| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_PUBLIC_RENDERER_RESOURCE_FETCHER_H_ | 5 #ifndef CONTENT_PUBLIC_RENDERER_RESOURCE_FETCHER_H_ |
| 6 #define CONTENT_PUBLIC_RENDERER_RESOURCE_FETCHER_H_ | 6 #define CONTENT_PUBLIC_RENDERER_RESOURCE_FETCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 12 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class TimeDelta; | 17 class TimeDelta; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 class WebFrame; | 21 class WebFrame; |
| 22 class WebURLResponse; | 22 class WebURLResponse; |
| 23 struct WebURLLoaderOptions; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 // Interface to download resources asynchronously. | 28 // Interface to download resources asynchronously. |
| 28 class CONTENT_EXPORT ResourceFetcher { | 29 class CONTENT_EXPORT ResourceFetcher { |
| 29 public: | 30 public: |
| 30 enum LoaderType { | 31 enum LoaderType { |
| 31 PLATFORM_LOADER, // uses Platform::createURLLoader | 32 PLATFORM_LOADER, // uses Platform::createURLLoader |
| 32 FRAME_ASSOCIATED_LOADER, // uses WebFrame::createAssociatedURLLoader | 33 FRAME_ASSOCIATED_LOADER, // uses WebFrame::createAssociatedURLLoader |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 // ownership of the returned object. Deleting the ResourceFetcher will cancel | 46 // ownership of the returned object. Deleting the ResourceFetcher will cancel |
| 46 // the request, and the callback will never be run. | 47 // the request, and the callback will never be run. |
| 47 static ResourceFetcher* Create(const GURL& url); | 48 static ResourceFetcher* Create(const GURL& url); |
| 48 | 49 |
| 49 // Set the corresponding parameters of the request. Must be called before | 50 // Set the corresponding parameters of the request. Must be called before |
| 50 // Start. By default, requests are GETs with no body. | 51 // Start. By default, requests are GETs with no body. |
| 51 virtual void SetMethod(const std::string& method) = 0; | 52 virtual void SetMethod(const std::string& method) = 0; |
| 52 virtual void SetBody(const std::string& body) = 0; | 53 virtual void SetBody(const std::string& body) = 0; |
| 53 virtual void SetHeader(const std::string& header, | 54 virtual void SetHeader(const std::string& header, |
| 54 const std::string& value) = 0; | 55 const std::string& value) = 0; |
| 56 virtual void SetSkipServiceWorker(bool skip_service_worker) = 0; |
| 57 |
| 58 // Associate the corresponding WebURLLoaderOptions to the loader. Must be |
| 59 // called before Start. Used if the LoaderType is FRAME_ASSOCIATED_LOADER. |
| 60 virtual void SetLoaderOptions(const blink::WebURLLoaderOptions& options) = 0; |
| 55 | 61 |
| 56 // Starts the request using the specified frame. Calls |callback| when | 62 // Starts the request using the specified frame. Calls |callback| when |
| 57 // done. | 63 // done. |
| 58 virtual void Start(blink::WebFrame* frame, | 64 virtual void Start(blink::WebFrame* frame, |
| 59 blink::WebURLRequest::RequestContext request_context, | 65 blink::WebURLRequest::RequestContext request_context, |
| 60 blink::WebURLRequest::FrameType frame_type, | 66 blink::WebURLRequest::FrameType frame_type, |
| 61 LoaderType loader_type, | 67 LoaderType loader_type, |
| 62 const Callback& callback) = 0; | 68 const Callback& callback) = 0; |
| 63 | 69 |
| 64 // Sets how long to wait for the server to reply. By default, there is no | 70 // Sets how long to wait for the server to reply. By default, there is no |
| 65 // timeout. Must be called after a request is started. | 71 // timeout. Must be called after a request is started. |
| 66 virtual void SetTimeout(const base::TimeDelta& timeout) = 0; | 72 virtual void SetTimeout(const base::TimeDelta& timeout) = 0; |
| 67 | 73 |
| 68 // Manually cancel the request. | 74 // Manually cancel the request. |
| 69 virtual void Cancel() = 0; | 75 virtual void Cancel() = 0; |
| 70 }; | 76 }; |
| 71 | 77 |
| 72 } // namespace content | 78 } // namespace content |
| 73 | 79 |
| 74 #endif // CONTENT_PUBLIC_RENDERER_RESOURCE_FETCHER_H_ | 80 #endif // CONTENT_PUBLIC_RENDERER_RESOURCE_FETCHER_H_ |
| OLD | NEW |