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