| 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/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" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 public: | 55 public: |
| 56 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, | 56 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, |
| 57 const ResourceLoaderBridge::RequestInfo& request_info); | 57 const ResourceLoaderBridge::RequestInfo& request_info); |
| 58 virtual ~IPCResourceLoaderBridge(); | 58 virtual ~IPCResourceLoaderBridge(); |
| 59 | 59 |
| 60 // ResourceLoaderBridge | 60 // ResourceLoaderBridge |
| 61 virtual void SetRequestBody(ResourceRequestBody* request_body); | 61 virtual void SetRequestBody(ResourceRequestBody* request_body); |
| 62 virtual bool Start(Peer* peer); | 62 virtual bool Start(Peer* peer); |
| 63 virtual void Cancel(); | 63 virtual void Cancel(); |
| 64 virtual void SetDefersLoading(bool value); | 64 virtual void SetDefersLoading(bool value); |
| 65 virtual void DidChangePriority(WebKit::WebURLRequest::Priority new_priority); |
| 65 virtual void SyncLoad(SyncLoadResponse* response); | 66 virtual void SyncLoad(SyncLoadResponse* response); |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 ResourceLoaderBridge::Peer* peer_; | 69 ResourceLoaderBridge::Peer* peer_; |
| 69 | 70 |
| 70 // The resource dispatcher for this loader. The bridge doesn't own it, but | 71 // The resource dispatcher for this loader. The bridge doesn't own it, but |
| 71 // it's guaranteed to outlive the bridge. | 72 // it's guaranteed to outlive the bridge. |
| 72 ResourceDispatcher* dispatcher_; | 73 ResourceDispatcher* dispatcher_; |
| 73 | 74 |
| 74 // The request to send, created on initialization for modification and | 75 // The request to send, created on initialization for modification and |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 187 |
| 187 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { | 188 void IPCResourceLoaderBridge::SetDefersLoading(bool value) { |
| 188 if (request_id_ < 0) { | 189 if (request_id_ < 0) { |
| 189 NOTREACHED() << "Trying to (un)defer an unstarted request"; | 190 NOTREACHED() << "Trying to (un)defer an unstarted request"; |
| 190 return; | 191 return; |
| 191 } | 192 } |
| 192 | 193 |
| 193 dispatcher_->SetDefersLoading(request_id_, value); | 194 dispatcher_->SetDefersLoading(request_id_, value); |
| 194 } | 195 } |
| 195 | 196 |
| 197 void IPCResourceLoaderBridge::DidChangePriority( |
| 198 WebKit::WebURLRequest::Priority new_priority) { |
| 199 if (request_id_ < 0) { |
| 200 NOTREACHED() << "Trying to change priority of an unstarted request"; |
| 201 return; |
| 202 } |
| 203 |
| 204 dispatcher_->DidChangePriority(routing_id_, request_id_, new_priority); |
| 205 } |
| 206 |
| 196 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { | 207 void IPCResourceLoaderBridge::SyncLoad(SyncLoadResponse* response) { |
| 197 if (request_id_ != -1) { | 208 if (request_id_ != -1) { |
| 198 NOTREACHED() << "Starting a request twice"; | 209 NOTREACHED() << "Starting a request twice"; |
| 199 response->error_code = net::ERR_FAILED; | 210 response->error_code = net::ERR_FAILED; |
| 200 return; | 211 return; |
| 201 } | 212 } |
| 202 | 213 |
| 203 request_id_ = MakeRequestID(); | 214 request_id_ = MakeRequestID(); |
| 204 is_synchronous_request_ = true; | 215 is_synchronous_request_ = true; |
| 205 | 216 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 request_info.is_deferred = false; | 553 request_info.is_deferred = false; |
| 543 | 554 |
| 544 FollowPendingRedirect(request_id, request_info); | 555 FollowPendingRedirect(request_id, request_info); |
| 545 | 556 |
| 546 MessageLoop::current()->PostTask(FROM_HERE, | 557 MessageLoop::current()->PostTask(FROM_HERE, |
| 547 base::Bind(&ResourceDispatcher::FlushDeferredMessages, | 558 base::Bind(&ResourceDispatcher::FlushDeferredMessages, |
| 548 weak_factory_.GetWeakPtr(), request_id)); | 559 weak_factory_.GetWeakPtr(), request_id)); |
| 549 } | 560 } |
| 550 } | 561 } |
| 551 | 562 |
| 563 void ResourceDispatcher::DidChangePriority( |
| 564 int routing_id, int request_id, |
| 565 WebKit::WebURLRequest::Priority 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 |
| 552 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() | 571 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo() |
| 553 : peer(NULL), | 572 : peer(NULL), |
| 554 resource_type(ResourceType::SUB_RESOURCE), | 573 resource_type(ResourceType::SUB_RESOURCE), |
| 555 is_deferred(false), | 574 is_deferred(false), |
| 556 buffer_size(0) { | 575 buffer_size(0) { |
| 557 } | 576 } |
| 558 | 577 |
| 559 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo( | 578 ResourceDispatcher::PendingRequestInfo::PendingRequestInfo( |
| 560 webkit_glue::ResourceLoaderBridge::Peer* peer, | 579 webkit_glue::ResourceLoaderBridge::Peer* peer, |
| 561 ResourceType::Type resource_type, | 580 ResourceType::Type resource_type, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 745 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 727 while (!queue->empty()) { | 746 while (!queue->empty()) { |
| 728 IPC::Message* message = queue->front(); | 747 IPC::Message* message = queue->front(); |
| 729 ReleaseResourcesInDataMessage(*message); | 748 ReleaseResourcesInDataMessage(*message); |
| 730 queue->pop_front(); | 749 queue->pop_front(); |
| 731 delete message; | 750 delete message; |
| 732 } | 751 } |
| 733 } | 752 } |
| 734 | 753 |
| 735 } // namespace content | 754 } // namespace content |
| OLD | NEW |