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

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

Issue 2758993002: Move the functions which block, resume and cancel requests for a frame route id out of ResourceDisp… (Closed)
Patch Set: Rebased to tip Created 3 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 // 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 <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 ResourceDispatcherHostDelegate* delegate, 318 ResourceDispatcherHostDelegate* delegate,
319 const net::URLRequest& request, 319 const net::URLRequest& request,
320 ResourceContext* resource_context, 320 ResourceContext* resource_context,
321 bool is_main_frame) { 321 bool is_main_frame) {
322 // previews_state is set to PREVIEWS_OFF when reloading with Lo-Fi disabled. 322 // previews_state is set to PREVIEWS_OFF when reloading with Lo-Fi disabled.
323 if (previews_state == PREVIEWS_UNSPECIFIED && delegate && is_main_frame) 323 if (previews_state == PREVIEWS_UNSPECIFIED && delegate && is_main_frame)
324 return delegate->GetPreviewsState(request, resource_context); 324 return delegate->GetPreviewsState(request, resource_context);
325 return previews_state; 325 return previews_state;
326 } 326 }
327 327
328 // The following functions simplify code paths where the UI thread notifies the
329 // ResourceDispatcherHostImpl of information pertaining to loading behavior of
330 // frame hosts.
331 void NotifyForRouteOnIO(
332 base::Callback<void(ResourceDispatcherHostImpl*,
333 const GlobalFrameRoutingId&)> frame_callback,
334 const GlobalFrameRoutingId& global_routing_id) {
335 DCHECK_CURRENTLY_ON(BrowserThread::IO);
336 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
337 if (rdh)
338 frame_callback.Run(rdh, global_routing_id);
339 }
340
341 void NotifyForRouteFromUI(
342 const GlobalFrameRoutingId& global_routing_id,
343 base::Callback<void(ResourceDispatcherHostImpl*,
344 const GlobalFrameRoutingId&)> frame_callback) {
345 DCHECK_CURRENTLY_ON(BrowserThread::UI);
346 BrowserThread::PostTask(
347 BrowserThread::IO, FROM_HERE,
348 base::Bind(&NotifyForRouteOnIO, frame_callback, global_routing_id));
349 }
350
351 void NotifyForRouteSetOnIO(
352 base::Callback<void(ResourceDispatcherHostImpl*,
353 const GlobalFrameRoutingId&)> frame_callback,
354 std::unique_ptr<std::set<GlobalFrameRoutingId>> routing_ids) {
355 DCHECK_CURRENTLY_ON(BrowserThread::IO);
356 for (const auto& routing_id : *routing_ids)
357 NotifyForRouteOnIO(frame_callback, routing_id);
358 }
359
360 void NotifyForEachFrameFromUI(
361 RenderFrameHost* root_frame_host,
362 base::Callback<void(ResourceDispatcherHostImpl*,
363 const GlobalFrameRoutingId&)> frame_callback) {
364 DCHECK_CURRENTLY_ON(BrowserThread::UI);
365 FrameTree* frame_tree = static_cast<RenderFrameHostImpl*>(root_frame_host)
366 ->frame_tree_node()
367 ->frame_tree();
368 DCHECK_EQ(root_frame_host, frame_tree->GetMainFrame());
369 std::unique_ptr<std::set<GlobalFrameRoutingId>> routing_ids(
370 new std::set<GlobalFrameRoutingId>());
371 for (FrameTreeNode* node : frame_tree->Nodes()) {
372 RenderFrameHostImpl* frame_host = node->current_frame_host();
373 RenderFrameHostImpl* pending_frame_host =
374 IsBrowserSideNavigationEnabled()
375 ? node->render_manager()->speculative_frame_host()
376 : node->render_manager()->pending_frame_host();
377 if (frame_host)
378 routing_ids->insert(frame_host->GetGlobalFrameRoutingId());
379 if (pending_frame_host)
380 routing_ids->insert(pending_frame_host->GetGlobalFrameRoutingId());
381 }
382 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
383 base::Bind(&NotifyForRouteSetOnIO, frame_callback,
384 base::Passed(std::move(routing_ids))));
385 }
386
387 // Sends back the result of a synchronous loading result to the renderer through 328 // Sends back the result of a synchronous loading result to the renderer through
388 // Chrome IPC. 329 // Chrome IPC.
389 void HandleSyncLoadResult(base::WeakPtr<ResourceMessageFilter> filter, 330 void HandleSyncLoadResult(base::WeakPtr<ResourceMessageFilter> filter,
390 std::unique_ptr<IPC::Message> sync_result, 331 std::unique_ptr<IPC::Message> sync_result,
391 const SyncLoadResult* result) { 332 const SyncLoadResult* result) {
392 if (!filter) 333 if (!filter)
393 return; 334 return;
394 335
395 if (result) { 336 if (result) {
396 ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result.get(), *result); 337 ResourceHostMsg_SyncLoad::WriteReplyParams(sync_result.get(), *result);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 DCHECK(g_resource_dispatcher_host); 408 DCHECK(g_resource_dispatcher_host);
468 DCHECK_CURRENTLY_ON(BrowserThread::UI); 409 DCHECK_CURRENTLY_ON(BrowserThread::UI);
469 g_resource_dispatcher_host = NULL; 410 g_resource_dispatcher_host = NULL;
470 } 411 }
471 412
472 // static 413 // static
473 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { 414 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() {
474 return g_resource_dispatcher_host; 415 return g_resource_dispatcher_host;
475 } 416 }
476 417
477 // static
478 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForRouteFromUI(
479 const GlobalFrameRoutingId& global_routing_id) {
480 DCHECK_CURRENTLY_ON(BrowserThread::UI);
481 NotifyForRouteFromUI(
482 global_routing_id,
483 base::Bind(&ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute));
484 }
485
486 // static
487 void ResourceDispatcherHostImpl::BlockRequestsForFrameFromUI(
488 RenderFrameHost* root_frame_host) {
489 DCHECK_CURRENTLY_ON(BrowserThread::UI);
490 NotifyForEachFrameFromUI(
491 root_frame_host,
492 base::Bind(&ResourceDispatcherHostImpl::BlockRequestsForRoute));
493 }
494
495 // static
496 void ResourceDispatcherHostImpl::ResumeBlockedRequestsForFrameFromUI(
497 RenderFrameHost* root_frame_host) {
498 DCHECK_CURRENTLY_ON(BrowserThread::UI);
499 NotifyForEachFrameFromUI(
500 root_frame_host,
501 base::Bind(&ResourceDispatcherHostImpl::ResumeBlockedRequestsForRoute));
502 }
503
504 // static
505 void ResourceDispatcherHostImpl::CancelBlockedRequestsForFrameFromUI(
506 RenderFrameHostImpl* root_frame_host) {
507 DCHECK_CURRENTLY_ON(BrowserThread::UI);
508 NotifyForEachFrameFromUI(
509 root_frame_host,
510 base::Bind(&ResourceDispatcherHostImpl::CancelBlockedRequestsForRoute));
511 }
512
513 void ResourceDispatcherHostImpl::SetDelegate( 418 void ResourceDispatcherHostImpl::SetDelegate(
514 ResourceDispatcherHostDelegate* delegate) { 419 ResourceDispatcherHostDelegate* delegate) {
515 delegate_ = delegate; 420 delegate_ = delegate;
516 } 421 }
517 422
518 void ResourceDispatcherHostImpl::SetAllowCrossOriginAuthPrompt(bool value) { 423 void ResourceDispatcherHostImpl::SetAllowCrossOriginAuthPrompt(bool value) {
519 allow_cross_origin_auth_prompt_ = value; 424 allow_cross_origin_auth_prompt_ = value;
520 } 425 }
521 426
522 void ResourceDispatcherHostImpl::CancelRequestsForContext( 427 void ResourceDispatcherHostImpl::CancelRequestsForContext(
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2792 &throttles); 2697 &throttles);
2793 if (!throttles.empty()) { 2698 if (!throttles.empty()) {
2794 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2699 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2795 std::move(throttles))); 2700 std::move(throttles)));
2796 } 2701 }
2797 } 2702 }
2798 return handler; 2703 return handler;
2799 } 2704 }
2800 2705
2801 } // namespace content 2706 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/security_exploit_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698