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

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

Issue 12321055: Revert 183382 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1418/src/
Patch Set: Created 7 years, 10 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 | « content/common/resource_dispatcher.h ('k') | content/common/resource_messages.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/common/resource_dispatcher.h" 7 #include "content/common/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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/debug/alias.h" 12 #include "base/debug/alias.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/shared_memory.h" 16 #include "base/shared_memory.h"
17 #include "base/string_util.h" 17 #include "base/string_util.h"
18 #include "content/common/inter_process_time_ticks_converter.h" 18 #include "content/common/inter_process_time_ticks_converter.h"
19 #include "content/common/request_extra_data.h" 19 #include "content/common/request_extra_data.h"
20 #include "content/common/resource_messages.h" 20 #include "content/common/resource_messages.h"
21 #include "content/public/common/resource_dispatcher_delegate.h" 21 #include "content/public/common/resource_dispatcher_delegate.h"
22 #include "content/public/common/resource_response.h" 22 #include "content/public/common/resource_response.h"
23 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
24 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
25 #include "net/base/request_priority.h"
26 #include "net/http/http_response_headers.h" 25 #include "net/http/http_response_headers.h"
27 #include "webkit/glue/resource_request_body.h" 26 #include "webkit/glue/resource_request_body.h"
28 #include "webkit/glue/resource_type.h" 27 #include "webkit/glue/resource_type.h"
29 28
30 using webkit_glue::ResourceLoaderBridge; 29 using webkit_glue::ResourceLoaderBridge;
31 using webkit_glue::ResourceRequestBody; 30 using webkit_glue::ResourceRequestBody;
32 using webkit_glue::ResourceResponseInfo; 31 using webkit_glue::ResourceResponseInfo;
33 32
34 namespace content { 33 namespace content {
35 34
(...skipping 20 matching lines...) Expand all
56 public: 55 public:
57 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, 56 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher,
58 const ResourceLoaderBridge::RequestInfo& request_info); 57 const ResourceLoaderBridge::RequestInfo& request_info);
59 virtual ~IPCResourceLoaderBridge(); 58 virtual ~IPCResourceLoaderBridge();
60 59
61 // ResourceLoaderBridge 60 // ResourceLoaderBridge
62 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE; 61 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE;
63 virtual bool Start(Peer* peer) OVERRIDE; 62 virtual bool Start(Peer* peer) OVERRIDE;
64 virtual void Cancel() OVERRIDE; 63 virtual void Cancel() OVERRIDE;
65 virtual void SetDefersLoading(bool value) OVERRIDE; 64 virtual void SetDefersLoading(bool value) OVERRIDE;
66 virtual void DidChangePriority(net::RequestPriority new_priority) OVERRIDE;
67 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE; 65 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE;
68 66
69 private: 67 private:
70 ResourceLoaderBridge::Peer* peer_; 68 ResourceLoaderBridge::Peer* peer_;
71 69
72 // The resource dispatcher for this loader. The bridge doesn't own it, but 70 // The resource dispatcher for this loader. The bridge doesn't own it, but
73 // it's guaranteed to outlive the bridge. 71 // it's guaranteed to outlive the bridge.
74 ResourceDispatcher* dispatcher_; 72 ResourceDispatcher* dispatcher_;
75 73
76 // The request to send, created on initialization for modification and 74 // The request to send, created on initialization for modification and
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 186
189 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { 187 void IPCResourceLoaderBridge::SetDefersLoading(bool value) {
190 if (request_id_ < 0) { 188 if (request_id_ < 0) {
191 NOTREACHED() << "Trying to (un)defer an unstarted request"; 189 NOTREACHED() << "Trying to (un)defer an unstarted request";
192 return; 190 return;
193 } 191 }
194 192
195 dispatcher_->SetDefersLoading(request_id_, value); 193 dispatcher_->SetDefersLoading(request_id_, value);
196 } 194 }
197 195
198 void IPCResourceLoaderBridge::DidChangePriority(
199 net::RequestPriority new_priority) {
200 if (request_id_ < 0) {
201 NOTREACHED() << "Trying to change priority of an unstarted request";
202 return;
203 }
204
205 dispatcher_->DidChangePriority(routing_id_, request_id_, new_priority);
206 }
207
208 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { 196 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) {
209 if (request_id_ != -1) { 197 if (request_id_ != -1) {
210 NOTREACHED() << "Starting a request twice"; 198 NOTREACHED() << "Starting a request twice";
211 response->error_code = net::ERR_FAILED; 199 response->error_code = net::ERR_FAILED;
212 return; 200 return;
213 } 201 }
214 202
215 request_id_ = MakeRequestID(); 203 request_id_ = MakeRequestID();
216 is_synchronous_request_ = true; 204 is_synchronous_request_ = true;
217 205
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 request_info.is_deferred = false; 542 request_info.is_deferred = false;
555 543
556 FollowPendingRedirect(request_id, request_info); 544 FollowPendingRedirect(request_id, request_info);
557 545
558 MessageLoop::current()->PostTask(FROM_HERE, 546 MessageLoop::current()->PostTask(FROM_HERE,
559 base::Bind(&ResourceDispatcher::FlushDeferredMessages, 547 base::Bind(&ResourceDispatcher::FlushDeferredMessages,
560 weak_factory_.GetWeakPtr(), request_id)); 548 weak_factory_.GetWeakPtr(), request_id));
561 } 549 }
562 } 550 }
563 551
564 void ResourceDispatcher::DidChangePriority(
565 int routing_id, int request_id, net::RequestPriority new_priority) {
566 DCHECK(ContainsKey(pending_requests_, request_id));
567 message_sender()->Send(new ResourceHostMsg_DidChangePriority(
568 routing_id, request_id, new_priority));
569 }
570
571 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() 552 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo()
572 : peer(NULL), 553 : peer(NULL),
573 resource_type(ResourceType::SUB_RESOURCE), 554 resource_type(ResourceType::SUB_RESOURCE),
574 is_deferred(false), 555 is_deferred(false),
575 buffer_size(0) { 556 buffer_size(0) {
576 } 557 }
577 558
578 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo( 559 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo(
579 webkit_glue::ResourceLoaderBridge::Peer* peer, 560 webkit_glue::ResourceLoaderBridge::Peer* peer,
580 ResourceType::Type resource_type, 561 ResourceType::Type resource_type,
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { 726 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) {
746 while (!queue->empty()) { 727 while (!queue->empty()) {
747 IPC::Message* message = queue->front(); 728 IPC::Message* message = queue->front();
748 ReleaseResourcesInDataMessage(*message); 729 ReleaseResourcesInDataMessage(*message);
749 queue->pop_front(); 730 queue->pop_front();
750 delete message; 731 delete message;
751 } 732 }
752 } 733 }
753 734
754 } // namespace content 735 } // namespace content
OLDNEW
« no previous file with comments | « content/common/resource_dispatcher.h ('k') | content/common/resource_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698