Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: content/browser/worker_host/worker_process_host.h

Issue 10885044: Remove storage context accessors from ResourceContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged to ToT Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ 5 #ifndef CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_
6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ 6 #define CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string>
9 #include <utility> 10 #include <utility>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/file_path.h" 13 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "content/browser/worker_host/worker_document_set.h" 16 #include "content/browser/worker_host/worker_document_set.h"
16 #include "content/public/browser/browser_child_process_host_delegate.h" 17 #include "content/public/browser/browser_child_process_host_delegate.h"
17 #include "content/public/browser/browser_child_process_host_iterator.h" 18 #include "content/public/browser/browser_child_process_host_iterator.h"
18 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
19 #include "ipc/ipc_sender.h" 20 #include "ipc/ipc_sender.h"
20 21
21 class BrowserChildProcessHostImpl; 22 class BrowserChildProcessHostImpl;
23 class ChromeAppCacheService;
24 class IndexedDBContextImpl;
22 25
23 namespace content { 26 namespace content {
24 class ResourceContext; 27 class ResourceContext;
25 class WorkerServiceImpl; 28 class WorkerServiceImpl;
26 } // namespace content 29 } // namespace content
27 30
31 namespace fileapi {
32 class FileSystemContext;
33 } // namespace fileapi
34
35 namespace webkit_database {
36 class DatabaseTracker;
37 } // namespace webkit_database
38
28 // The WorkerProcessHost is the interface that represents the browser side of 39 // The WorkerProcessHost is the interface that represents the browser side of
29 // the browser <-> worker communication channel. There will be one 40 // the browser <-> worker communication channel. There will be one
30 // WorkerProcessHost per worker process. Currently each worker runs in its own 41 // WorkerProcessHost per worker process. Currently each worker runs in its own
31 // process, but that may change. However, we do assume (by storing a 42 // process, but that may change. However, we do assume (by storing a
32 // net::URLRequestContext) that a WorkerProcessHost serves a single 43 // net::URLRequestContext) that a WorkerProcessHost serves a single
33 // BrowserContext. 44 // BrowserContext.
34 class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, 45 class WorkerProcessHost : public content::BrowserChildProcessHostDelegate,
35 public IPC::Sender { 46 public IPC::Sender {
36 public: 47 public:
37 // Contains information about each worker instance, needed to forward messages 48 // Contains information about each worker instance, needed to forward messages
38 // between the renderer and worker processes. 49 // between the renderer and worker processes.
39 class WorkerInstance { 50 class WorkerInstance {
40 public: 51 public:
41 WorkerInstance(const GURL& url, 52 WorkerInstance(const GURL& url,
42 const string16& name, 53 const string16& name,
43 int worker_route_id, 54 int worker_route_id,
44 int parent_process_id, 55 int parent_process_id,
45 int64 main_resource_appcache_id, 56 int64 main_resource_appcache_id,
46 content::ResourceContext* resource_context); 57 const std::string& partition_id,
58 content::ResourceContext* resource_context,
59 ChromeAppCacheService* appcache_service,
60 fileapi::FileSystemContext* filesystem_context,
61 webkit_database::DatabaseTracker* database_tracker,
62 IndexedDBContextImpl* indexed_db_context);
47 // Used for pending instances. Rest of the parameters are ignored. 63 // Used for pending instances. Rest of the parameters are ignored.
48 WorkerInstance(const GURL& url, 64 WorkerInstance(const GURL& url,
49 bool shared, 65 bool shared,
50 const string16& name, 66 const string16& name,
51 content::ResourceContext* resource_context); 67 const std::string& partition_id,
68 content::ResourceContext* resource_context,
69 ChromeAppCacheService* appcache_service,
70 fileapi::FileSystemContext* filesystem_context,
71 webkit_database::DatabaseTracker* database_tracker,
72 IndexedDBContextImpl* indexed_db_context);
52 ~WorkerInstance(); 73 ~WorkerInstance();
53 74
54 // Unique identifier for a worker client. 75 // Unique identifier for a worker client.
55 typedef std::pair<WorkerMessageFilter*, int> FilterInfo; 76 typedef std::pair<WorkerMessageFilter*, int> FilterInfo;
56 77
57 // APIs to manage the filter list for a given instance. 78 // APIs to manage the filter list for a given instance.
58 void AddFilter(WorkerMessageFilter* filter, int route_id); 79 void AddFilter(WorkerMessageFilter* filter, int route_id);
59 void RemoveFilter(WorkerMessageFilter* filter, int route_id); 80 void RemoveFilter(WorkerMessageFilter* filter, int route_id);
60 void RemoveFilters(WorkerMessageFilter* filter); 81 void RemoveFilters(WorkerMessageFilter* filter);
61 bool HasFilter(WorkerMessageFilter* filter, int route_id) const; 82 bool HasFilter(WorkerMessageFilter* filter, int route_id) const;
62 bool RendererIsParent(int render_process_id, int render_view_id) const; 83 bool RendererIsParent(int render_process_id, int render_view_id) const;
63 int NumFilters() const { return filters_.size(); } 84 int NumFilters() const { return filters_.size(); }
64 // Returns the single filter (must only be one). 85 // Returns the single filter (must only be one).
65 FilterInfo GetFilter() const; 86 FilterInfo GetFilter() const;
66 87
67 typedef std::list<FilterInfo> FilterList; 88 typedef std::list<FilterInfo> FilterList;
68 const FilterList& filters() const { return filters_; } 89 const FilterList& filters() const { return filters_; }
69 90
70 // Checks if this WorkerInstance matches the passed url/name params 91 // Checks if this WorkerInstance matches the passed url/name params
71 // (per the comparison algorithm in the WebWorkers spec). This API only 92 // (per the comparison algorithm in the WebWorkers spec). This API only
72 // applies to shared workers. 93 // applies to shared workers.
73 bool Matches( 94 bool Matches(
74 const GURL& url, 95 const GURL& url,
75 const string16& name, 96 const string16& name,
97 const std::string& partition_id,
76 content::ResourceContext* resource_context) const; 98 content::ResourceContext* resource_context) const;
77 99
78 // Shares the passed instance's WorkerDocumentSet with this instance. This 100 // Shares the passed instance's WorkerDocumentSet with this instance. This
79 // instance's current WorkerDocumentSet is dereferenced (and freed if this 101 // instance's current WorkerDocumentSet is dereferenced (and freed if this
80 // is the only reference) as a result. 102 // is the only reference) as a result.
81 void ShareDocumentSet(const WorkerInstance& instance) { 103 void ShareDocumentSet(const WorkerInstance& instance) {
82 worker_document_set_ = instance.worker_document_set_; 104 worker_document_set_ = instance.worker_document_set_;
83 }; 105 };
84 106
85 // Accessors 107 // Accessors
86 bool closed() const { return closed_; } 108 bool closed() const { return closed_; }
87 void set_closed(bool closed) { closed_ = closed; } 109 void set_closed(bool closed) { closed_ = closed; }
88 const GURL& url() const { return url_; } 110 const GURL& url() const { return url_; }
89 const string16 name() const { return name_; } 111 const string16 name() const { return name_; }
90 int worker_route_id() const { return worker_route_id_; } 112 int worker_route_id() const { return worker_route_id_; }
91 int parent_process_id() const { return parent_process_id_; } 113 int parent_process_id() const { return parent_process_id_; }
92 int64 main_resource_appcache_id() const { 114 int64 main_resource_appcache_id() const {
93 return main_resource_appcache_id_; 115 return main_resource_appcache_id_;
94 } 116 }
95 WorkerDocumentSet* worker_document_set() const { 117 WorkerDocumentSet* worker_document_set() const {
96 return worker_document_set_; 118 return worker_document_set_;
97 } 119 }
98 content::ResourceContext* resource_context() const { 120 content::ResourceContext* resource_context() const {
99 return resource_context_; 121 return resource_context_;
100 } 122 }
123 const std::string& partition_id() const {
124 return partition_id_;
125 }
126 ChromeAppCacheService* appcache_service() const {
127 return appcache_service_;
128 }
129 fileapi::FileSystemContext* filesystem_context() const {
130 return filesystem_context_;
131 }
132 webkit_database::DatabaseTracker* database_tracker() const {
133 return database_tracker_;
134 }
135 IndexedDBContextImpl* indexed_db_context() const {
136 return indexed_db_context_;
137 }
101 138
102 private: 139 private:
103 // Set of all filters (clients) associated with this worker. 140 // Set of all filters (clients) associated with this worker.
104 GURL url_; 141 GURL url_;
105 bool closed_; 142 bool closed_;
106 string16 name_; 143 string16 name_;
107 int worker_route_id_; 144 int worker_route_id_;
108 int parent_process_id_; 145 int parent_process_id_;
109 int64 main_resource_appcache_id_; 146 int64 main_resource_appcache_id_;
110 FilterList filters_; 147 FilterList filters_;
111 scoped_refptr<WorkerDocumentSet> worker_document_set_; 148 scoped_refptr<WorkerDocumentSet> worker_document_set_;
149 std::string partition_id_;
112 content::ResourceContext* const resource_context_; 150 content::ResourceContext* const resource_context_;
151 ChromeAppCacheService* const appcache_service_;
152 fileapi::FileSystemContext* const filesystem_context_;
153 webkit_database::DatabaseTracker* const database_tracker_;
154 IndexedDBContextImpl* const indexed_db_context_;
113 }; 155 };
114 156
115 explicit WorkerProcessHost(content::ResourceContext* resource_context); 157 WorkerProcessHost(const std::string& partition_id,
158 content::ResourceContext* resource_context,
159 ChromeAppCacheService* appcache_service,
160 fileapi::FileSystemContext* filesystem_context,
161 webkit_database::DatabaseTracker* database_tracker,
162 IndexedDBContextImpl* indexed_db_context);
116 virtual ~WorkerProcessHost(); 163 virtual ~WorkerProcessHost();
117 164
118 // IPC::Sender implementation: 165 // IPC::Sender implementation:
119 virtual bool Send(IPC::Message* message) OVERRIDE; 166 virtual bool Send(IPC::Message* message) OVERRIDE;
120 167
121 // Starts the process. Returns true iff it succeeded. 168 // Starts the process. Returns true iff it succeeded.
122 // |render_process_id| is the renderer process responsible for starting this 169 // |render_process_id| is the renderer process responsible for starting this
123 // worker. 170 // worker.
124 bool Init(int render_process_id); 171 bool Init(int render_process_id);
125 172
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 234
188 // Updates the title shown in the task manager. 235 // Updates the title shown in the task manager.
189 void UpdateTitle(); 236 void UpdateTitle();
190 237
191 // Return a vector of all the render process/render view IDs that use the 238 // Return a vector of all the render process/render view IDs that use the
192 // given worker. 239 // given worker.
193 std::vector<std::pair<int, int> > GetRenderViewIDsForWorker(int route_id); 240 std::vector<std::pair<int, int> > GetRenderViewIDsForWorker(int route_id);
194 241
195 Instances instances_; 242 Instances instances_;
196 243
244 std::string partition_id_;
197 content::ResourceContext* const resource_context_; 245 content::ResourceContext* const resource_context_;
246 ChromeAppCacheService* const appcache_service_;
247 fileapi::FileSystemContext* const filesystem_context_;
248 webkit_database::DatabaseTracker* const database_tracker_;
249 IndexedDBContextImpl* const indexed_db_context_;
198 250
199 // A reference to the filter associated with this worker process. We need to 251 // A reference to the filter associated with this worker process. We need to
200 // keep this around since we'll use it when forward messages to the worker 252 // keep this around since we'll use it when forward messages to the worker
201 // process. 253 // process.
202 scoped_refptr<WorkerMessageFilter> worker_message_filter_; 254 scoped_refptr<WorkerMessageFilter> worker_message_filter_;
203 255
204 scoped_ptr<BrowserChildProcessHostImpl> process_; 256 scoped_ptr<BrowserChildProcessHostImpl> process_;
205 257
206 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost); 258 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost);
207 }; 259 };
208 260
209 class WorkerProcessHostIterator 261 class WorkerProcessHostIterator
210 : public content::BrowserChildProcessHostTypeIterator<WorkerProcessHost> { 262 : public content::BrowserChildProcessHostTypeIterator<WorkerProcessHost> {
211 public: 263 public:
212 WorkerProcessHostIterator() 264 WorkerProcessHostIterator()
213 : content::BrowserChildProcessHostTypeIterator<WorkerProcessHost>( 265 : content::BrowserChildProcessHostTypeIterator<WorkerProcessHost>(
214 content::PROCESS_TYPE_WORKER) { 266 content::PROCESS_TYPE_WORKER) {
215 } 267 }
216 }; 268 };
217 269
218 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ 270 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698