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 CONTENT_RENDERER_FETCHERS_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ | 5 #ifndef CONTENT_RENDERER_FETCHERS_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ |
6 #define CONTENT_RENDERER_FETCHERS_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ | 6 #define CONTENT_RENDERER_FETCHERS_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 "third_party/WebKit/public/platform/WebURLError.h" | 10 #include "third_party/WebKit/public/platform/WebURLError.h" |
11 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 11 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 namespace WebKit { | 14 namespace blink { |
15 class WebFrame; | 15 class WebFrame; |
16 class WebURLResponse; | 16 class WebURLResponse; |
17 } | 17 } |
18 | 18 |
19 namespace content { | 19 namespace content { |
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 third parameter (the | 27 // successfully or not. If there is a failure, the third parameter (the |
28 // data) will be empty. | 28 // data) will be empty. |
29 typedef base::Callback<void(WebKit::WebFrame*, | 29 typedef base::Callback<void(blink::WebFrame*, |
30 const WebKit::WebURLRequest&, | 30 const blink::WebURLRequest&, |
31 const WebKit::WebURLError&, | 31 const blink::WebURLError&, |
32 const std::string&)> Callback; | 32 const std::string&)> Callback; |
33 | 33 |
34 AltErrorPageResourceFetcher( | 34 AltErrorPageResourceFetcher( |
35 const GURL& url, | 35 const GURL& url, |
36 WebKit::WebFrame* frame, | 36 blink::WebFrame* frame, |
37 const WebKit::WebURLRequest& original_request, | 37 const blink::WebURLRequest& original_request, |
38 const WebKit::WebURLError& original_error, | 38 const blink::WebURLError& original_error, |
39 const Callback& callback); | 39 const Callback& callback); |
40 ~AltErrorPageResourceFetcher(); | 40 ~AltErrorPageResourceFetcher(); |
41 | 41 |
42 // Stop any pending loads. | 42 // Stop any pending loads. |
43 void Cancel(); | 43 void Cancel(); |
44 | 44 |
45 private: | 45 private: |
46 void OnURLFetchComplete(const WebKit::WebURLResponse& response, | 46 void OnURLFetchComplete(const blink::WebURLResponse& response, |
47 const std::string& data); | 47 const std::string& data); |
48 | 48 |
49 // Does the actual fetching. | 49 // Does the actual fetching. |
50 scoped_ptr<ResourceFetcherWithTimeout> fetcher_; | 50 scoped_ptr<ResourceFetcherWithTimeout> fetcher_; |
51 | 51 |
52 WebKit::WebFrame* frame_; | 52 blink::WebFrame* frame_; |
53 Callback callback_; | 53 Callback callback_; |
54 | 54 |
55 // The original request. If loading the alternate error page fails, it's | 55 // The original request. If loading the alternate error page fails, it's |
56 // needed to generate the error page. | 56 // needed to generate the error page. |
57 WebKit::WebURLRequest original_request_; | 57 blink::WebURLRequest original_request_; |
58 | 58 |
59 // The error associated with this load. If there's an error talking with the | 59 // The error associated with this load. If there's an error talking with the |
60 // alt error page server, we need this to complete the original load. | 60 // alt error page server, we need this to complete the original load. |
61 WebKit::WebURLError original_error_; | 61 blink::WebURLError original_error_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(AltErrorPageResourceFetcher); | 63 DISALLOW_COPY_AND_ASSIGN(AltErrorPageResourceFetcher); |
64 }; | 64 }; |
65 | 65 |
66 } // namespace content | 66 } // namespace content |
67 | 67 |
68 #endif // CONTENT_RENDERER_FETCHERS_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ | 68 #endif // CONTENT_RENDERER_FETCHERS_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_ |
OLD | NEW |