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_old.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 | 12 |
13 namespace WebKit { | 13 namespace WebKit { |
14 class WebFrame; | 14 class WebFrame; |
15 class WebURLResponse; | 15 class WebURLResponse; |
16 } | 16 } |
17 | 17 |
18 namespace webkit_glue { | 18 namespace webkit_glue { |
19 class ResourceFetcherWithTimeout; | 19 class ResourceFetcherWithTimeout; |
20 | 20 |
21 // Used for downloading alternate dns error pages. Once downloading is done | 21 // Used for downloading alternate dns error pages. Once downloading is done |
22 // (or fails), the webview delegate is notified. | 22 // (or fails), the webview delegate is notified. |
23 class AltErrorPageResourceFetcher { | 23 class AltErrorPageResourceFetcher { |
24 public: | 24 public: |
25 // 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, |
26 // 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 |
27 // data) will be empty. | 27 // data) will be empty. |
28 typedef Callback3<WebKit::WebFrame*, const WebKit::WebURLError&, | 28 typedef base::Callback<void(WebKit::WebFrame*, const WebKit::WebURLError&, |
29 const std::string&>::Type Callback; | 29 const std::string&)> Callback; |
30 | 30 |
31 AltErrorPageResourceFetcher(const GURL& url, | 31 AltErrorPageResourceFetcher(const GURL& url, |
32 WebKit::WebFrame* frame, | 32 WebKit::WebFrame* frame, |
33 const WebKit::WebURLError& original_error, | 33 const WebKit::WebURLError& original_error, |
34 Callback* callback); | 34 const 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 WebKit::WebFrame* frame_; | 47 WebKit::WebFrame* frame_; |
48 scoped_ptr<Callback> callback_; | 48 Callback callback_; |
49 | 49 |
50 // 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 |
51 // 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. |
52 WebKit::WebURLError original_error_; | 52 WebKit::WebURLError original_error_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(AltErrorPageResourceFetcher); | 54 DISALLOW_COPY_AND_ASSIGN(AltErrorPageResourceFetcher); |
55 }; | 55 }; |
56 | 56 |
57 } // namespace webkit_glue | 57 } // namespace webkit_glue |
58 | 58 |
59 #endif // WEBKIT_GLUE_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ | 59 #endif // WEBKIT_GLUE_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ |
OLD | NEW |