[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" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 12 | #include "base/macros.h" |
Takashi Toyoshima | 6ece8de | 2017-08-30 11:36:48 | [diff] [blame] | 13 | #include "base/time/time.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" |
Takashi Toyoshima | 6ece8de | 2017-08-30 11:36:48 | [diff] [blame] | 16 | #include "net/http/http_request_headers.h" |
John Abd-El-Malek | 1df6179 | 2018-01-12 20:40:45 | [diff] [blame] | 17 | #include "services/network/public/cpp/resource_request.h" |
[email protected] | 5c30b5e0 | 2013-05-30 03:46:08 | [diff] [blame] | 18 | #include "third_party/WebKit/public/platform/WebURLRequest.h" |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 19 | |
20 | class GURL; | ||||
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 21 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 22 | namespace blink { |
yhirano | 505d1e6 | 2017-05-08 10:37:35 | [diff] [blame] | 23 | class WebLocalFrame; |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 24 | } |
25 | |||||
[email protected] | f8c700ba | 2013-05-14 08:25:49 | [diff] [blame] | 26 | namespace content { |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 27 | |
tyoshino | 6d76711 | 2016-10-24 06:44:53 | [diff] [blame] | 28 | class ResourceFetcherImpl : public ResourceFetcher { |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 29 | public: |
[email protected] | 885e54f1 | 2013-11-25 21:01:58 | [diff] [blame] | 30 | // ResourceFetcher implementation: |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 31 | void SetMethod(const std::string& method) override; |
32 | void SetBody(const std::string& body) override; | ||||
33 | void SetHeader(const std::string& header, const std::string& value) override; | ||||
yhirano | 505d1e6 | 2017-05-08 10:37:35 | [diff] [blame] | 34 | void Start(blink::WebLocalFrame* frame, |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 35 | blink::WebURLRequest::RequestContext request_context, |
Chong Zhang | b7c8d1ce | 2018-03-13 19:14:11 | [diff] [blame] | 36 | scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, |
Takashi Toyoshima | 6448dc95 | 2017-08-31 07:20:48 | [diff] [blame] | 37 | const net::NetworkTrafficAnnotationTag& annotation_tag, |
Takashi Toyoshima | c3bd1cf | 2017-09-05 06:32:47 | [diff] [blame] | 38 | Callback callback, |
Takashi Toyoshima | 6448dc95 | 2017-08-31 07:20:48 | [diff] [blame] | 39 | size_t maximum_download_size) override; |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 40 | void SetTimeout(const base::TimeDelta& timeout) override; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 41 | |
[email protected] | 885e54f1 | 2013-11-25 21:01:58 | [diff] [blame] | 42 | private: |
43 | friend class ResourceFetcher; | ||||
44 | |||||
tyoshino | 6d76711 | 2016-10-24 06:44:53 | [diff] [blame] | 45 | class ClientImpl; |
46 | |||||
[email protected] | ec5b02bb | 2014-01-28 13:32:03 | [diff] [blame] | 47 | explicit ResourceFetcherImpl(const GURL& url); |
[email protected] | 1a040f9 | 2013-11-14 06:08:46 | [diff] [blame] | 48 | |
avi | 5c77d21 | 2015-09-25 20:08:25 | [diff] [blame] | 49 | ~ResourceFetcherImpl() override; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 50 | |
tyoshino | 6d76711 | 2016-10-24 06:44:53 | [diff] [blame] | 51 | void OnLoadComplete(); |
Takashi Toyoshima | beba932 | 2017-09-07 06:27:14 | [diff] [blame] | 52 | void OnTimeout(); |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 53 | |
tyoshino | 6d76711 | 2016-10-24 06:44:53 | [diff] [blame] | 54 | std::unique_ptr<ClientImpl> client_; |
mlamouri | f484b43a | 2015-01-14 19:03:43 | [diff] [blame] | 55 | |
kinuko | a2b5c2e | 2016-07-13 02:12:37 | [diff] [blame] | 56 | // Request to send. |
John Abd-El-Malek | 1df6179 | 2018-01-12 20:40:45 | [diff] [blame] | 57 | network::ResourceRequest request_; |
Takashi Toyoshima | 6ece8de | 2017-08-30 11:36:48 | [diff] [blame] | 58 | |
[email protected] | 1a040f9 | 2013-11-14 06:08:46 | [diff] [blame] | 59 | // Limit how long to wait for the server. |
danakj | 8c3eb80 | 2015-09-24 07:53:00 | [diff] [blame] | 60 | base::OneShotTimer timeout_timer_; |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 61 | |
[email protected] | 885e54f1 | 2013-11-25 21:01:58 | [diff] [blame] | 62 | DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); |
initial.commit | f5b16fe | 2008-07-27 00:20:51 | [diff] [blame] | 63 | }; |
64 | |||||
[email protected] | f8c700ba | 2013-05-14 08:25:49 | [diff] [blame] | 65 | } // namespace content |
[email protected] | f6134ff | 2009-07-07 16:44:39 | [diff] [blame] | 66 | |
tfarina | bccc34c7 | 2015-02-27 21:32:15 | [diff] [blame] | 67 | #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_IMPL_H_ |