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