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

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: teh 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"
17 #include "content/browser/worker_host/worker_storage_partition.h"
16 #include "content/public/browser/browser_child_process_host_delegate.h" 18 #include "content/public/browser/browser_child_process_host_delegate.h"
17 #include "content/public/browser/browser_child_process_host_iterator.h" 19 #include "content/public/browser/browser_child_process_host_iterator.h"
18 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
19 #include "ipc/ipc_sender.h" 21 #include "ipc/ipc_sender.h"
20 22
21 class BrowserChildProcessHostImpl; 23 class BrowserChildProcessHostImpl;
24 class ChromeAppCacheService;
25 class IndexedDBContextImpl;
22 26
23 namespace content { 27 namespace content {
24 class ResourceContext; 28 class ResourceContext;
25 class WorkerServiceImpl; 29 class WorkerServiceImpl;
26 } // namespace content 30 } // namespace content
27 31
32 namespace fileapi {
33 class FileSystemContext;
34 } // namespace fileapi
35
36 namespace webkit_database {
37 class DatabaseTracker;
38 } // namespace webkit_database
39
28 // The WorkerProcessHost is the interface that represents the browser side of 40 // The WorkerProcessHost is the interface that represents the browser side of
29 // the browser <-> worker communication channel. There will be one 41 // the browser <-> worker communication channel. There will be one
30 // WorkerProcessHost per worker process. Currently each worker runs in its own 42 // WorkerProcessHost per worker process. Currently each worker runs in its own
31 // process, but that may change. However, we do assume (by storing a 43 // process, but that may change. However, we do assume (by storing a
32 // net::URLRequestContext) that a WorkerProcessHost serves a single 44 // net::URLRequestContext) that a WorkerProcessHost serves a single
33 // BrowserContext. 45 // BrowserContext.
34 class WorkerProcessHost : public content::BrowserChildProcessHostDelegate, 46 class WorkerProcessHost : public content::BrowserChildProcessHostDelegate,
35 public IPC::Sender { 47 public IPC::Sender {
36 public: 48 public:
37 // Contains information about each worker instance, needed to forward messages 49 // Contains information about each worker instance, needed to forward messages
38 // between the renderer and worker processes. 50 // between the renderer and worker processes.
39 class WorkerInstance { 51 class WorkerInstance {
40 public: 52 public:
41 WorkerInstance(const GURL& url, 53 WorkerInstance(const GURL& url,
42 const string16& name, 54 const string16& name,
43 int worker_route_id, 55 int worker_route_id,
44 int parent_process_id, 56 int parent_process_id,
45 int64 main_resource_appcache_id, 57 int64 main_resource_appcache_id,
46 content::ResourceContext* resource_context); 58 content::ResourceContext* resource_context,
59 const WorkerStoragePartition& partition);
47 // Used for pending instances. Rest of the parameters are ignored. 60 // Used for pending instances. Rest of the parameters are ignored.
48 WorkerInstance(const GURL& url, 61 WorkerInstance(const GURL& url,
49 bool shared, 62 bool shared,
50 const string16& name, 63 const string16& name,
51 content::ResourceContext* resource_context); 64 content::ResourceContext* resource_context,
65 const WorkerStoragePartition& partition);
52 ~WorkerInstance(); 66 ~WorkerInstance();
53 67
54 // Unique identifier for a worker client. 68 // Unique identifier for a worker client.
55 typedef std::pair<WorkerMessageFilter*, int> FilterInfo; 69 typedef std::pair<WorkerMessageFilter*, int> FilterInfo;
56 70
57 // APIs to manage the filter list for a given instance. 71 // APIs to manage the filter list for a given instance.
58 void AddFilter(WorkerMessageFilter* filter, int route_id); 72 void AddFilter(WorkerMessageFilter* filter, int route_id);
59 void RemoveFilter(WorkerMessageFilter* filter, int route_id); 73 void RemoveFilter(WorkerMessageFilter* filter, int route_id);
60 void RemoveFilters(WorkerMessageFilter* filter); 74 void RemoveFilters(WorkerMessageFilter* filter);
61 bool HasFilter(WorkerMessageFilter* filter, int route_id) const; 75 bool HasFilter(WorkerMessageFilter* filter, int route_id) const;
62 bool RendererIsParent(int render_process_id, int render_view_id) const; 76 bool RendererIsParent(int render_process_id, int render_view_id) const;
63 int NumFilters() const { return filters_.size(); } 77 int NumFilters() const { return filters_.size(); }
64 // Returns the single filter (must only be one). 78 // Returns the single filter (must only be one).
65 FilterInfo GetFilter() const; 79 FilterInfo GetFilter() const;
66 80
67 typedef std::list<FilterInfo> FilterList; 81 typedef std::list<FilterInfo> FilterList;
68 const FilterList& filters() const { return filters_; } 82 const FilterList& filters() const { return filters_; }
69 83
70 // Checks if this WorkerInstance matches the passed url/name params 84 // Checks if this WorkerInstance matches the passed url/name params
71 // (per the comparison algorithm in the WebWorkers spec). This API only 85 // (per the comparison algorithm in the WebWorkers spec). This API only
72 // applies to shared workers. 86 // applies to shared workers.
73 bool Matches( 87 bool Matches(
74 const GURL& url, 88 const GURL& url,
75 const string16& name, 89 const string16& name,
90 const WorkerStoragePartition& partition,
76 content::ResourceContext* resource_context) const; 91 content::ResourceContext* resource_context) const;
77 92
78 // Shares the passed instance's WorkerDocumentSet with this instance. This 93 // Shares the passed instance's WorkerDocumentSet with this instance. This
79 // instance's current WorkerDocumentSet is dereferenced (and freed if this 94 // instance's current WorkerDocumentSet is dereferenced (and freed if this
80 // is the only reference) as a result. 95 // is the only reference) as a result.
81 void ShareDocumentSet(const WorkerInstance& instance) { 96 void ShareDocumentSet(const WorkerInstance& instance) {
82 worker_document_set_ = instance.worker_document_set_; 97 worker_document_set_ = instance.worker_document_set_;
83 }; 98 };
84 99
85 // Accessors 100 // Accessors
86 bool closed() const { return closed_; } 101 bool closed() const { return closed_; }
87 void set_closed(bool closed) { closed_ = closed; } 102 void set_closed(bool closed) { closed_ = closed; }
88 const GURL& url() const { return url_; } 103 const GURL& url() const { return url_; }
89 const string16 name() const { return name_; } 104 const string16 name() const { return name_; }
90 int worker_route_id() const { return worker_route_id_; } 105 int worker_route_id() const { return worker_route_id_; }
91 int parent_process_id() const { return parent_process_id_; } 106 int parent_process_id() const { return parent_process_id_; }
92 int64 main_resource_appcache_id() const { 107 int64 main_resource_appcache_id() const {
93 return main_resource_appcache_id_; 108 return main_resource_appcache_id_;
94 } 109 }
95 WorkerDocumentSet* worker_document_set() const { 110 WorkerDocumentSet* worker_document_set() const {
96 return worker_document_set_; 111 return worker_document_set_;
97 } 112 }
98 content::ResourceContext* resource_context() const { 113 content::ResourceContext* resource_context() const {
99 return resource_context_; 114 return resource_context_;
100 } 115 }
116 const WorkerStoragePartition& partition() const {
117 return partition_;
118 }
101 119
102 private: 120 private:
103 // Set of all filters (clients) associated with this worker. 121 // Set of all filters (clients) associated with this worker.
104 GURL url_; 122 GURL url_;
105 bool closed_; 123 bool closed_;
106 string16 name_; 124 string16 name_;
107 int worker_route_id_; 125 int worker_route_id_;
108 int parent_process_id_; 126 int parent_process_id_;
109 int64 main_resource_appcache_id_; 127 int64 main_resource_appcache_id_;
110 FilterList filters_; 128 FilterList filters_;
111 scoped_refptr<WorkerDocumentSet> worker_document_set_; 129 scoped_refptr<WorkerDocumentSet> worker_document_set_;
112 content::ResourceContext* const resource_context_; 130 content::ResourceContext* const resource_context_;
131 WorkerStoragePartition partition_;
113 }; 132 };
114 133
115 explicit WorkerProcessHost(content::ResourceContext* resource_context); 134 WorkerProcessHost(content::ResourceContext* resource_context,
135 const WorkerStoragePartition& partition);
116 virtual ~WorkerProcessHost(); 136 virtual ~WorkerProcessHost();
117 137
118 // IPC::Sender implementation: 138 // IPC::Sender implementation:
119 virtual bool Send(IPC::Message* message) OVERRIDE; 139 virtual bool Send(IPC::Message* message) OVERRIDE;
120 140
121 // Starts the process. Returns true iff it succeeded. 141 // Starts the process. Returns true iff it succeeded.
122 // |render_process_id| is the renderer process responsible for starting this 142 // |render_process_id| is the renderer process responsible for starting this
123 // worker. 143 // worker.
124 bool Init(int render_process_id); 144 bool Init(int render_process_id);
125 145
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Updates the title shown in the task manager. 208 // Updates the title shown in the task manager.
189 void UpdateTitle(); 209 void UpdateTitle();
190 210
191 // Return a vector of all the render process/render view IDs that use the 211 // Return a vector of all the render process/render view IDs that use the
192 // given worker. 212 // given worker.
193 std::vector<std::pair<int, int> > GetRenderViewIDsForWorker(int route_id); 213 std::vector<std::pair<int, int> > GetRenderViewIDsForWorker(int route_id);
194 214
195 Instances instances_; 215 Instances instances_;
196 216
197 content::ResourceContext* const resource_context_; 217 content::ResourceContext* const resource_context_;
218 WorkerStoragePartition partition_;
198 219
199 // A reference to the filter associated with this worker process. We need to 220 // 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 221 // keep this around since we'll use it when forward messages to the worker
201 // process. 222 // process.
202 scoped_refptr<WorkerMessageFilter> worker_message_filter_; 223 scoped_refptr<WorkerMessageFilter> worker_message_filter_;
203 224
204 scoped_ptr<BrowserChildProcessHostImpl> process_; 225 scoped_ptr<BrowserChildProcessHostImpl> process_;
205 226
206 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost); 227 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost);
207 }; 228 };
208 229
209 class WorkerProcessHostIterator 230 class WorkerProcessHostIterator
210 : public content::BrowserChildProcessHostTypeIterator<WorkerProcessHost> { 231 : public content::BrowserChildProcessHostTypeIterator<WorkerProcessHost> {
211 public: 232 public:
212 WorkerProcessHostIterator() 233 WorkerProcessHostIterator()
213 : content::BrowserChildProcessHostTypeIterator<WorkerProcessHost>( 234 : content::BrowserChildProcessHostTypeIterator<WorkerProcessHost>(
214 content::PROCESS_TYPE_WORKER) { 235 content::PROCESS_TYPE_WORKER) {
215 } 236 }
216 }; 237 };
217 238
218 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ 239 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « content/browser/worker_host/worker_message_filter.cc ('k') | content/browser/worker_host/worker_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698