| 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 // A wrapper around ResourceHandle and ResourceHandleClient that simplifies | 5 // A wrapper around ResourceHandle and ResourceHandleClient that simplifies |
| 6 // the download of an HTTP object. The interface is modeled after URLFetcher | 6 // the download of an HTTP object. The interface is modeled after URLFetcher |
| 7 // in the /chrome/browser. | 7 // in the /chrome/browser. |
| 8 // | 8 // |
| 9 // ResourceFetcher::Delegate::OnURLFetchComplete will be called async after | 9 // ResourceFetcher::Delegate::OnURLFetchComplete will be called async after |
| 10 // the ResourceFetcher object is created. | 10 // the ResourceFetcher object is created. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // This will be called when the URL has been fetched, successfully or not. | 38 // This will be called when the URL has been fetched, successfully or not. |
| 39 // If there is a failure, response and data will both be empty. |response| | 39 // If there is a failure, response and data will both be empty. |response| |
| 40 // and |data| are both valid until the URLFetcher instance is destroyed. | 40 // and |data| are both valid until the URLFetcher instance is destroyed. |
| 41 typedef Callback2<const WebKit::WebURLResponse&, | 41 typedef Callback2<const WebKit::WebURLResponse&, |
| 42 const std::string&>::Type Callback; | 42 const std::string&>::Type Callback; |
| 43 | 43 |
| 44 // We need a frame to make requests. | 44 // We need a frame to make requests. |
| 45 ResourceFetcher( | 45 ResourceFetcher( |
| 46 const GURL& url, WebKit::WebFrame* frame, | 46 const GURL& url, WebKit::WebFrame* frame, |
| 47 WebKit::WebURLRequest::TargetType target_type, Callback* callback); | 47 WebKit::WebURLRequest::TargetType target_type, Callback* callback); |
| 48 ~ResourceFetcher(); | 48 virtual ~ResourceFetcher(); |
| 49 | 49 |
| 50 // Stop the request and don't call the callback. | 50 // Stop the request and don't call the callback. |
| 51 void Cancel(); | 51 void Cancel(); |
| 52 | 52 |
| 53 bool completed() const { return completed_; } | 53 bool completed() const { return completed_; } |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 // WebURLLoaderClient methods: | 56 // WebURLLoaderClient methods: |
| 57 virtual void willSendRequest( | 57 virtual void willSendRequest( |
| 58 WebKit::WebURLLoader* loader, WebKit::WebURLRequest& new_request, | 58 WebKit::WebURLLoader* loader, WebKit::WebURLRequest& new_request, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // kill the request. | 121 // kill the request. |
| 122 void TimeoutFired(); | 122 void TimeoutFired(); |
| 123 | 123 |
| 124 // Limit how long we wait for the alternate error page server. | 124 // Limit how long we wait for the alternate error page server. |
| 125 base::OneShotTimer<ResourceFetcherWithTimeout> timeout_timer_; | 125 base::OneShotTimer<ResourceFetcherWithTimeout> timeout_timer_; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 } // namespace webkit_glue | 128 } // namespace webkit_glue |
| 129 | 129 |
| 130 #endif // WEBKIT_GLUE_RESOURCE_FETCHER_H_ | 130 #endif // WEBKIT_GLUE_RESOURCE_FETCHER_H_ |
| OLD | NEW |