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

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

Issue 294043012: No need to have RequestPeer as a data member variable of IPCResourceLoaderBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | no next file » | 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // ResourceLoaderBridge 77 // ResourceLoaderBridge
78 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE; 78 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE;
79 virtual bool Start(RequestPeer* peer) OVERRIDE; 79 virtual bool Start(RequestPeer* peer) OVERRIDE;
80 virtual void Cancel() OVERRIDE; 80 virtual void Cancel() OVERRIDE;
81 virtual void SetDefersLoading(bool value) OVERRIDE; 81 virtual void SetDefersLoading(bool value) OVERRIDE;
82 virtual void DidChangePriority(net::RequestPriority new_priority, 82 virtual void DidChangePriority(net::RequestPriority new_priority,
83 int intra_priority_value) OVERRIDE; 83 int intra_priority_value) OVERRIDE;
84 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE; 84 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE;
85 85
86 private: 86 private:
87 RequestPeer* peer_;
88
89 // The resource dispatcher for this loader. The bridge doesn't own it, but 87 // The resource dispatcher for this loader. The bridge doesn't own it, but
90 // it's guaranteed to outlive the bridge. 88 // it's guaranteed to outlive the bridge.
91 ResourceDispatcher* dispatcher_; 89 ResourceDispatcher* dispatcher_;
92 90
93 // The request to send, created on initialization for modification and 91 // The request to send, created on initialization for modification and
94 // appending data. 92 // appending data.
95 ResourceHostMsg_Request request_; 93 ResourceHostMsg_Request request_;
96 94
97 // ID for the request, valid once Start()ed, -1 if not valid yet. 95 // ID for the request, valid once Start()ed, -1 if not valid yet.
98 int request_id_; 96 int request_id_;
99 97
100 // The routing id used when sending IPC messages. 98 // The routing id used when sending IPC messages.
101 int routing_id_; 99 int routing_id_;
102 100
103 // The security origin of the frame that initiates this request. 101 // The security origin of the frame that initiates this request.
104 GURL frame_origin_; 102 GURL frame_origin_;
105 103
106 bool is_synchronous_request_; 104 bool is_synchronous_request_;
107 }; 105 };
108 106
109 IPCResourceLoaderBridge::IPCResourceLoaderBridge( 107 IPCResourceLoaderBridge::IPCResourceLoaderBridge(
110 ResourceDispatcher* dispatcher, 108 ResourceDispatcher* dispatcher,
111 const RequestInfo& request_info) 109 const RequestInfo& request_info)
112 : peer_(NULL), 110 : dispatcher_(dispatcher),
113 dispatcher_(dispatcher),
114 request_id_(-1), 111 request_id_(-1),
115 routing_id_(request_info.routing_id), 112 routing_id_(request_info.routing_id),
116 is_synchronous_request_(false) { 113 is_synchronous_request_(false) {
117 DCHECK(dispatcher_) << "no resource dispatcher"; 114 DCHECK(dispatcher_) << "no resource dispatcher";
118 request_.method = request_info.method; 115 request_.method = request_info.method;
119 request_.url = request_info.url; 116 request_.url = request_info.url;
120 request_.first_party_for_cookies = request_info.first_party_for_cookies; 117 request_.first_party_for_cookies = request_info.first_party_for_cookies;
121 request_.referrer = request_info.referrer; 118 request_.referrer = request_info.referrer;
122 request_.referrer_policy = request_info.referrer_policy; 119 request_.referrer_policy = request_info.referrer_policy;
123 request_.headers = request_info.headers; 120 request_.headers = request_info.headers;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 request_.request_body = request_body; 167 request_.request_body = request_body;
171 } 168 }
172 169
173 // Writes a footer on the message and sends it 170 // Writes a footer on the message and sends it
174 bool IPCResourceLoaderBridge::Start(RequestPeer* peer) { 171 bool IPCResourceLoaderBridge::Start(RequestPeer* peer) {
175 if (request_id_ != -1) { 172 if (request_id_ != -1) {
176 NOTREACHED() << "Starting a request twice"; 173 NOTREACHED() << "Starting a request twice";
177 return false; 174 return false;
178 } 175 }
179 176
180 peer_ = peer;
181
182 // generate the request ID, and append it to the message 177 // generate the request ID, and append it to the message
183 request_id_ = dispatcher_->AddPendingRequest(peer_, 178 request_id_ = dispatcher_->AddPendingRequest(peer,
184 request_.resource_type, 179 request_.resource_type,
185 request_.origin_pid, 180 request_.origin_pid,
186 frame_origin_, 181 frame_origin_,
187 request_.url, 182 request_.url,
188 request_.download_to_file); 183 request_.download_to_file);
189 184
190 return dispatcher_->message_sender()->Send( 185 return dispatcher_->message_sender()->Send(
191 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_)); 186 new ResourceHostMsg_RequestResource(routing_id_, request_id_, request_));
192 } 187 }
193 188
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { 808 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) {
814 while (!queue->empty()) { 809 while (!queue->empty()) {
815 IPC::Message* message = queue->front(); 810 IPC::Message* message = queue->front();
816 ReleaseResourcesInDataMessage(*message); 811 ReleaseResourcesInDataMessage(*message);
817 queue->pop_front(); 812 queue->pop_front();
818 delete message; 813 delete message;
819 } 814 }
820 } 815 }
821 816
822 } // namespace content 817 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698