| 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 #ifndef CONTENT_COMMON_RESOURCE_DISPATCHER_H_ | 7 #ifndef CONTENT_COMMON_RESOURCE_DISPATCHER_H_ |
| 8 #define CONTENT_COMMON_RESOURCE_DISPATCHER_H_ | 8 #define CONTENT_COMMON_RESOURCE_DISPATCHER_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 virtual bool OnMessageReceived(const IPC::Message& message); | 33 virtual bool OnMessageReceived(const IPC::Message& message); |
| 34 | 34 |
| 35 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so | 35 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so |
| 36 // this can be tested regardless of the ResourceLoaderBridge::Create | 36 // this can be tested regardless of the ResourceLoaderBridge::Create |
| 37 // implementation. | 37 // implementation. |
| 38 webkit_glue::ResourceLoaderBridge* CreateBridge( | 38 webkit_glue::ResourceLoaderBridge* CreateBridge( |
| 39 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info); | 39 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info); |
| 40 | 40 |
| 41 // Adds a request from the pending_requests_ list, returning the new | 41 // Adds a request from the pending_requests_ list, returning the new |
| 42 // requests' ID | 42 // requests' ID |
| 43 int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, | 43 int AddPendingRequest(int webkit_request_id, |
| 44 webkit_glue::ResourceLoaderBridge::Peer* callback, |
| 44 ResourceType::Type resource_type, | 45 ResourceType::Type resource_type, |
| 45 const GURL& request_url); | 46 const GURL& request_url); |
| 46 | 47 |
| 47 // Removes a request from the pending_requests_ list, returning true if the | 48 // Removes a request from the pending_requests_ list, returning true if the |
| 48 // request was found and removed. | 49 // request was found and removed. |
| 49 bool RemovePendingRequest(int request_id); | 50 bool RemovePendingRequest(int request_id); |
| 50 | 51 |
| 51 // Cancels a request in the pending_requests_ list. | 52 // Cancels a request in the pending_requests_ list. |
| 52 void CancelPendingRequest(int routing_id, int request_id); | 53 void CancelPendingRequest(int routing_id, int request_id); |
| 53 | 54 |
| 55 // Updates the request that was transferred to a new page. |
| 56 void TransferRequestToNewPage(int webkit_identifier, int new_routing_id); |
| 57 |
| 54 IPC::Message::Sender* message_sender() const { | 58 IPC::Message::Sender* message_sender() const { |
| 55 return message_sender_; | 59 return message_sender_; |
| 56 } | 60 } |
| 57 | 61 |
| 58 // Toggles the is_deferred attribute for the specified request. | 62 // Toggles the is_deferred attribute for the specified request. |
| 59 void SetDefersLoading(int request_id, bool value); | 63 void SetDefersLoading(int request_id, bool value); |
| 60 | 64 |
| 61 // This does not take ownership of the delegate. It is expected that the | 65 // This does not take ownership of the delegate. It is expected that the |
| 62 // delegate have a longer lifetime than the ResourceDispatcher. | 66 // delegate have a longer lifetime than the ResourceDispatcher. |
| 63 void set_delegate(ResourceDispatcherDelegate* delegate) { | 67 void set_delegate(ResourceDispatcherDelegate* delegate) { |
| 64 delegate_ = delegate; | 68 delegate_ = delegate; |
| 65 } | 69 } |
| 66 | 70 |
| 67 private: | 71 private: |
| 68 friend class ResourceDispatcherTest; | 72 friend class ResourceDispatcherTest; |
| 69 | 73 |
| 70 typedef std::deque<IPC::Message*> MessageQueue; | 74 typedef std::deque<IPC::Message*> MessageQueue; |
| 71 struct PendingRequestInfo { | 75 struct PendingRequestInfo { |
| 72 PendingRequestInfo() { } | 76 PendingRequestInfo() { } |
| 73 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, | 77 PendingRequestInfo(int webkit_request_id, |
| 78 webkit_glue::ResourceLoaderBridge::Peer* peer, |
| 74 ResourceType::Type resource_type, | 79 ResourceType::Type resource_type, |
| 75 const GURL& request_url) | 80 const GURL& request_url) |
| 76 : peer(peer), | 81 : webkit_request_id(webkit_request_id), |
| 82 peer(peer), |
| 77 resource_type(resource_type), | 83 resource_type(resource_type), |
| 78 is_deferred(false), | 84 is_deferred(false), |
| 79 url(request_url) { | 85 url(request_url) { |
| 80 } | 86 } |
| 81 ~PendingRequestInfo() { } | 87 ~PendingRequestInfo() { } |
| 88 int webkit_request_id; |
| 82 webkit_glue::ResourceLoaderBridge::Peer* peer; | 89 webkit_glue::ResourceLoaderBridge::Peer* peer; |
| 83 ResourceType::Type resource_type; | 90 ResourceType::Type resource_type; |
| 84 MessageQueue deferred_message_queue; | 91 MessageQueue deferred_message_queue; |
| 85 bool is_deferred; | 92 bool is_deferred; |
| 86 GURL url; | 93 GURL url; |
| 87 linked_ptr<IPC::Message> pending_redirect_message; | 94 linked_ptr<IPC::Message> pending_redirect_message; |
| 88 }; | 95 }; |
| 89 typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; | 96 typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; |
| 90 | 97 |
| 91 // Helper to lookup the info based on the request_id. | 98 // Helper to lookup the info based on the request_id. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 PendingRequestList pending_requests_; | 158 PendingRequestList pending_requests_; |
| 152 | 159 |
| 153 ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; | 160 ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; |
| 154 | 161 |
| 155 ResourceDispatcherDelegate* delegate_; | 162 ResourceDispatcherDelegate* delegate_; |
| 156 | 163 |
| 157 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 164 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
| 158 }; | 165 }; |
| 159 | 166 |
| 160 #endif // CONTENT_COMMON_RESOURCE_DISPATCHER_H_ | 167 #endif // CONTENT_COMMON_RESOURCE_DISPATCHER_H_ |
| OLD | NEW |