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