| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // is destroyed. | 41 // is destroyed. |
| 42 typedef base::Callback<void(const blink::WebURLResponse& response, | 42 typedef base::Callback<void(const blink::WebURLResponse& response, |
| 43 const std::string& data)> Callback; | 43 const std::string& data)> Callback; |
| 44 | 44 |
| 45 // Creates a ResourceFetcher for the specified resource. Caller takes | 45 // Creates a ResourceFetcher for the specified resource. Caller takes |
| 46 // ownership of the returned object. Deleting the ResourceFetcher will cancel | 46 // ownership of the returned object. Deleting the ResourceFetcher will cancel |
| 47 // the request, and the callback will never be run. | 47 // the request, and the callback will never be run. |
| 48 static ResourceFetcher* Create(const GURL& url); | 48 static ResourceFetcher* Create(const GURL& url); |
| 49 | 49 |
| 50 // Set the corresponding parameters of the request. Must be called before | 50 // Set the corresponding parameters of the request. Must be called before |
| 51 // Start. By default, requests are GETs with no body. | 51 // Start. By default, requests are GETs with no body and respect the default |
| 52 // cache policy. |
| 52 virtual void SetMethod(const std::string& method) = 0; | 53 virtual void SetMethod(const std::string& method) = 0; |
| 53 virtual void SetBody(const std::string& body) = 0; | 54 virtual void SetBody(const std::string& body) = 0; |
| 54 virtual void SetHeader(const std::string& header, | 55 virtual void SetHeader(const std::string& header, |
| 55 const std::string& value) = 0; | 56 const std::string& value) = 0; |
| 56 virtual void SetSkipServiceWorker(bool skip_service_worker) = 0; | 57 virtual void SetSkipServiceWorker(bool skip_service_worker) = 0; |
| 58 virtual void SetCachePolicy(blink::WebURLRequest::CachePolicy policy) = 0; |
| 57 | 59 |
| 58 // Associate the corresponding WebURLLoaderOptions to the loader. Must be | 60 // Associate the corresponding WebURLLoaderOptions to the loader. Must be |
| 59 // called before Start. Used if the LoaderType is FRAME_ASSOCIATED_LOADER. | 61 // called before Start. Used if the LoaderType is FRAME_ASSOCIATED_LOADER. |
| 60 virtual void SetLoaderOptions(const blink::WebURLLoaderOptions& options) = 0; | 62 virtual void SetLoaderOptions(const blink::WebURLLoaderOptions& options) = 0; |
| 61 | 63 |
| 62 // Starts the request using the specified frame. Calls |callback| when | 64 // Starts the request using the specified frame. Calls |callback| when |
| 63 // done. | 65 // done. |
| 64 virtual void Start(blink::WebFrame* frame, | 66 virtual void Start(blink::WebFrame* frame, |
| 65 blink::WebURLRequest::RequestContext request_context, | 67 blink::WebURLRequest::RequestContext request_context, |
| 66 blink::WebURLRequest::FrameType frame_type, | 68 blink::WebURLRequest::FrameType frame_type, |
| 67 LoaderType loader_type, | 69 LoaderType loader_type, |
| 68 const Callback& callback) = 0; | 70 const Callback& callback) = 0; |
| 69 | 71 |
| 70 // Sets how long to wait for the server to reply. By default, there is no | 72 // Sets how long to wait for the server to reply. By default, there is no |
| 71 // timeout. Must be called after a request is started. | 73 // timeout. Must be called after a request is started. |
| 72 virtual void SetTimeout(const base::TimeDelta& timeout) = 0; | 74 virtual void SetTimeout(const base::TimeDelta& timeout) = 0; |
| 73 | 75 |
| 74 // Manually cancel the request. | 76 // Manually cancel the request. |
| 75 virtual void Cancel() = 0; | 77 virtual void Cancel() = 0; |
| 76 }; | 78 }; |
| 77 | 79 |
| 78 } // namespace content | 80 } // namespace content |
| 79 | 81 |
| 80 #endif // CONTENT_PUBLIC_RENDERER_RESOURCE_FETCHER_H_ | 82 #endif // CONTENT_PUBLIC_RENDERER_RESOURCE_FETCHER_H_ |
| OLD | NEW |