| 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 <queue> | 10 #include <queue> |
| 11 | 11 |
| 12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
| 13 #include "base/shared_memory.h" |
| 13 #include "base/task.h" | 14 #include "base/task.h" |
| 15 #include "chrome/common/filter_policy.h" |
| 14 #include "chrome/common/ipc_channel.h" | 16 #include "chrome/common/ipc_channel.h" |
| 15 #include "chrome/common/render_messages.h" | |
| 16 #include "webkit/glue/resource_loader_bridge.h" | 17 #include "webkit/glue/resource_loader_bridge.h" |
| 17 | 18 |
| 19 struct ResourceResponseHead; |
| 20 struct ViewMsg_Resource_ResponseHead; |
| 21 |
| 18 // Uncomment this to disable loading resources via the parent process. This | 22 // Uncomment this to disable loading resources via the parent process. This |
| 19 // may be useful for debugging purposes. | 23 // may be useful for debugging purposes. |
| 20 //#define USING_SIMPLE_RESOURCE_LOADER_BRIDGE | 24 //#define USING_SIMPLE_RESOURCE_LOADER_BRIDGE |
| 21 | 25 |
| 22 // This class serves as a communication interface between the | 26 // This class serves as a communication interface between the |
| 23 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in | 27 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in |
| 24 // the child process. It can be used from either the renderer or plugin | 28 // the child process. It can be used from either the renderer or plugin |
| 25 // processes. | 29 // processes. |
| 26 class ResourceDispatcher : public base::RefCounted<ResourceDispatcher> { | 30 class ResourceDispatcher : public base::RefCounted<ResourceDispatcher> { |
| 27 public: | 31 public: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ResourceType::Type resource_type; | 96 ResourceType::Type resource_type; |
| 93 FilterPolicy::Type filter_policy; | 97 FilterPolicy::Type filter_policy; |
| 94 MessageQueue deferred_message_queue; | 98 MessageQueue deferred_message_queue; |
| 95 bool mixed_content; | 99 bool mixed_content; |
| 96 bool is_deferred; | 100 bool is_deferred; |
| 97 }; | 101 }; |
| 98 typedef base::hash_map<int,PendingRequestInfo> PendingRequestList; | 102 typedef base::hash_map<int,PendingRequestInfo> PendingRequestList; |
| 99 | 103 |
| 100 // Message response handlers, called by the message handler for this process. | 104 // Message response handlers, called by the message handler for this process. |
| 101 void OnUploadProgress(int request_id, int64 position, int64 size); | 105 void OnUploadProgress(int request_id, int64 position, int64 size); |
| 102 void OnReceivedResponse(int request_id, const ViewMsg_Resource_ResponseHead&); | 106 void OnReceivedResponse(int request_id, const ResourceResponseHead&); |
| 103 void OnReceivedRedirect(int request_id, const GURL& new_url); | 107 void OnReceivedRedirect(int request_id, const GURL& new_url); |
| 104 void OnReceivedData(int request_id, base::SharedMemoryHandle data, | 108 void OnReceivedData(int request_id, base::SharedMemoryHandle data, |
| 105 int data_len); | 109 int data_len); |
| 106 void OnRequestComplete(int request_id, const URLRequestStatus& status); | 110 void OnRequestComplete(int request_id, const URLRequestStatus& status); |
| 107 | 111 |
| 108 // Dispatch the message to one of the message response handlers. | 112 // Dispatch the message to one of the message response handlers. |
| 109 void DispatchMessage(const IPC::Message& message); | 113 void DispatchMessage(const IPC::Message& message); |
| 110 | 114 |
| 111 // Dispatch any deferred messages for the given request, provided it is not | 115 // Dispatch any deferred messages for the given request, provided it is not |
| 112 // again in the deferred state. | 116 // again in the deferred state. |
| 113 void FlushDeferredMessages(int request_id); | 117 void FlushDeferredMessages(int request_id); |
| 114 | 118 |
| 115 IPC::Message::Sender* message_sender_; | 119 IPC::Message::Sender* message_sender_; |
| 116 | 120 |
| 117 // All pending requests issued to the host | 121 // All pending requests issued to the host |
| 118 PendingRequestList pending_requests_; | 122 PendingRequestList pending_requests_; |
| 119 | 123 |
| 120 ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; | 124 ScopedRunnableMethodFactory<ResourceDispatcher> method_factory_; |
| 121 | 125 |
| 122 DISALLOW_EVIL_CONSTRUCTORS(ResourceDispatcher); | 126 DISALLOW_EVIL_CONSTRUCTORS(ResourceDispatcher); |
| 123 }; | 127 }; |
| 124 | 128 |
| 125 #endif // CHROME_COMMON_RESOURCE_DISPATCHER_H__ | 129 #endif // CHROME_COMMON_RESOURCE_DISPATCHER_H__ |
| OLD | NEW |