| 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 21 matching lines...) Expand all Loading... |
| 32 // handled, else false. | 32 // handled, else false. |
| 33 bool OnMessageReceived(const IPC::Message& message); | 33 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(const std::string& method, | 38 webkit_glue::ResourceLoaderBridge* CreateBridge(const std::string& method, |
| 39 const GURL& url, | 39 const GURL& url, |
| 40 const GURL& policy_url, | 40 const GURL& policy_url, |
| 41 const GURL& referrer, | 41 const GURL& referrer, |
| 42 const std::string& frame_origin, |
| 43 const std::string& main_frame_origin, |
| 42 const std::string& headers, | 44 const std::string& headers, |
| 43 int load_flags, | 45 int load_flags, |
| 44 int origin_pid, | 46 int origin_pid, |
| 45 ResourceType::Type resource_type, | 47 ResourceType::Type resource_type, |
| 46 bool mixed_content, | |
| 47 uint32 request_context /* used for plugin->browser requests */, | 48 uint32 request_context /* used for plugin->browser requests */, |
| 48 int route_id); | 49 int route_id); |
| 49 | 50 |
| 50 // Adds a request from the pending_requests_ list, returning the new | 51 // Adds a request from the pending_requests_ list, returning the new |
| 51 // requests' ID | 52 // requests' ID |
| 52 int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, | 53 int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, |
| 53 ResourceType::Type resource_type, | 54 ResourceType::Type resource_type); |
| 54 bool mixed_content); | |
| 55 | 55 |
| 56 // Removes a request from the pending_requests_ list, returning true if the | 56 // Removes a request from the pending_requests_ list, returning true if the |
| 57 // request was found and removed. | 57 // request was found and removed. |
| 58 bool RemovePendingRequest(int request_id); | 58 bool RemovePendingRequest(int request_id); |
| 59 | 59 |
| 60 IPC::Message::Sender* message_sender() const { | 60 IPC::Message::Sender* message_sender() const { |
| 61 return message_sender_; | 61 return message_sender_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Toggles the is_deferred attribute for the specified request. | 64 // Toggles the is_deferred attribute for the specified request. |
| 65 void SetDefersLoading(int request_id, bool value); | 65 void SetDefersLoading(int request_id, bool value); |
| 66 | 66 |
| 67 // Returns true if the message passed in is a resource related | 67 // Returns true if the message passed in is a resource related |
| 68 // message. | 68 // message. |
| 69 bool IsResourceMessage(const IPC::Message& message) const; | 69 bool IsResourceMessage(const IPC::Message& message) const; |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 friend class ResourceDispatcherTest; | 72 friend class ResourceDispatcherTest; |
| 73 | 73 |
| 74 typedef std::deque<IPC::Message*> MessageQueue; | 74 typedef std::deque<IPC::Message*> MessageQueue; |
| 75 struct PendingRequestInfo { | 75 struct PendingRequestInfo { |
| 76 PendingRequestInfo() { } | 76 PendingRequestInfo() { } |
| 77 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, | 77 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, |
| 78 ResourceType::Type resource_type, | 78 ResourceType::Type resource_type) |
| 79 bool mixed_content) | |
| 80 : peer(peer), | 79 : peer(peer), |
| 81 resource_type(resource_type), | 80 resource_type(resource_type), |
| 82 filter_policy(FilterPolicy::DONT_FILTER), | 81 filter_policy(FilterPolicy::DONT_FILTER), |
| 83 mixed_content(mixed_content), | |
| 84 is_deferred(false) { | 82 is_deferred(false) { |
| 85 } | 83 } |
| 86 ~PendingRequestInfo() { } | 84 ~PendingRequestInfo() { } |
| 87 webkit_glue::ResourceLoaderBridge::Peer* peer; | 85 webkit_glue::ResourceLoaderBridge::Peer* peer; |
| 88 ResourceType::Type resource_type; | 86 ResourceType::Type resource_type; |
| 89 FilterPolicy::Type filter_policy; | 87 FilterPolicy::Type filter_policy; |
| 90 MessageQueue deferred_message_queue; | 88 MessageQueue deferred_message_queue; |
| 91 bool mixed_content; | |
| 92 bool is_deferred; | 89 bool is_deferred; |
| 93 }; | 90 }; |
| 94 typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; | 91 typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; |
| 95 | 92 |
| 96 // Message response handlers, called by the message handler for this process. | 93 // Message response handlers, called by the message handler for this process. |
| 97 void OnUploadProgress(const IPC::Message& message, | 94 void OnUploadProgress(const IPC::Message& message, |
| 98 int request_id, | 95 int request_id, |
| 99 int64 position, | 96 int64 position, |
| 100 int64 size); | 97 int64 size); |
| 101 void OnDownloadProgress(const IPC::Message& message, | 98 void OnDownloadProgress(const IPC::Message& message, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 121 | 118 |
| 122 // All pending requests issued to the host | 119 // All pending requests issued to the host |
| 123 PendingRequestList pending_requests_; | 120 PendingRequestList pending_requests_; |
| 124 | 121 |
| 125 ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; | 122 ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; |
| 126 | 123 |
| 127 DISALLOW_EVIL_CONSTRUCTORS(ResourceDispatcher); | 124 DISALLOW_EVIL_CONSTRUCTORS(ResourceDispatcher); |
| 128 }; | 125 }; |
| 129 | 126 |
| 130 #endif // CHROME_COMMON_RESOURCE_DISPATCHER_H__ | 127 #endif // CHROME_COMMON_RESOURCE_DISPATCHER_H__ |
| OLD | NEW |