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

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

Issue 2567043003: Revert of Move onReceivedError and onReceivedHttpError out of AwContentsIoThreadClientImpl (Closed)
Patch Set: Created 4 years 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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "android_webview/browser/aw_browser_context.h" 10 #include "android_webview/browser/aw_browser_context.h"
11 #include "android_webview/browser/aw_contents_client_bridge_base.h" 11 #include "android_webview/browser/aw_contents_client_bridge_base.h"
12 #include "android_webview/browser/aw_contents_io_thread_client.h" 12 #include "android_webview/browser/aw_contents_io_thread_client.h"
13 #include "android_webview/browser/aw_login_delegate.h" 13 #include "android_webview/browser/aw_login_delegate.h"
14 #include "android_webview/browser/aw_resource_context.h" 14 #include "android_webview/browser/aw_resource_context.h"
15 #include "android_webview/browser/net/aw_web_resource_request.h"
16 #include "android_webview/browser/renderer_host/auto_login_parser.h" 15 #include "android_webview/browser/renderer_host/auto_login_parser.h"
17 #include "android_webview/common/url_constants.h" 16 #include "android_webview/common/url_constants.h"
18 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
19 #include "components/navigation_interception/intercept_navigation_delegate.h" 18 #include "components/navigation_interception/intercept_navigation_delegate.h"
20 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h" 19 #include "components/web_restrictions/browser/web_restrictions_resource_throttle .h"
21 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/resource_dispatcher_host.h" 21 #include "content/public/browser/resource_dispatcher_host.h"
23 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 22 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
24 #include "content/public/browser/resource_request_info.h" 23 #include "content/public/browser/resource_request_info.h"
25 #include "content/public/browser/resource_throttle.h" 24 #include "content/public/browser/resource_throttle.h"
26 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
27 #include "net/base/load_flags.h" 26 #include "net/base/load_flags.h"
28 #include "net/base/net_errors.h" 27 #include "net/base/net_errors.h"
29 #include "net/http/http_response_headers.h" 28 #include "net/http/http_response_headers.h"
30 #include "net/url_request/url_request.h" 29 #include "net/url_request/url_request.h"
31 #include "net/url_request/url_request_status.h" 30 #include "net/url_request/url_request_status.h"
32 #include "url/url_constants.h" 31 #include "url/url_constants.h"
33 32
34 using android_webview::AwContentsIoThreadClient; 33 using android_webview::AwContentsIoThreadClient;
35 using android_webview::AwContentsClientBridgeBase; 34 using android_webview::AwContentsClientBridgeBase;
36 using android_webview::AwWebResourceRequest;
37 using content::BrowserThread; 35 using content::BrowserThread;
38 using content::ResourceType; 36 using content::ResourceType;
39 using content::WebContents; 37 using content::WebContents;
40 using navigation_interception::InterceptNavigationDelegate; 38 using navigation_interception::InterceptNavigationDelegate;
41 39
42 namespace { 40 namespace {
43 41
44 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate> 42 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate>
45 g_webview_resource_dispatcher_host_delegate = LAZY_INSTANCE_INITIALIZER; 43 g_webview_resource_dispatcher_host_delegate = LAZY_INSTANCE_INITIALIZER;
46 44
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const std::string& realm, 77 const std::string& realm,
80 const std::string& account, 78 const std::string& account,
81 const std::string& args) { 79 const std::string& args) {
82 AwContentsClientBridgeBase* client = 80 AwContentsClientBridgeBase* client =
83 AwContentsClientBridgeBase::FromWebContentsGetter(web_contents_getter); 81 AwContentsClientBridgeBase::FromWebContentsGetter(web_contents_getter);
84 if (!client) 82 if (!client)
85 return; 83 return;
86 client->NewLoginRequest(realm, account, args); 84 client->NewLoginRequest(realm, account, args);
87 } 85 }
88 86
89 void OnReceivedErrorOnUiThread(
90 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
91 const AwWebResourceRequest& request,
92 int error_code) {
93 AwContentsClientBridgeBase* client =
94 AwContentsClientBridgeBase::FromWebContentsGetter(web_contents_getter);
95 if (!client) {
96 DLOG(WARNING) << "io_client is null, onReceivedError dropped for "
97 << request.url;
98 return;
99 }
100 client->OnReceivedError(request, error_code);
101 }
102
103 } // namespace 87 } // namespace
104 88
105 namespace android_webview { 89 namespace android_webview {
106 90
107 // Calls through the IoThreadClient to check the embedders settings to determine 91 // Calls through the IoThreadClient to check the embedders settings to determine
108 // if the request should be cancelled. There may not always be an IoThreadClient 92 // if the request should be cancelled. There may not always be an IoThreadClient
109 // available for the |render_process_id|, |render_frame_id| pair (in the case of 93 // available for the |render_process_id|, |render_frame_id| pair (in the case of
110 // newly created pop up windows, for example) and in that case the request and 94 // newly created pop up windows, for example) and in that case the request and
111 // the client callbacks will be deferred the request until a client is ready. 95 // the client callbacks will be deferred the request until a client is ready.
112 class IoThreadClientThrottle : public content::ResourceThrottle { 96 class IoThreadClientThrottle : public content::ResourceThrottle {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 content::ResourceContext* resource_context, 278 content::ResourceContext* resource_context,
295 content::ResourceResponse* response) { 279 content::ResourceResponse* response) {
296 AddExtraHeadersIfNeeded(request, resource_context); 280 AddExtraHeadersIfNeeded(request, resource_context);
297 } 281 }
298 282
299 void AwResourceDispatcherHostDelegate::RequestComplete( 283 void AwResourceDispatcherHostDelegate::RequestComplete(
300 net::URLRequest* request) { 284 net::URLRequest* request) {
301 if (request && !request->status().is_success()) { 285 if (request && !request->status().is_success()) {
302 const content::ResourceRequestInfo* request_info = 286 const content::ResourceRequestInfo* request_info =
303 content::ResourceRequestInfo::ForRequest(request); 287 content::ResourceRequestInfo::ForRequest(request);
304 288 std::unique_ptr<AwContentsIoThreadClient> io_client =
305 BrowserThread::PostTask( 289 AwContentsIoThreadClient::FromID(request_info->GetChildID(),
306 BrowserThread::UI, FROM_HERE, 290 request_info->GetRenderFrameID());
307 base::Bind(&OnReceivedErrorOnUiThread, 291 if (io_client) {
308 request_info->GetWebContentsGetterForRequest(), 292 io_client->OnReceivedError(request);
309 AwWebResourceRequest(*request), request->status().error())); 293 } else {
294 DLOG(WARNING) << "io_client is null, onReceivedError dropped for " <<
295 request->url();
296 }
310 } 297 }
311 } 298 }
312 299
300
313 void AwResourceDispatcherHostDelegate::DownloadStarting( 301 void AwResourceDispatcherHostDelegate::DownloadStarting(
314 net::URLRequest* request, 302 net::URLRequest* request,
315 content::ResourceContext* resource_context, 303 content::ResourceContext* resource_context,
316 bool is_content_initiated, 304 bool is_content_initiated,
317 bool must_download, 305 bool must_download,
318 bool is_new_request, 306 bool is_new_request,
319 ScopedVector<content::ResourceThrottle>* throttles) { 307 ScopedVector<content::ResourceThrottle>* throttles) {
320 GURL url(request->url()); 308 GURL url(request->url());
321 std::string user_agent; 309 std::string user_agent;
322 std::string content_disposition; 310 std::string content_disposition;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 net::HttpRequestHeaders headers; 464 net::HttpRequestHeaders headers;
477 headers.AddHeadersFromString(extra_headers); 465 headers.AddHeadersFromString(extra_headers);
478 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { 466 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) {
479 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); 467 request->SetExtraRequestHeaderByName(it.name(), it.value(), false);
480 } 468 }
481 } 469 }
482 } 470 }
483 } 471 }
484 472
485 } // namespace android_webview 473 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698