| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 WEBKIT_GLUE_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ | 5 #ifndef WEBKIT_GLUE_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ |
| 6 #define WEBKIT_GLUE_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ | 6 #define WEBKIT_GLUE_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 | 11 |
| 12 class WebFrame; | 12 class WebFrame; |
| 13 | 13 |
| 14 namespace WebKit { | 14 namespace WebKit { |
| 15 class WebURLResponse; | 15 class WebURLResponse; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace webkit_glue { | 18 namespace webkit_glue { |
| 19 | 19 |
| 20 class ResourceFetcherWithTimeout; | 20 class ResourceFetcherWithTimeout; |
| 21 | 21 |
| 22 // Used for downloading alternate dns error pages. Once downloading is done | 22 // Used for downloading alternate dns error pages. Once downloading is done |
| 23 // (or fails), the webview delegate is notified. | 23 // (or fails), the webview delegate is notified. |
| 24 class AltErrorPageResourceFetcher { | 24 class AltErrorPageResourceFetcher { |
| 25 public: | 25 public: |
| 26 // This will be called when the alternative error page has been fetched, | 26 // This will be called when the alternative error page has been fetched, |
| 27 // successfully or not. If there is a failure, the second parameter (the | 27 // successfully or not. If there is a failure, the second parameter (the |
| 28 // data) will be empty. | 28 // data) will be empty. |
| 29 typedef Callback2<const GURL&, const std::string&>::Type Callback; | 29 typedef Callback3<WebFrame*, const GURL&, const std::string&>::Type Callback; |
| 30 | 30 |
| 31 AltErrorPageResourceFetcher(const GURL& url, | 31 AltErrorPageResourceFetcher(const GURL& url, |
| 32 WebFrame* frame, | 32 WebFrame* frame, |
| 33 const GURL& unreachable_url, | 33 const GURL& unreachable_url, |
| 34 Callback* callback); | 34 Callback* callback); |
| 35 ~AltErrorPageResourceFetcher(); | 35 ~AltErrorPageResourceFetcher(); |
| 36 | 36 |
| 37 // Stop any pending loads. | 37 // Stop any pending loads. |
| 38 void Cancel(); | 38 void Cancel(); |
| 39 | 39 |
| 40 private: | 40 private: |
| 41 void OnURLFetchComplete(const WebKit::WebURLResponse& response, | 41 void OnURLFetchComplete(const WebKit::WebURLResponse& response, |
| 42 const std::string& data); | 42 const std::string& data); |
| 43 | 43 |
| 44 // Does the actual fetching. | 44 // Does the actual fetching. |
| 45 scoped_ptr<ResourceFetcherWithTimeout> fetcher_; | 45 scoped_ptr<ResourceFetcherWithTimeout> fetcher_; |
| 46 | 46 |
| 47 WebFrame* frame_; |
| 47 scoped_ptr<Callback> callback_; | 48 scoped_ptr<Callback> callback_; |
| 48 | 49 |
| 49 // The "unreachable url" associated with this load. If there's an error | 50 // The "unreachable url" associated with this load. If there's an error |
| 50 // talking with the alt 404 page server, we need this to complete the | 51 // talking with the alt 404 page server, we need this to complete the |
| 51 // original load. | 52 // original load. |
| 52 GURL unreachable_url_; | 53 GURL unreachable_url_; |
| 53 | 54 |
| 54 DISALLOW_COPY_AND_ASSIGN(AltErrorPageResourceFetcher); | 55 DISALLOW_COPY_AND_ASSIGN(AltErrorPageResourceFetcher); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 } // namespace webkit_glue | 58 } // namespace webkit_glue |
| 58 | 59 |
| 59 #endif // WEBKIT_GLUE_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ | 60 #endif // WEBKIT_GLUE_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ |
| OLD | NEW |