OLD | NEW |
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 public: | 70 public: |
71 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, | 71 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, |
72 const ResourceLoaderBridge::RequestInfo& request_info); | 72 const ResourceLoaderBridge::RequestInfo& request_info); |
73 virtual ~IPCResourceLoaderBridge(); | 73 virtual ~IPCResourceLoaderBridge(); |
74 | 74 |
75 // ResourceLoaderBridge | 75 // ResourceLoaderBridge |
76 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE; | 76 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE; |
77 virtual bool Start(Peer* peer) OVERRIDE; | 77 virtual bool Start(Peer* peer) OVERRIDE; |
78 virtual void Cancel() OVERRIDE; | 78 virtual void Cancel() OVERRIDE; |
79 virtual void SetDefersLoading(bool value) OVERRIDE; | 79 virtual void SetDefersLoading(bool value) OVERRIDE; |
80 virtual void DidChangePriority(net::RequestPriority new_priority) OVERRIDE; | 80 virtual void DidChangePriority(net::RequestPriority new_priority, |
| 81 int intra_priority_value) OVERRIDE; |
81 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE; | 82 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE; |
82 | 83 |
83 private: | 84 private: |
84 ResourceLoaderBridge::Peer* peer_; | 85 ResourceLoaderBridge::Peer* peer_; |
85 | 86 |
86 // 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 |
87 // it's guaranteed to outlive the bridge. | 88 // it's guaranteed to outlive the bridge. |
88 ResourceDispatcher* dispatcher_; | 89 ResourceDispatcher* dispatcher_; |
89 | 90 |
90 // The request to send, created on initialization for modification and | 91 // The request to send, created on initialization for modification and |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { | 218 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { |
218 if (request_id_ < 0) { | 219 if (request_id_ < 0) { |
219 NOTREACHED() << "Trying to (un)defer an unstarted request"; | 220 NOTREACHED() << "Trying to (un)defer an unstarted request"; |
220 return; | 221 return; |
221 } | 222 } |
222 | 223 |
223 dispatcher_->SetDefersLoading(request_id_, value); | 224 dispatcher_->SetDefersLoading(request_id_, value); |
224 } | 225 } |
225 | 226 |
226 void IPCResourceLoaderBridge::DidChangePriority( | 227 void IPCResourceLoaderBridge::DidChangePriority( |
227 net::RequestPriority new_priority) { | 228 net::RequestPriority new_priority, int intra_priority_value) { |
228 if (request_id_ < 0) { | 229 if (request_id_ < 0) { |
229 NOTREACHED() << "Trying to change priority of an unstarted request"; | 230 NOTREACHED() << "Trying to change priority of an unstarted request"; |
230 return; | 231 return; |
231 } | 232 } |
232 | 233 |
233 dispatcher_->DidChangePriority(routing_id_, request_id_, new_priority); | 234 dispatcher_->DidChangePriority(routing_id_, request_id_, new_priority, |
| 235 intra_priority_value); |
234 } | 236 } |
235 | 237 |
236 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { | 238 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { |
237 if (request_id_ != -1) { | 239 if (request_id_ != -1) { |
238 NOTREACHED() << "Starting a request twice"; | 240 NOTREACHED() << "Starting a request twice"; |
239 response->error_code = net::ERR_FAILED; | 241 response->error_code = net::ERR_FAILED; |
240 return; | 242 return; |
241 } | 243 } |
242 | 244 |
243 request_id_ = MakeRequestID(); | 245 request_id_ = MakeRequestID(); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 | 610 |
609 base::MessageLoop::current()->PostTask( | 611 base::MessageLoop::current()->PostTask( |
610 FROM_HERE, | 612 FROM_HERE, |
611 base::Bind(&ResourceDispatcher::FlushDeferredMessages, | 613 base::Bind(&ResourceDispatcher::FlushDeferredMessages, |
612 weak_factory_.GetWeakPtr(), | 614 weak_factory_.GetWeakPtr(), |
613 request_id)); | 615 request_id)); |
614 } | 616 } |
615 } | 617 } |
616 | 618 |
617 void ResourceDispatcher::DidChangePriority( | 619 void ResourceDispatcher::DidChangePriority( |
618 int routing_id, int request_id, net::RequestPriority new_priority) { | 620 int routing_id, int request_id, net::RequestPriority new_priority, |
| 621 int intra_priority_value) { |
619 DCHECK(ContainsKey(pending_requests_, request_id)); | 622 DCHECK(ContainsKey(pending_requests_, request_id)); |
620 message_sender()->Send(new ResourceHostMsg_DidChangePriority( | 623 message_sender()->Send(new ResourceHostMsg_DidChangePriority( |
621 request_id, new_priority)); | 624 request_id, new_priority, intra_priority_value)); |
622 } | 625 } |
623 | 626 |
624 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() | 627 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() |
625 : peer(NULL), | 628 : peer(NULL), |
626 resource_type(ResourceType::SUB_RESOURCE), | 629 resource_type(ResourceType::SUB_RESOURCE), |
627 is_deferred(false), | 630 is_deferred(false), |
628 buffer_size(0) { | 631 buffer_size(0) { |
629 } | 632 } |
630 | 633 |
631 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo( | 634 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo( |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 805 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
803 while (!queue->empty()) { | 806 while (!queue->empty()) { |
804 IPC::Message* message = queue->front(); | 807 IPC::Message* message = queue->front(); |
805 ReleaseResourcesInDataMessage(*message); | 808 ReleaseResourcesInDataMessage(*message); |
806 queue->pop_front(); | 809 queue->pop_front(); |
807 delete message; | 810 delete message; |
808 } | 811 } |
809 } | 812 } |
810 | 813 |
811 } // namespace content | 814 } // namespace content |
OLD | NEW |