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

Side by Side Diff: content/child/resource_dispatcher.cc

Issue 1366883002: [Reland] Post loading tasks on the appropriate WebFrameScheduler's queue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 2 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/child/resource_dispatcher.h" 7 #include "content/child/resource_dispatcher.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!request_info->deferred_message_queue.empty()) { 107 if (!request_info->deferred_message_queue.empty()) {
108 FlushDeferredMessages(request_id); 108 FlushDeferredMessages(request_id);
109 request_info = GetPendingRequestInfo(request_id); 109 request_info = GetPendingRequestInfo(request_id);
110 DCHECK(request_info); 110 DCHECK(request_info);
111 if (request_info->is_deferred) { 111 if (request_info->is_deferred) {
112 request_info->deferred_message_queue.push_back(new IPC::Message(message)); 112 request_info->deferred_message_queue.push_back(new IPC::Message(message));
113 return true; 113 return true;
114 } 114 }
115 } 115 }
116 116
117 DispatchMessage(message); 117 // If the request is associated with a specific loading task queue then
118 // dispatch the message there, otherwise dispatch it here.
Sami 2015/09/25 13:31:27 I guess the other alternative would be to dispatch
alex clarke (OOO till 29th) 2015/09/28 17:24:53 Done. Turned out to be much less invasive than I'd
119 if (request_info->loading_task_queue) {
120 request_info->loading_task_queue->PostTask(
121 FROM_HERE, base::Bind(&ResourceDispatcher::DispatchMessage,
122 base::Unretained(this), message));
123 } else {
124 DispatchMessage(message);
125 }
118 return true; 126 return true;
119 } 127 }
120 128
121 ResourceDispatcher::PendingRequestInfo* 129 ResourceDispatcher::PendingRequestInfo*
122 ResourceDispatcher::GetPendingRequestInfo(int request_id) { 130 ResourceDispatcher::GetPendingRequestInfo(int request_id) {
123 PendingRequestList::iterator it = pending_requests_.find(request_id); 131 PendingRequestList::iterator it = pending_requests_.find(request_id);
124 if (it == pending_requests_.end()) { 132 if (it == pending_requests_.end()) {
125 // This might happen for kill()ed requests on the webkit end. 133 // This might happen for kill()ed requests on the webkit end.
126 return NULL; 134 return NULL;
127 } 135 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 download_to_file(false), 481 download_to_file(false),
474 buffer_size(0) { 482 buffer_size(0) {
475 } 483 }
476 484
477 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo( 485 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo(
478 RequestPeer* peer, 486 RequestPeer* peer,
479 ResourceType resource_type, 487 ResourceType resource_type,
480 int origin_pid, 488 int origin_pid,
481 const GURL& frame_origin, 489 const GURL& frame_origin,
482 const GURL& request_url, 490 const GURL& request_url,
483 bool download_to_file) 491 bool download_to_file,
492 scoped_refptr<base::SingleThreadTaskRunner> loading_task_queue)
484 : peer(peer), 493 : peer(peer),
485 threaded_data_provider(NULL), 494 threaded_data_provider(NULL),
486 resource_type(resource_type), 495 resource_type(resource_type),
487 origin_pid(origin_pid), 496 origin_pid(origin_pid),
488 is_deferred(false), 497 is_deferred(false),
489 url(request_url), 498 url(request_url),
490 frame_origin(frame_origin), 499 frame_origin(frame_origin),
491 response_url(request_url), 500 response_url(request_url),
492 download_to_file(download_to_file), 501 download_to_file(download_to_file),
493 request_start(base::TimeTicks::Now()) { 502 request_start(base::TimeTicks::Now()),
503 loading_task_queue(loading_task_queue) {
494 } 504 }
495 505
496 ResourceDispatcher::PendingRequestInfo::~PendingRequestInfo() { 506 ResourceDispatcher::PendingRequestInfo::~PendingRequestInfo() {
497 if (threaded_data_provider) 507 if (threaded_data_provider)
498 threaded_data_provider->Stop(); 508 threaded_data_provider->Stop();
499 } 509 }
500 510
501 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) { 511 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) {
502 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message) 512 IPC_BEGIN_MESSAGE_MAP(ResourceDispatcher, message)
503 IPC_MESSAGE_HANDLER(ResourceMsg_UploadProgress, OnUploadProgress) 513 IPC_MESSAGE_HANDLER(ResourceMsg_UploadProgress, OnUploadProgress)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 CreateRequest(request_info, request_body, &frame_origin); 591 CreateRequest(request_info, request_body, &frame_origin);
582 592
583 // Compute a unique request_id for this renderer process. 593 // Compute a unique request_id for this renderer process.
584 int request_id = MakeRequestID(); 594 int request_id = MakeRequestID();
585 pending_requests_[request_id] = 595 pending_requests_[request_id] =
586 PendingRequestInfo(peer, 596 PendingRequestInfo(peer,
587 request->resource_type, 597 request->resource_type,
588 request->origin_pid, 598 request->origin_pid,
589 frame_origin, 599 frame_origin,
590 request->url, 600 request->url,
591 request_info.download_to_file); 601 request_info.download_to_file,
602 request_info.loading_task_queue);
592 603
593 message_sender_->Send(new ResourceHostMsg_RequestResource( 604 message_sender_->Send(new ResourceHostMsg_RequestResource(
594 request_info.routing_id, request_id, *request)); 605 request_info.routing_id, request_id, *request));
595 606
596 return request_id; 607 return request_id;
597 } 608 }
598 609
599 void ResourceDispatcher::ToResourceResponseInfo( 610 void ResourceDispatcher::ToResourceResponseInfo(
600 const PendingRequestInfo& request_info, 611 const PendingRequestInfo& request_info,
601 const ResourceResponseHead& browser_info, 612 const ResourceResponseHead& browser_info,
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 extra_data->transferred_request_request_id(); 801 extra_data->transferred_request_request_id();
791 request->service_worker_provider_id = 802 request->service_worker_provider_id =
792 extra_data->service_worker_provider_id(); 803 extra_data->service_worker_provider_id();
793 request->request_body = request_body; 804 request->request_body = request_body;
794 if (frame_origin) 805 if (frame_origin)
795 *frame_origin = extra_data->frame_origin(); 806 *frame_origin = extra_data->frame_origin();
796 return request.Pass(); 807 return request.Pass();
797 } 808 }
798 809
799 } // namespace content 810 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698