| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 CHROME_COMMON_RESOURCE_DISPATCHER_H__ | 7 #ifndef CHROME_COMMON_RESOURCE_DISPATCHER_H__ |
| 8 #define CHROME_COMMON_RESOURCE_DISPATCHER_H__ | 8 #define CHROME_COMMON_RESOURCE_DISPATCHER_H__ |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // this can be tested regardless of the ResourceLoaderBridge::Create | 35 // this can be tested regardless of the ResourceLoaderBridge::Create |
| 36 // implementation. | 36 // implementation. |
| 37 webkit_glue::ResourceLoaderBridge* CreateBridge( | 37 webkit_glue::ResourceLoaderBridge* CreateBridge( |
| 38 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, | 38 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info, |
| 39 int host_renderer_id, | 39 int host_renderer_id, |
| 40 int host_render_view_id); | 40 int host_render_view_id); |
| 41 | 41 |
| 42 // Adds a request from the pending_requests_ list, returning the new | 42 // Adds a request from the pending_requests_ list, returning the new |
| 43 // requests' ID | 43 // requests' ID |
| 44 int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, | 44 int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, |
| 45 ResourceType::Type resource_type); | 45 ResourceType::Type resource_type, |
| 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 |
| 54 IPC::Message::Sender* message_sender() const { | 55 IPC::Message::Sender* message_sender() const { |
| 55 return message_sender_; | 56 return message_sender_; |
| 56 } | 57 } |
| 57 | 58 |
| 58 // Toggles the is_deferred attribute for the specified request. | 59 // Toggles the is_deferred attribute for the specified request. |
| 59 void SetDefersLoading(int request_id, bool value); | 60 void SetDefersLoading(int request_id, bool value); |
| 60 | 61 |
| 61 private: | 62 private: |
| 62 friend class ResourceDispatcherTest; | 63 friend class ResourceDispatcherTest; |
| 63 | 64 |
| 64 typedef std::deque<IPC::Message*> MessageQueue; | 65 typedef std::deque<IPC::Message*> MessageQueue; |
| 65 struct PendingRequestInfo { | 66 struct PendingRequestInfo { |
| 66 PendingRequestInfo() { } | 67 PendingRequestInfo() { } |
| 67 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, | 68 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, |
| 68 ResourceType::Type resource_type) | 69 ResourceType::Type resource_type, |
| 70 const GURL& request_url) |
| 69 : peer(peer), | 71 : peer(peer), |
| 70 resource_type(resource_type), | 72 resource_type(resource_type), |
| 71 filter_policy(FilterPolicy::DONT_FILTER), | 73 filter_policy(FilterPolicy::DONT_FILTER), |
| 72 is_deferred(false), | 74 is_deferred(false), |
| 73 is_cancelled(false) { | 75 is_cancelled(false), |
| 76 url(request_url) { |
| 74 } | 77 } |
| 75 ~PendingRequestInfo() { } | 78 ~PendingRequestInfo() { } |
| 76 webkit_glue::ResourceLoaderBridge::Peer* peer; | 79 webkit_glue::ResourceLoaderBridge::Peer* peer; |
| 77 ResourceType::Type resource_type; | 80 ResourceType::Type resource_type; |
| 78 FilterPolicy::Type filter_policy; | 81 FilterPolicy::Type filter_policy; |
| 79 MessageQueue deferred_message_queue; | 82 MessageQueue deferred_message_queue; |
| 80 bool is_deferred; | 83 bool is_deferred; |
| 81 bool is_cancelled; | 84 bool is_cancelled; |
| 85 GURL url; |
| 82 }; | 86 }; |
| 83 typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; | 87 typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; |
| 84 | 88 |
| 85 // Message response handlers, called by the message handler for this process. | 89 // Message response handlers, called by the message handler for this process. |
| 86 void OnUploadProgress( | 90 void OnUploadProgress( |
| 87 const IPC::Message& message, | 91 const IPC::Message& message, |
| 88 int request_id, | 92 int request_id, |
| 89 int64 position, | 93 int64 position, |
| 90 int64 size); | 94 int64 size); |
| 91 void OnReceivedResponse(int request_id, const ResourceResponseHead&); | 95 void OnReceivedResponse(int request_id, const ResourceResponseHead&); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 128 |
| 125 // All pending requests issued to the host | 129 // All pending requests issued to the host |
| 126 PendingRequestList pending_requests_; | 130 PendingRequestList pending_requests_; |
| 127 | 131 |
| 128 ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; | 132 ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; |
| 129 | 133 |
| 130 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 134 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
| 131 }; | 135 }; |
| 132 | 136 |
| 133 #endif // CHROME_COMMON_RESOURCE_DISPATCHER_H__ | 137 #endif // CHROME_COMMON_RESOURCE_DISPATCHER_H__ |
| OLD | NEW |