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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_FETCHERS_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_
6 #define CONTENT_RENDERER_FETCHERS_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "third_party/WebKit/public/platform/WebURLError.h"
11 #include "third_party/WebKit/public/platform/WebURLRequest.h"
20 class ResourceFetcherWithTimeout;
22 // Used for downloading alternate dns error pages. Once downloading is done
23 // (or fails), the webview delegate is notified.
24 class AltErrorPageResourceFetcher {
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
28 // data) will be empty.
29 typedef base::Callback<void(WebKit::WebFrame*,
30 const WebKit::WebURLRequest&,
31 const WebKit::WebURLError&,
32 const std::string&)> Callback;
34 AltErrorPageResourceFetcher(
36 WebKit::WebFrame* frame,
37 const WebKit::WebURLRequest& original_request,
38 const WebKit::WebURLError& original_error,
39 const Callback& callback);
40 ~AltErrorPageResourceFetcher();
42 // Stop any pending loads.
46 void OnURLFetchComplete(const WebKit::WebURLResponse& response,
47 const std::string& data);
49 // Does the actual fetching.
50 scoped_ptr<ResourceFetcherWithTimeout> fetcher_;
52 WebKit::WebFrame* frame_;
55 // The original request. If loading the alternate error page fails, it's
56 // needed to generate the error page.
57 WebKit::WebURLRequest original_request_;
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.
61 WebKit::WebURLError original_error_;
63 DISALLOW_COPY_AND_ASSIGN(AltErrorPageResourceFetcher);
66 } // namespace content
68 #endif // CONTENT_RENDERER_FETCHERS_ALT_ERROR_PAGE_RESOURCE_FETCHER_H_