OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHILD_RESOURCE_DISPATCHER_H_ | 7 #ifndef CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
8 #define CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 8 #define CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "content/child/site_isolation_policy.h" | |
18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
19 #include "ipc/ipc_listener.h" | 20 #include "ipc/ipc_listener.h" |
20 #include "ipc/ipc_sender.h" | 21 #include "ipc/ipc_sender.h" |
21 #include "webkit/child/resource_loader_bridge.h" | 22 #include "webkit/child/resource_loader_bridge.h" |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 class ResourceDispatcherDelegate; | 25 class ResourceDispatcherDelegate; |
25 struct ResourceResponseHead; | 26 struct ResourceResponseHead; |
26 | 27 |
27 // This class serves as a communication interface between the | 28 // This class serves as a communication interface between the |
28 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in | 29 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in |
29 // the child process. It can be used from any child process. | 30 // the child process. It can be used from any child process. |
30 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { | 31 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
31 public: | 32 public: |
32 explicit ResourceDispatcher(IPC::Sender* sender); | 33 explicit ResourceDispatcher(IPC::Sender* sender); |
33 virtual ~ResourceDispatcher(); | 34 virtual ~ResourceDispatcher(); |
34 | 35 |
35 // IPC::Listener implementation. | 36 // IPC::Listener implementation. |
36 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 37 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
37 | 38 |
38 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so | 39 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so |
39 // this can be tested regardless of the ResourceLoaderBridge::Create | 40 // this can be tested regardless of the ResourceLoaderBridge::Create |
40 // implementation. | 41 // implementation. |
41 webkit_glue::ResourceLoaderBridge* CreateBridge( | 42 webkit_glue::ResourceLoaderBridge* CreateBridge( |
42 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info); | 43 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info); |
43 | 44 |
44 // Adds a request from the pending_requests_ list, returning the new | 45 // Adds a request from the pending_requests_ list, returning the new |
45 // requests' ID | 46 // requests' ID |
46 int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, | 47 int AddPendingRequest(SiteIsolationPolicy* callback, |
darin (slow to review)
2013/08/20 23:47:05
nit: it is a bit confusing to refer to something t
dsjang
2013/08/21 18:49:57
Done.
| |
47 ResourceType::Type resource_type, | 48 ResourceType::Type resource_type, |
48 const GURL& request_url); | 49 const GURL& request_url); |
49 | 50 |
50 // Removes a request from the pending_requests_ list, returning true if the | 51 // Removes a request from the pending_requests_ list, returning true if the |
51 // request was found and removed. | 52 // request was found and removed. |
52 bool RemovePendingRequest(int request_id); | 53 bool RemovePendingRequest(int request_id); |
53 | 54 |
54 // Cancels a request in the pending_requests_ list. | 55 // Cancels a request in the pending_requests_ list. |
55 void CancelPendingRequest(int routing_id, int request_id); | 56 void CancelPendingRequest(int routing_id, int request_id); |
56 | 57 |
(...skipping 19 matching lines...) Expand all Loading... | |
76 io_timestamp_ = io_timestamp; | 77 io_timestamp_ = io_timestamp; |
77 } | 78 } |
78 | 79 |
79 private: | 80 private: |
80 friend class ResourceDispatcherTest; | 81 friend class ResourceDispatcherTest; |
81 | 82 |
82 typedef std::deque<IPC::Message*> MessageQueue; | 83 typedef std::deque<IPC::Message*> MessageQueue; |
83 struct PendingRequestInfo { | 84 struct PendingRequestInfo { |
84 PendingRequestInfo(); | 85 PendingRequestInfo(); |
85 | 86 |
86 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, | 87 PendingRequestInfo( |
87 ResourceType::Type resource_type, | 88 SiteIsolationPolicy* peer, |
88 const GURL& request_url); | 89 ResourceType::Type resource_type, |
90 const GURL& request_url); | |
89 | 91 |
90 ~PendingRequestInfo(); | 92 ~PendingRequestInfo(); |
91 | 93 |
92 webkit_glue::ResourceLoaderBridge::Peer* peer; | 94 SiteIsolationPolicy* peer; |
93 ResourceType::Type resource_type; | 95 ResourceType::Type resource_type; |
94 MessageQueue deferred_message_queue; | 96 MessageQueue deferred_message_queue; |
95 bool is_deferred; | 97 bool is_deferred; |
96 GURL url; | 98 GURL url; |
97 linked_ptr<IPC::Message> pending_redirect_message; | 99 linked_ptr<IPC::Message> pending_redirect_message; |
98 base::TimeTicks request_start; | 100 base::TimeTicks request_start; |
99 base::TimeTicks response_start; | 101 base::TimeTicks response_start; |
100 base::TimeTicks completion_time; | 102 base::TimeTicks completion_time; |
101 linked_ptr<base::SharedMemory> buffer; | 103 linked_ptr<base::SharedMemory> buffer; |
102 int buffer_size; | 104 int buffer_size; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 194 |
193 // IO thread timestamp for ongoing IPC message. | 195 // IO thread timestamp for ongoing IPC message. |
194 base::TimeTicks io_timestamp_; | 196 base::TimeTicks io_timestamp_; |
195 | 197 |
196 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 198 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
197 }; | 199 }; |
198 | 200 |
199 } // namespace content | 201 } // namespace content |
200 | 202 |
201 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 203 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
OLD | NEW |