Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc

Issue 1001003004: [Android WebView] Implement a better OnReceivedError callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the last comment Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" 5 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "android_webview/browser/aw_contents_io_thread_client.h" 9 #include "android_webview/browser/aw_contents_io_thread_client.h"
10 #include "android_webview/browser/aw_login_delegate.h" 10 #include "android_webview/browser/aw_login_delegate.h"
11 #include "android_webview/browser/aw_resource_context.h" 11 #include "android_webview/browser/aw_resource_context.h"
12 #include "android_webview/common/url_constants.h" 12 #include "android_webview/common/url_constants.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "components/auto_login_parser/auto_login_parser.h" 15 #include "components/auto_login_parser/auto_login_parser.h"
16 #include "components/navigation_interception/intercept_navigation_delegate.h" 16 #include "components/navigation_interception/intercept_navigation_delegate.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/resource_controller.h" 18 #include "content/public/browser/resource_controller.h"
19 #include "content/public/browser/resource_dispatcher_host.h" 19 #include "content/public/browser/resource_dispatcher_host.h"
20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 20 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
21 #include "content/public/browser/resource_request_info.h" 21 #include "content/public/browser/resource_request_info.h"
22 #include "content/public/browser/resource_throttle.h" 22 #include "content/public/browser/resource_throttle.h"
23 #include "net/base/load_flags.h" 23 #include "net/base/load_flags.h"
24 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
25 #include "net/http/http_response_headers.h" 25 #include "net/http/http_response_headers.h"
26 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
27 #include "net/url_request/url_request_status.h"
27 #include "url/url_constants.h" 28 #include "url/url_constants.h"
28 29
29 using android_webview::AwContentsIoThreadClient; 30 using android_webview::AwContentsIoThreadClient;
30 using content::BrowserThread; 31 using content::BrowserThread;
31 using content::ResourceType; 32 using content::ResourceType;
32 using navigation_interception::InterceptNavigationDelegate; 33 using navigation_interception::InterceptNavigationDelegate;
33 34
34 namespace { 35 namespace {
35 36
36 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate> 37 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate>
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 235 }
235 236
236 void AwResourceDispatcherHostDelegate::OnRequestRedirected( 237 void AwResourceDispatcherHostDelegate::OnRequestRedirected(
237 const GURL& redirect_url, 238 const GURL& redirect_url,
238 net::URLRequest* request, 239 net::URLRequest* request,
239 content::ResourceContext* resource_context, 240 content::ResourceContext* resource_context,
240 content::ResourceResponse* response) { 241 content::ResourceResponse* response) {
241 AddExtraHeadersIfNeeded(request, resource_context); 242 AddExtraHeadersIfNeeded(request, resource_context);
242 } 243 }
243 244
245 void AwResourceDispatcherHostDelegate::RequestComplete(
246 net::URLRequest* request) {
247 if (request && !request->status().is_success()) {
248 const content::ResourceRequestInfo* request_info =
249 content::ResourceRequestInfo::ForRequest(request);
250 scoped_ptr<AwContentsIoThreadClient> io_client =
251 AwContentsIoThreadClient::FromID(request_info->GetChildID(),
252 request_info->GetRenderFrameID());
253 if (io_client) {
254 io_client->OnReceivedError(request);
255 } else {
256 DLOG(WARNING) << "io_client is null, onReceivedError dropped for " <<
257 request->url();
258 }
259 }
260 }
261
244 262
245 void AwResourceDispatcherHostDelegate::DownloadStarting( 263 void AwResourceDispatcherHostDelegate::DownloadStarting(
246 net::URLRequest* request, 264 net::URLRequest* request,
247 content::ResourceContext* resource_context, 265 content::ResourceContext* resource_context,
248 int child_id, 266 int child_id,
249 int route_id, 267 int route_id,
250 int request_id, 268 int request_id,
251 bool is_content_initiated, 269 bool is_content_initiated,
252 bool must_download, 270 bool must_download,
253 ScopedVector<content::ResourceThrottle>* throttles) { 271 ScopedVector<content::ResourceThrottle>* throttles) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 net::HttpRequestHeaders headers; 436 net::HttpRequestHeaders headers;
419 headers.AddHeadersFromString(extra_headers); 437 headers.AddHeadersFromString(extra_headers);
420 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { 438 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) {
421 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); 439 request->SetExtraRequestHeaderByName(it.name(), it.value(), false);
422 } 440 }
423 } 441 }
424 } 442 }
425 } 443 }
426 444
427 } // namespace android_webview 445 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698