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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 23947003: Create WebContentsObserver callbacks for notifications, remove notifications from SSLManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: formatting Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "content/browser/streams/stream_registry.h" 51 #include "content/browser/streams/stream_registry.h"
52 #include "content/browser/worker_host/worker_service_impl.h" 52 #include "content/browser/worker_host/worker_service_impl.h"
53 #include "content/common/resource_messages.h" 53 #include "content/common/resource_messages.h"
54 #include "content/common/ssl_status_serialization.h" 54 #include "content/common/ssl_status_serialization.h"
55 #include "content/common/view_messages.h" 55 #include "content/common/view_messages.h"
56 #include "content/public/browser/browser_thread.h" 56 #include "content/public/browser/browser_thread.h"
57 #include "content/public/browser/content_browser_client.h" 57 #include "content/public/browser/content_browser_client.h"
58 #include "content/public/browser/download_manager.h" 58 #include "content/public/browser/download_manager.h"
59 #include "content/public/browser/download_url_parameters.h" 59 #include "content/public/browser/download_url_parameters.h"
60 #include "content/public/browser/global_request_id.h" 60 #include "content/public/browser/global_request_id.h"
61 #include "content/public/browser/notification_service.h"
62 #include "content/public/browser/resource_dispatcher_host_delegate.h" 61 #include "content/public/browser/resource_dispatcher_host_delegate.h"
63 #include "content/public/browser/resource_request_details.h" 62 #include "content/public/browser/resource_request_details.h"
64 #include "content/public/browser/resource_throttle.h" 63 #include "content/public/browser/resource_throttle.h"
65 #include "content/public/browser/stream_handle.h" 64 #include "content/public/browser/stream_handle.h"
66 #include "content/public/browser/user_metrics.h" 65 #include "content/public/browser/user_metrics.h"
67 #include "content/public/common/content_switches.h" 66 #include "content/public/common/content_switches.h"
68 #include "content/public/common/process_type.h" 67 #include "content/public/common/process_type.h"
69 #include "content/public/common/url_constants.h" 68 #include "content/public/common/url_constants.h"
70 #include "ipc/ipc_message_macros.h" 69 #include "ipc/ipc_message_macros.h"
71 #include "ipc/ipc_message_start.h" 70 #include "ipc/ipc_message_start.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 258 }
260 259
261 int GetCertID(net::URLRequest* request, int child_id) { 260 int GetCertID(net::URLRequest* request, int child_id) {
262 if (request->ssl_info().cert.get()) { 261 if (request->ssl_info().cert.get()) {
263 return CertStore::GetInstance()->StoreCert(request->ssl_info().cert.get(), 262 return CertStore::GetInstance()->StoreCert(request->ssl_info().cert.get(),
264 child_id); 263 child_id);
265 } 264 }
266 return 0; 265 return 0;
267 } 266 }
268 267
269 template <class T> 268 void NotifyRedirectOnUI(int render_process_id,
270 void NotifyOnUI(int type, int render_process_id, int render_view_id, 269 int render_view_id,
271 scoped_ptr<T> detail) { 270 scoped_ptr<ResourceRedirectDetails> details) {
272 RenderViewHostImpl* host = 271 RenderViewHostImpl* host =
273 RenderViewHostImpl::FromID(render_process_id, render_view_id); 272 RenderViewHostImpl::FromID(render_process_id, render_view_id);
274 if (host) { 273 if (!host)
275 RenderViewHostDelegate* delegate = host->GetDelegate(); 274 return;
276 NotificationService::current()->Notify( 275
277 type, Source<WebContents>(delegate->GetAsWebContents()), 276 RenderViewHostDelegate* delegate = host->GetDelegate();
278 Details<T>(detail.get())); 277 delegate->DidGetRedirectForResourceRequest(*details.get());
279 } 278 }
279
280 void NotifyResponseOnUI(int render_process_id,
281 int render_view_id,
282 scoped_ptr<ResourceRequestDetails> details) {
283 RenderViewHostImpl* host =
284 RenderViewHostImpl::FromID(render_process_id, render_view_id);
285 if (!host)
286 return;
287
288 RenderViewHostDelegate* delegate = host->GetDelegate();
289 delegate->DidGetResourceResponseStart(*details.get());
280 } 290 }
281 291
282 } // namespace 292 } // namespace
283 293
284 // static 294 // static
285 ResourceDispatcherHost* ResourceDispatcherHost::Get() { 295 ResourceDispatcherHost* ResourceDispatcherHost::Get() {
286 return g_resource_dispatcher_host; 296 return g_resource_dispatcher_host;
287 } 297 }
288 298
289 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() 299 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl()
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 return; 684 return;
675 685
676 // Notify the observers on the UI thread. 686 // Notify the observers on the UI thread.
677 scoped_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails( 687 scoped_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails(
678 loader->request(), 688 loader->request(),
679 GetCertID(loader->request(), info->GetChildID()), 689 GetCertID(loader->request(), info->GetChildID()),
680 new_url)); 690 new_url));
681 BrowserThread::PostTask( 691 BrowserThread::PostTask(
682 BrowserThread::UI, FROM_HERE, 692 BrowserThread::UI, FROM_HERE,
683 base::Bind( 693 base::Bind(
684 &NotifyOnUI<ResourceRedirectDetails>, 694 &NotifyRedirectOnUI,
685 static_cast<int>(NOTIFICATION_RESOURCE_RECEIVED_REDIRECT),
686 render_process_id, render_view_id, base::Passed(&detail))); 695 render_process_id, render_view_id, base::Passed(&detail)));
687 } 696 }
688 697
689 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { 698 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
690 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 699 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
691 // There should be an entry in the map created when we dispatched the 700 // There should be an entry in the map created when we dispatched the
692 // request. 701 // request.
693 OfflineMap::iterator policy_it( 702 OfflineMap::iterator policy_it(
694 offline_policy_map_.find(info->GetGlobalRoutingID())); 703 offline_policy_map_.find(info->GetGlobalRoutingID()));
695 if (offline_policy_map_.end() != policy_it) { 704 if (offline_policy_map_.end() != policy_it) {
(...skipping 10 matching lines...) Expand all
706 if (!info->GetAssociatedRenderView(&render_process_id, &render_view_id)) 715 if (!info->GetAssociatedRenderView(&render_process_id, &render_view_id))
707 return; 716 return;
708 717
709 // Notify the observers on the UI thread. 718 // Notify the observers on the UI thread.
710 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( 719 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails(
711 loader->request(), 720 loader->request(),
712 GetCertID(loader->request(), info->GetChildID()))); 721 GetCertID(loader->request(), info->GetChildID())));
713 BrowserThread::PostTask( 722 BrowserThread::PostTask(
714 BrowserThread::UI, FROM_HERE, 723 BrowserThread::UI, FROM_HERE,
715 base::Bind( 724 base::Bind(
716 &NotifyOnUI<ResourceRequestDetails>, 725 &NotifyResponseOnUI,
717 static_cast<int>(NOTIFICATION_RESOURCE_RESPONSE_STARTED),
718 render_process_id, render_view_id, base::Passed(&detail))); 726 render_process_id, render_view_id, base::Passed(&detail)));
719 } 727 }
720 728
721 void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) { 729 void ResourceDispatcherHostImpl::DidFinishLoading(ResourceLoader* loader) {
722 ResourceRequestInfo* info = loader->GetRequestInfo(); 730 ResourceRequestInfo* info = loader->GetRequestInfo();
723 731
724 // Record final result of all resource loads. 732 // Record final result of all resource loads.
725 if (info->GetResourceType() == ResourceType::MAIN_FRAME) { 733 if (info->GetResourceType() == ResourceType::MAIN_FRAME) {
726 // This enumeration has "3" appended to its name to distinguish it from 734 // This enumeration has "3" appended to its name to distinguish it from
727 // older versions. 735 // older versions.
(...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) 1879 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS)
1872 && !policy->CanReadRawCookies(child_id)) { 1880 && !policy->CanReadRawCookies(child_id)) {
1873 VLOG(1) << "Denied unauthorized request for raw headers"; 1881 VLOG(1) << "Denied unauthorized request for raw headers";
1874 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; 1882 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS;
1875 } 1883 }
1876 1884
1877 return load_flags; 1885 return load_flags;
1878 } 1886 }
1879 1887
1880 } // namespace content 1888 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698