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

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

Issue 23842002: Whitelisting exts and plugins from cross-site document blocking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Comments & Coding style are improved. 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
« no previous file with comments | « content/child/resource_dispatcher.h ('k') | content/child/site_isolation_policy.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/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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Writes a footer on the message and sends it 176 // Writes a footer on the message and sends it
177 bool IPCResourceLoaderBridge::Start(Peer* peer) { 177 bool IPCResourceLoaderBridge::Start(Peer* peer) {
178 if (request_id_ != -1) { 178 if (request_id_ != -1) {
179 NOTREACHED() << "Starting a request twice"; 179 NOTREACHED() << "Starting a request twice";
180 return false; 180 return false;
181 } 181 }
182 182
183 peer_ = peer; 183 peer_ = peer;
184 184
185 // generate the request ID, and append it to the message 185 // generate the request ID, and append it to the message
186 request_id_ = dispatcher_->AddPendingRequest( 186 request_id_ = dispatcher_->AddPendingRequest(peer_,
187 peer_, request_.resource_type, frame_origin_, request_.url); 187 request_.resource_type,
188 request_.origin_pid,
189 frame_origin_,
190 request_.url);
188 191
189 return dispatcher_->message_sender()->Send( 192 return dispatcher_->message_sender()->Send(
190 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_)); 193 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_));
191 } 194 }
192 195
193 void IPCResourceLoaderBridge::Cancel() { 196 void IPCResourceLoaderBridge::Cancel() {
194 if (request_id_ < 0) { 197 if (request_id_ < 0) {
195 NOTREACHED() << "Trying to cancel an unstarted request"; 198 NOTREACHED() << "Trying to cancel an unstarted request";
196 return; 199 return;
197 } 200 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 if (new_peer) 351 if (new_peer)
349 request_info->peer = new_peer; 352 request_info->peer = new_peer;
350 } 353 }
351 354
352 ResourceResponseInfo renderer_response_info; 355 ResourceResponseInfo renderer_response_info;
353 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); 356 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info);
354 SiteIsolationPolicy::OnReceivedResponse(request_id, 357 SiteIsolationPolicy::OnReceivedResponse(request_id,
355 request_info->frame_origin, 358 request_info->frame_origin,
356 request_info->response_url, 359 request_info->response_url,
357 request_info->resource_type, 360 request_info->resource_type,
361 request_info->origin_pid,
358 renderer_response_info); 362 renderer_response_info);
359 request_info->peer->OnReceivedResponse(renderer_response_info); 363 request_info->peer->OnReceivedResponse(renderer_response_info);
360 } 364 }
361 365
362 void ResourceDispatcher::OnReceivedCachedMetadata( 366 void ResourceDispatcher::OnReceivedCachedMetadata(
363 int request_id, const std::vector<char>& data) { 367 int request_id, const std::vector<char>& data) {
364 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); 368 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id);
365 if (!request_info) 369 if (!request_info)
366 return; 370 return;
367 371
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 // The request ID will be removed from our pending list in the destructor. 543 // The request ID will be removed from our pending list in the destructor.
540 // Normally, dispatching this message causes the reference-counted request to 544 // Normally, dispatching this message causes the reference-counted request to
541 // die immediately. 545 // die immediately.
542 peer->OnCompletedRequest(error_code, was_ignored_by_handler, security_info, 546 peer->OnCompletedRequest(error_code, was_ignored_by_handler, security_info,
543 renderer_completion_time); 547 renderer_completion_time);
544 } 548 }
545 549
546 int ResourceDispatcher::AddPendingRequest( 550 int ResourceDispatcher::AddPendingRequest(
547 ResourceLoaderBridge::Peer* callback, 551 ResourceLoaderBridge::Peer* callback,
548 ResourceType::Type resource_type, 552 ResourceType::Type resource_type,
553 int origin_pid,
549 const GURL& frame_origin, 554 const GURL& frame_origin,
550 const GURL& request_url) { 555 const GURL& request_url) {
551 // Compute a unique request_id for this renderer process. 556 // Compute a unique request_id for this renderer process.
552 int id = MakeRequestID(); 557 int id = MakeRequestID();
553 pending_requests_[id] = 558 pending_requests_[id] = PendingRequestInfo(
554 PendingRequestInfo(callback, resource_type, frame_origin, request_url); 559 callback, resource_type, origin_pid, frame_origin, request_url);
555 return id; 560 return id;
556 } 561 }
557 562
558 bool ResourceDispatcher::RemovePendingRequest(int request_id) { 563 bool ResourceDispatcher::RemovePendingRequest(int request_id) {
559 PendingRequestList::iterator it = pending_requests_.find(request_id); 564 PendingRequestList::iterator it = pending_requests_.find(request_id);
560 if (it == pending_requests_.end()) 565 if (it == pending_requests_.end())
561 return false; 566 return false;
562 567
563 SiteIsolationPolicy::OnRequestComplete(request_id); 568 SiteIsolationPolicy::OnRequestComplete(request_id);
564 PendingRequestInfo& request_info = it->second; 569 PendingRequestInfo& request_info = it->second;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() 622 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo()
618 : peer(NULL), 623 : peer(NULL),
619 resource_type(ResourceType::SUB_RESOURCE), 624 resource_type(ResourceType::SUB_RESOURCE),
620 is_deferred(false), 625 is_deferred(false),
621 buffer_size(0) { 626 buffer_size(0) {
622 } 627 }
623 628
624 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo( 629 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo(
625 webkit_glue::ResourceLoaderBridge::Peer* peer, 630 webkit_glue::ResourceLoaderBridge::Peer* peer,
626 ResourceType::Type resource_type, 631 ResourceType::Type resource_type,
632 int origin_pid,
627 const GURL& frame_origin, 633 const GURL& frame_origin,
628 const GURL& request_url) 634 const GURL& request_url)
629 : peer(peer), 635 : peer(peer),
630 resource_type(resource_type), 636 resource_type(resource_type),
637 origin_pid(origin_pid),
631 is_deferred(false), 638 is_deferred(false),
632 url(request_url), 639 url(request_url),
633 frame_origin(frame_origin), 640 frame_origin(frame_origin),
634 response_url(request_url), 641 response_url(request_url),
635 request_start(base::TimeTicks::Now()) { 642 request_start(base::TimeTicks::Now()) {
636 } 643 }
637 644
638 ResourceDispatcher::PendingRequestInfo::~PendingRequestInfo() {} 645 ResourceDispatcher::PendingRequestInfo::~PendingRequestInfo() {}
639 646
640 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) { 647 void ResourceDispatcher::DispatchMessage(const IPC::Message& message) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { 800 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) {
794 while (!queue->empty()) { 801 while (!queue->empty()) {
795 IPC::Message* message = queue->front(); 802 IPC::Message* message = queue->front();
796 ReleaseResourcesInDataMessage(*message); 803 ReleaseResourcesInDataMessage(*message);
797 queue->pop_front(); 804 queue->pop_front();
798 delete message; 805 delete message;
799 } 806 }
800 } 807 }
801 808
802 } // namespace content 809 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.h ('k') | content/child/site_isolation_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698