| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 return next_request_id++; | 29 return next_request_id++; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // ResourceLoaderBridge implementation ---------------------------------------- | 32 // ResourceLoaderBridge implementation ---------------------------------------- |
| 33 | 33 |
| 34 namespace webkit_glue { | 34 namespace webkit_glue { |
| 35 | 35 |
| 36 class IPCResourceLoaderBridge : public ResourceLoaderBridge { | 36 class IPCResourceLoaderBridge : public ResourceLoaderBridge { |
| 37 public: | 37 public: |
| 38 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, | 38 IPCResourceLoaderBridge(ResourceDispatcher* dispatcher, |
| 39 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, | 39 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info); |
| 40 int host_renderer_id, | |
| 41 int host_render_view_id); | |
| 42 virtual ~IPCResourceLoaderBridge(); | 40 virtual ~IPCResourceLoaderBridge(); |
| 43 | 41 |
| 44 // ResourceLoaderBridge | 42 // ResourceLoaderBridge |
| 45 virtual void AppendDataToUpload(const char* data, int data_len); | 43 virtual void AppendDataToUpload(const char* data, int data_len); |
| 46 virtual void AppendFileRangeToUpload( | 44 virtual void AppendFileRangeToUpload( |
| 47 const FilePath& path, | 45 const FilePath& path, |
| 48 uint64 offset, | 46 uint64 offset, |
| 49 uint64 length, | 47 uint64 length, |
| 50 const base::Time& expected_modification_time); | 48 const base::Time& expected_modification_time); |
| 51 virtual void AppendBlobToUpload(const GURL& blob_url); | 49 virtual void AppendBlobToUpload(const GURL& blob_url); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 64 | 62 |
| 65 // The request to send, created on initialization for modification and | 63 // The request to send, created on initialization for modification and |
| 66 // appending data. | 64 // appending data. |
| 67 ResourceHostMsg_Request request_; | 65 ResourceHostMsg_Request request_; |
| 68 | 66 |
| 69 // ID for the request, valid once Start()ed, -1 if not valid yet. | 67 // ID for the request, valid once Start()ed, -1 if not valid yet. |
| 70 int request_id_; | 68 int request_id_; |
| 71 | 69 |
| 72 // The routing id used when sending IPC messages. | 70 // The routing id used when sending IPC messages. |
| 73 int routing_id_; | 71 int routing_id_; |
| 74 | |
| 75 // The following two members are specified if the request is initiated by | |
| 76 // a plugin like Gears. | |
| 77 | |
| 78 // Contains the id of the host renderer. | |
| 79 int host_renderer_id_; | |
| 80 | |
| 81 // Contains the id of the host render view. | |
| 82 int host_render_view_id_; | |
| 83 }; | 72 }; |
| 84 | 73 |
| 85 IPCResourceLoaderBridge::IPCResourceLoaderBridge( | 74 IPCResourceLoaderBridge::IPCResourceLoaderBridge( |
| 86 ResourceDispatcher* dispatcher, | 75 ResourceDispatcher* dispatcher, |
| 87 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, | 76 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) |
| 88 int host_renderer_id, | |
| 89 int host_render_view_id) | |
| 90 : peer_(NULL), | 77 : peer_(NULL), |
| 91 dispatcher_(dispatcher), | 78 dispatcher_(dispatcher), |
| 92 request_id_(-1), | 79 request_id_(-1), |
| 93 routing_id_(request_info.routing_id), | 80 routing_id_(request_info.routing_id) { |
| 94 host_renderer_id_(host_renderer_id), | |
| 95 host_render_view_id_(host_render_view_id) { | |
| 96 DCHECK(dispatcher_) << "no resource dispatcher"; | 81 DCHECK(dispatcher_) << "no resource dispatcher"; |
| 97 request_.method = request_info.method; | 82 request_.method = request_info.method; |
| 98 request_.url = request_info.url; | 83 request_.url = request_info.url; |
| 99 request_.first_party_for_cookies = request_info.first_party_for_cookies; | 84 request_.first_party_for_cookies = request_info.first_party_for_cookies; |
| 100 request_.referrer = request_info.referrer; | 85 request_.referrer = request_info.referrer; |
| 101 request_.headers = request_info.headers; | 86 request_.headers = request_info.headers; |
| 102 request_.load_flags = request_info.load_flags; | 87 request_.load_flags = request_info.load_flags; |
| 103 request_.origin_pid = request_info.requestor_pid; | 88 request_.origin_pid = request_info.requestor_pid; |
| 104 request_.resource_type = request_info.request_type; | 89 request_.resource_type = request_info.request_type; |
| 105 request_.request_context = request_info.request_context; | 90 request_.request_context = request_info.request_context; |
| 106 request_.appcache_host_id = request_info.appcache_host_id; | 91 request_.appcache_host_id = request_info.appcache_host_id; |
| 107 request_.download_to_file = request_info.download_to_file; | 92 request_.download_to_file = request_info.download_to_file; |
| 108 request_.has_user_gesture = request_info.has_user_gesture; | 93 request_.has_user_gesture = request_info.has_user_gesture; |
| 109 request_.host_renderer_id = host_renderer_id_; | |
| 110 request_.host_render_view_id = host_render_view_id_; | |
| 111 } | 94 } |
| 112 | 95 |
| 113 IPCResourceLoaderBridge::~IPCResourceLoaderBridge() { | 96 IPCResourceLoaderBridge::~IPCResourceLoaderBridge() { |
| 114 // we remove our hook for the resource dispatcher only when going away, since | 97 // we remove our hook for the resource dispatcher only when going away, since |
| 115 // it doesn't keep track of whether we've force terminated the request | 98 // it doesn't keep track of whether we've force terminated the request |
| 116 if (request_id_ >= 0) { | 99 if (request_id_ >= 0) { |
| 117 // this operation may fail, as the dispatcher will have preemptively | 100 // this operation may fail, as the dispatcher will have preemptively |
| 118 // removed us when the renderer sends the ReceivedAllData message. | 101 // removed us when the renderer sends the ReceivedAllData message. |
| 119 dispatcher_->RemovePendingRequest(request_id_); | 102 dispatcher_->RemovePendingRequest(request_id_); |
| 120 | 103 |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 PendingRequestInfo& pending_request = index->second; | 530 PendingRequestInfo& pending_request = index->second; |
| 548 if (pending_request.is_deferred) { | 531 if (pending_request.is_deferred) { |
| 549 pending_request.deferred_message_queue.swap(q); | 532 pending_request.deferred_message_queue.swap(q); |
| 550 return; | 533 return; |
| 551 } | 534 } |
| 552 } | 535 } |
| 553 } | 536 } |
| 554 } | 537 } |
| 555 | 538 |
| 556 webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( | 539 webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( |
| 557 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, | 540 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { |
| 558 int host_renderer_id, | 541 return new webkit_glue::IPCResourceLoaderBridge(this, request_info); |
| 559 int host_render_view_id) { | |
| 560 return new webkit_glue::IPCResourceLoaderBridge(this, request_info, | |
| 561 host_renderer_id, | |
| 562 host_render_view_id); | |
| 563 } | 542 } |
| 564 | 543 |
| 565 bool ResourceDispatcher::IsResourceDispatcherMessage( | 544 bool ResourceDispatcher::IsResourceDispatcherMessage( |
| 566 const IPC::Message& message) { | 545 const IPC::Message& message) { |
| 567 switch (message.type()) { | 546 switch (message.type()) { |
| 568 case ResourceMsg_UploadProgress::ID: | 547 case ResourceMsg_UploadProgress::ID: |
| 569 case ResourceMsg_ReceivedResponse::ID: | 548 case ResourceMsg_ReceivedResponse::ID: |
| 570 case ResourceMsg_ReceivedCachedMetadata::ID: | 549 case ResourceMsg_ReceivedCachedMetadata::ID: |
| 571 case ResourceMsg_ReceivedRedirect::ID: | 550 case ResourceMsg_ReceivedRedirect::ID: |
| 572 case ResourceMsg_DataReceived::ID: | 551 case ResourceMsg_DataReceived::ID: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 584 |
| 606 // static | 585 // static |
| 607 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 586 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 608 while (!queue->empty()) { | 587 while (!queue->empty()) { |
| 609 IPC::Message* message = queue->front(); | 588 IPC::Message* message = queue->front(); |
| 610 ReleaseResourcesInDataMessage(*message); | 589 ReleaseResourcesInDataMessage(*message); |
| 611 queue->pop_front(); | 590 queue->pop_front(); |
| 612 delete message; | 591 delete message; |
| 613 } | 592 } |
| 614 } | 593 } |
| OLD | NEW |