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; |
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 SetLoaderOptions(const blink::WebURLLoaderOptions& options) override; |
37 void Start(blink::WebFrame* frame, | 40 void Start(blink::WebFrame* frame, |
38 blink::WebURLRequest::RequestContext request_context, | 41 blink::WebURLRequest::RequestContext request_context, |
39 blink::WebURLRequest::FrameType frame_type, | 42 blink::WebURLRequest::FrameType frame_type, |
40 LoaderType loader_type, | 43 LoaderType loader_type, |
41 const Callback& callback) override; | 44 const Callback& callback) override; |
42 void SetTimeout(const base::TimeDelta& timeout) override; | 45 void SetTimeout(const base::TimeDelta& timeout) override; |
43 | 46 |
44 private: | 47 private: |
45 friend class ResourceFetcher; | 48 friend class ResourceFetcher; |
46 | 49 |
47 explicit ResourceFetcherImpl(const GURL& url); | 50 explicit ResourceFetcherImpl(const GURL& url); |
48 | 51 |
49 virtual ~ResourceFetcherImpl(); | 52 virtual ~ResourceFetcherImpl(); |
50 | 53 |
51 // Callback for timer that limits how long we wait for the server. If this | 54 // 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. | 55 // timer fires and the request hasn't completed, we kill the request. |
53 void TimeoutFired(); | 56 void TimeoutFired(); |
54 | 57 |
55 // WebURLLoaderClientImpl methods: | 58 // WebURLLoaderClientImpl methods: |
56 void OnLoadComplete() override; | 59 void OnLoadComplete() override; |
57 void Cancel() override; | 60 void Cancel() override; |
58 | 61 |
59 scoped_ptr<blink::WebURLLoader> loader_; | 62 scoped_ptr<blink::WebURLLoader> loader_; |
60 | 63 |
| 64 // Options to send to the loader. |
| 65 blink::WebURLLoaderOptions options_; |
| 66 |
61 // Request to send. Released once Start() is called. | 67 // Request to send. Released once Start() is called. |
62 blink::WebURLRequest request_; | 68 blink::WebURLRequest request_; |
63 | 69 |
64 // Callback when we're done. | 70 // Callback when we're done. |
65 Callback callback_; | 71 Callback callback_; |
66 | 72 |
67 // Limit how long to wait for the server. | 73 // Limit how long to wait for the server. |
68 base::OneShotTimer<ResourceFetcherImpl> timeout_timer_; | 74 base::OneShotTimer<ResourceFetcherImpl> timeout_timer_; |
69 | 75 |
70 DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); | 76 DISALLOW_COPY_AND_ASSIGN(ResourceFetcherImpl); |
71 }; | 77 }; |
72 | 78 |
73 } // namespace content | 79 } // namespace content |
74 | 80 |
75 #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ | 81 #endif // CONTENT_RENDERER_FETCHERS_RESOURCE_FETCHER_H_ |
OLD | NEW |