[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 4 | |
tfarina | bccc34c7 | 2015-02-27 21:32:15 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_IMPL_H_ |
6 | #define CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_IMPL_H_ | ||||
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 7 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 8 | #include <memory> |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 9 | #include <string> |
10 | |||||
[email protected] | 92d86a2c | 2011-11-22 00:49:23 | [diff] [blame] | 11 | #include "base/callback.h" |
[email protected] | 51678ad | 2011-12-02 19:07:50 | [diff] [blame] | 12 | #include "base/compiler_specific.h" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 13 | #include "base/macros.h" |
[email protected] | abb52216 | 2013-06-28 01:54:16 | [diff] [blame] | 14 | #include "base/timer/timer.h" |
[email protected] | 885e54f1 | 2013-11-25 21:01:58 | [diff] [blame] | 15 | #include "content/public/renderer/resource_fetcher.h" |
[email protected] | 5c30b5e0 | 2013-05-30 03:46:08 | [diff] [blame] | 16 | #include "third_party/WebKit/public/platform/WebURLRequest.h" |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 17 | |
18 | class GURL; | ||||
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 19 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 20 | namespace blink { |
yhirano | 505d1e6 | 2017-05-08 10:37:35 | [diff] [blame^] | 21 | class WebLocalFrame; |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 22 | class WebURLLoader; |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 23 | } |
24 | |||||
[email protected] | f8c700ba | 2013-05-14 08:25:49 | [diff] [blame] | 25 | namespace content { |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 26 | |
tyoshino | 6d76711 | 2016-10-24 06:44:53 | [diff] [blame] | 27 | class ResourceFetcherImpl : public ResourceFetcher { |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 28 | public: |
[email protected] | 885e54f1 | 2013-11-25 21:01:58 | [diff] [blame] | 29 | // ResourceFetcher implementation: |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 30 | void SetMethod(const std::string& method) override; |
31 | void SetBody(const std::string& body) override; | ||||
32 | void SetHeader(const std::string& header, const std::string& value) override; | ||||
yhirano | 505d1e6 | 2017-05-08 10:37:35 | [diff] [blame^] | 33 | void Start(blink::WebLocalFrame* frame, |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 34 | blink::WebURLRequest::RequestContext request_context, |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 35 | const Callback& callback) override; |
36 | void SetTimeout(const base::TimeDelta& timeout) override; | ||||
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 37 | |
[email protected] | 885e54f1 | 2013-11-25 21:01:58 | [diff] [blame] | 38 | private: |
39 | friend class ResourceFetcher; | ||||
40 | |||||
tyoshino | 6d76711 | 2016-10-24 06:44:53 | [diff] [blame] | 41 | class ClientImpl; |
42 | |||||
[email protected] | ec5b02bb | 2014-01-28 13:32:03 | [diff] [blame] | 43 | explicit ResourceFetcherImpl(const GURL& url); |
[email protected] | 1a040f9 | 2013-11-14 06:08:46 | [diff] [blame] | 44 | |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 45 | ~ResourceFetcherImpl() override; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 46 | |
tyoshino | 6d76711 | 2016-10-24 06:44:53 | [diff] [blame] | 47 | void OnLoadComplete(); |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 48 | void Cancel() override; |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 49 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 50 | std::unique_ptr<blink::WebURLLoader> loader_; |
tyoshino | 6d76711 | 2016-10-24 06:44:53 | [diff] [blame] | 51 | std::unique_ptr<ClientImpl> client_; |
mlamouri | f484b43a | 2015-01-14 19:03:43 | [diff] [blame] | 52 | |
kinuko | a2b5c2e | 2016-07-13 02:12:37 | [diff] [blame] | 53 | // Request to send. |
[email protected] | ec5b02bb | 2014-01-28 13:32:03 | [diff] [blame] | 54 | blink::WebURLRequest request_; |
55 | |||||
[email protected] | 1a040f9 | 2013-11-14 06:08:46 | [diff] [blame] | 56 | // Limit how long to wait for the server. |
danakj | 8c3eb80 | 2015-09-24 07:53:00 | [diff] [blame] | 57 | base::OneShotTimer timeout_timer_; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 58 | |
[email protected] | 885e54f1 | 2013-11-25 21:01:58 | [diff] [blame] | 59 | DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 60 | }; |
61 | |||||
[email protected] | f8c700ba | 2013-05-14 08:25:49 | [diff] [blame] | 62 | } // namespace content |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 63 | |
tfarina | bccc34c7 | 2015-02-27 21:32:15 | [diff] [blame] | 64 | #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_IMPL_H_ |