| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 public: | 73 public: |
| 74 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, | 74 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, |
| 75 const RequestInfo& request_info); | 75 const RequestInfo& request_info); |
| 76 virtual ~IPCResourceLoaderBridge(); | 76 virtual ~IPCResourceLoaderBridge(); |
| 77 | 77 |
| 78 // ResourceLoaderBridge | 78 // ResourceLoaderBridge |
| 79 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE; | 79 virtual void SetRequestBody(ResourceRequestBody* request_body) OVERRIDE; |
| 80 virtual bool Start(RequestPeer* peer) OVERRIDE; | 80 virtual bool Start(RequestPeer* peer) OVERRIDE; |
| 81 virtual void Cancel() OVERRIDE; | 81 virtual void Cancel() OVERRIDE; |
| 82 virtual void SetDefersLoading(bool value) OVERRIDE; | 82 virtual void SetDefersLoading(bool value) OVERRIDE; |
| 83 virtual void DidChangePriority(net::RequestPriority new_priority) OVERRIDE; | 83 virtual void DidChangePriority(net::RequestPriority new_priority, |
| 84 int intra_priority_value) OVERRIDE; |
| 84 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE; | 85 virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE; |
| 85 | 86 |
| 86 private: | 87 private: |
| 87 RequestPeer* peer_; | 88 RequestPeer* peer_; |
| 88 | 89 |
| 89 // The resource dispatcher for this loader. The bridge doesn't own it, but | 90 // The resource dispatcher for this loader. The bridge doesn't own it, but |
| 90 // it's guaranteed to outlive the bridge. | 91 // it's guaranteed to outlive the bridge. |
| 91 ResourceDispatcher* dispatcher_; | 92 ResourceDispatcher* dispatcher_; |
| 92 | 93 |
| 93 // The request to send, created on initialization for modification and | 94 // The request to send, created on initialization for modification and |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { | 213 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { |
| 213 if (request_id_ < 0) { | 214 if (request_id_ < 0) { |
| 214 NOTREACHED() << "Trying to (un)defer an unstarted request"; | 215 NOTREACHED() << "Trying to (un)defer an unstarted request"; |
| 215 return; | 216 return; |
| 216 } | 217 } |
| 217 | 218 |
| 218 dispatcher_->SetDefersLoading(request_id_, value); | 219 dispatcher_->SetDefersLoading(request_id_, value); |
| 219 } | 220 } |
| 220 | 221 |
| 221 void IPCResourceLoaderBridge::DidChangePriority( | 222 void IPCResourceLoaderBridge::DidChangePriority( |
| 222 net::RequestPriority new_priority) { | 223 net::RequestPriority new_priority, int intra_priority_value) { |
| 223 if (request_id_ < 0) { | 224 if (request_id_ < 0) { |
| 224 NOTREACHED() << "Trying to change priority of an unstarted request"; | 225 NOTREACHED() << "Trying to change priority of an unstarted request"; |
| 225 return; | 226 return; |
| 226 } | 227 } |
| 227 | 228 |
| 228 dispatcher_->DidChangePriority(routing_id_, request_id_, new_priority); | 229 dispatcher_->DidChangePriority(routing_id_, request_id_, new_priority, |
| 230 intra_priority_value); |
| 229 } | 231 } |
| 230 | 232 |
| 231 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { | 233 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { |
| 232 if (request_id_ != -1) { | 234 if (request_id_ != -1) { |
| 233 NOTREACHED() << "Starting a request twice"; | 235 NOTREACHED() << "Starting a request twice"; |
| 234 response->error_code = net::ERR_FAILED; | 236 response->error_code = net::ERR_FAILED; |
| 235 return; | 237 return; |
| 236 } | 238 } |
| 237 | 239 |
| 238 request_id_ = MakeRequestID(); | 240 request_id_ = MakeRequestID(); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 | 609 |
| 608 base::MessageLoop::current()->PostTask( | 610 base::MessageLoop::current()->PostTask( |
| 609 FROM_HERE, | 611 FROM_HERE, |
| 610 base::Bind(&ResourceDispatcher::FlushDeferredMessages, | 612 base::Bind(&ResourceDispatcher::FlushDeferredMessages, |
| 611 weak_factory_.GetWeakPtr(), | 613 weak_factory_.GetWeakPtr(), |
| 612 request_id)); | 614 request_id)); |
| 613 } | 615 } |
| 614 } | 616 } |
| 615 | 617 |
| 616 void ResourceDispatcher::DidChangePriority( | 618 void ResourceDispatcher::DidChangePriority( |
| 617 int routing_id, int request_id, net::RequestPriority new_priority) { | 619 int routing_id, int request_id, net::RequestPriority new_priority, |
| 620 int intra_priority_value) { |
| 618 DCHECK(ContainsKey(pending_requests_, request_id)); | 621 DCHECK(ContainsKey(pending_requests_, request_id)); |
| 619 message_sender()->Send(new ResourceHostMsg_DidChangePriority( | 622 message_sender()->Send(new ResourceHostMsg_DidChangePriority( |
| 620 request_id, new_priority)); | 623 request_id, new_priority, intra_priority_value)); |
| 621 } | 624 } |
| 622 | 625 |
| 623 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() | 626 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() |
| 624 : peer(NULL), | 627 : peer(NULL), |
| 625 resource_type(ResourceType::SUB_RESOURCE), | 628 resource_type(ResourceType::SUB_RESOURCE), |
| 626 is_deferred(false), | 629 is_deferred(false), |
| 627 blocked_response(false), | 630 blocked_response(false), |
| 628 buffer_size(0) { | 631 buffer_size(0) { |
| 629 } | 632 } |
| 630 | 633 |
| (...skipping 171 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 |