OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ | 5 #ifndef CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ |
6 #define CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ | 6 #define CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "content/public/renderer/resource_fetcher.h" | 15 #include "content/public/renderer/resource_fetcher.h" |
16 #include "content/renderer/fetchers/web_url_loader_client_impl.h" | 16 #include "content/renderer/fetchers/web_url_loader_client_impl.h" |
17 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 17 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
18 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 18 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
19 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" | |
19 | 20 |
20 class GURL; | 21 class GURL; |
21 | 22 |
22 namespace blink { | 23 namespace blink { |
23 class WebFrame; | 24 class WebFrame; |
24 class WebURLLoader; | 25 class WebURLLoader; |
25 struct WebURLError; | 26 struct WebURLError; |
27 struct WebURLLoaderOptions; | |
tyoshino (SeeGerritForStatus)
2015/01/14 04:09:41
Remove?
mlamouri (slow - plz ping)
2015/01/14 14:31:17
Indeed. WebURLError too ;)
| |
26 } | 28 } |
27 | 29 |
28 namespace content { | 30 namespace content { |
29 | 31 |
30 class ResourceFetcherImpl : public ResourceFetcher, | 32 class ResourceFetcherImpl : public ResourceFetcher, |
31 public WebURLLoaderClientImpl { | 33 public WebURLLoaderClientImpl { |
32 public: | 34 public: |
33 // ResourceFetcher implementation: | 35 // ResourceFetcher implementation: |
34 void SetMethod(const std::string& method) override; | 36 void SetMethod(const std::string& method) override; |
35 void SetBody(const std::string& body) override; | 37 void SetBody(const std::string& body) override; |
36 void SetHeader(const std::string& header, const std::string& value) override; | 38 void SetHeader(const std::string& header, const std::string& value) override; |
39 void SetSkipServiceWorker(bool skip_service_worker) override; | |
40 void SetLoaderOptions(const blink::WebURLLoaderOptions& options) override; | |
37 void Start(blink::WebFrame* frame, | 41 void Start(blink::WebFrame* frame, |
38 blink::WebURLRequest::RequestContext request_context, | 42 blink::WebURLRequest::RequestContext request_context, |
39 blink::WebURLRequest::FrameType frame_type, | 43 blink::WebURLRequest::FrameType frame_type, |
40 LoaderType loader_type, | 44 LoaderType loader_type, |
41 const Callback& callback) override; | 45 const Callback& callback) override; |
42 void SetTimeout(const base::TimeDelta& timeout) override; | 46 void SetTimeout(const base::TimeDelta& timeout) override; |
43 | 47 |
44 private: | 48 private: |
45 friend class ResourceFetcher; | 49 friend class ResourceFetcher; |
46 | 50 |
47 explicit ResourceFetcherImpl(const GURL& url); | 51 explicit ResourceFetcherImpl(const GURL& url); |
48 | 52 |
49 virtual ~ResourceFetcherImpl(); | 53 virtual ~ResourceFetcherImpl(); |
50 | 54 |
51 // Callback for timer that limits how long we wait for the server. If this | 55 // Callback for timer that limits how long we wait for the server. If this |
52 // timer fires and the request hasn't completed, we kill the request. | 56 // timer fires and the request hasn't completed, we kill the request. |
53 void TimeoutFired(); | 57 void TimeoutFired(); |
54 | 58 |
55 // WebURLLoaderClientImpl methods: | 59 // WebURLLoaderClientImpl methods: |
56 void OnLoadComplete() override; | 60 void OnLoadComplete() override; |
57 void Cancel() override; | 61 void Cancel() override; |
58 | 62 |
59 scoped_ptr<blink::WebURLLoader> loader_; | 63 scoped_ptr<blink::WebURLLoader> loader_; |
60 | 64 |
65 // Options to send to the loader. | |
66 blink::WebURLLoaderOptions options_; | |
67 | |
61 // Request to send. Released once Start() is called. | 68 // Request to send. Released once Start() is called. |
62 blink::WebURLRequest request_; | 69 blink::WebURLRequest request_; |
63 | 70 |
64 // Callback when we're done. | 71 // Callback when we're done. |
65 Callback callback_; | 72 Callback callback_; |
66 | 73 |
67 // Limit how long to wait for the server. | 74 // Limit how long to wait for the server. |
68 base::OneShotTimer<ResourceFetcherImpl> timeout_timer_; | 75 base::OneShotTimer<ResourceFetcherImpl> timeout_timer_; |
69 | 76 |
70 DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); | 77 DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); |
71 }; | 78 }; |
72 | 79 |
73 } // namespace content | 80 } // namespace content |
74 | 81 |
75 #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ | 82 #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ |
OLD | NEW |