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

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

Issue 6825038: Create a content::ResourceContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Own database_tracker. Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "chrome/browser/net/chrome_url_request_context.h" 13 #include "chrome/browser/net/chrome_url_request_context.h"
14 #include "content/browser/browser_child_process_host.h" 14 #include "content/browser/browser_child_process_host.h"
15 #include "content/browser/worker_host/worker_document_set.h" 15 #include "content/browser/worker_host/worker_document_set.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 17
18 class ResourceDispatcherHost;
19 namespace content {
20 class ResourceContext;
21 } // namespace content
18 namespace net { 22 namespace net {
19 class URLRequestContextGetter; 23 class URLRequestContextGetter;
20 } 24 } // namespace net
21 25
22 // The WorkerProcessHost is the interface that represents the browser side of 26 // The WorkerProcessHost is the interface that represents the browser side of
23 // the browser <-> worker communication channel. There will be one 27 // the browser <-> worker communication channel. There will be one
24 // WorkerProcessHost per worker process. Currently each worker runs in its own 28 // WorkerProcessHost per worker process. Currently each worker runs in its own
25 // process, but that may change. However, we do assume (by storing a 29 // process, but that may change. However, we do assume (by storing a
26 // net::URLRequestContext) that a WorkerProcessHost serves a single Profile. 30 // net::URLRequestContext) that a WorkerProcessHost serves a single Profile.
27 class WorkerProcessHost : public BrowserChildProcessHost { 31 class WorkerProcessHost : public BrowserChildProcessHost {
28 public: 32 public:
29 33
30 // Contains information about each worker instance, needed to forward messages 34 // Contains information about each worker instance, needed to forward messages
31 // between the renderer and worker processes. 35 // between the renderer and worker processes.
32 class WorkerInstance { 36 class WorkerInstance {
33 public: 37 public:
34 WorkerInstance(const GURL& url, 38 WorkerInstance(const GURL& url,
35 bool shared, 39 bool shared,
36 bool incognito, 40 bool incognito,
37 const string16& name, 41 const string16& name,
38 int worker_route_id, 42 int worker_route_id,
39 int parent_process_id, 43 int parent_process_id,
40 int parent_appcache_host_id, 44 int parent_appcache_host_id,
41 int64 main_resource_appcache_id, 45 int64 main_resource_appcache_id,
42 net::URLRequestContextGetter* request_context); 46 net::URLRequestContextGetter* request_context_getter,
47 const content::ResourceContext& resource_context);
48 // Used for pending instances. Rest of the parameters are ignored.
49 WorkerInstance(const GURL& url,
50 bool shared,
51 bool incognito,
52 const string16& name);
43 ~WorkerInstance(); 53 ~WorkerInstance();
44 54
45 // Unique identifier for a worker client. 55 // Unique identifier for a worker client.
46 typedef std::pair<WorkerMessageFilter*, int> FilterInfo; 56 typedef std::pair<WorkerMessageFilter*, int> FilterInfo;
47 57
48 // APIs to manage the filter list for a given instance. 58 // APIs to manage the filter list for a given instance.
49 void AddFilter(WorkerMessageFilter* filter, int route_id); 59 void AddFilter(WorkerMessageFilter* filter, int route_id);
50 void RemoveFilter(WorkerMessageFilter* filter, int route_id); 60 void RemoveFilter(WorkerMessageFilter* filter, int route_id);
51 void RemoveFilters(WorkerMessageFilter* filter); 61 void RemoveFilters(WorkerMessageFilter* filter);
52 bool HasFilter(WorkerMessageFilter* filter, int route_id) const; 62 bool HasFilter(WorkerMessageFilter* filter, int route_id) const;
(...skipping 27 matching lines...) Expand all
80 const string16 name() const { return name_; } 90 const string16 name() const { return name_; }
81 int worker_route_id() const { return worker_route_id_; } 91 int worker_route_id() const { return worker_route_id_; }
82 int parent_process_id() const { return parent_process_id_; } 92 int parent_process_id() const { return parent_process_id_; }
83 int parent_appcache_host_id() const { return parent_appcache_host_id_; } 93 int parent_appcache_host_id() const { return parent_appcache_host_id_; }
84 int64 main_resource_appcache_id() const { 94 int64 main_resource_appcache_id() const {
85 return main_resource_appcache_id_; 95 return main_resource_appcache_id_;
86 } 96 }
87 WorkerDocumentSet* worker_document_set() const { 97 WorkerDocumentSet* worker_document_set() const {
88 return worker_document_set_; 98 return worker_document_set_;
89 } 99 }
90 net::URLRequestContextGetter* request_context() const { 100 net::URLRequestContextGetter* request_context_getter() const {
91 return request_context_; 101 return request_context_getter_;
102 }
103 const content::ResourceContext& resource_context() const {
104 return *resource_context_;
92 } 105 }
93 106
94 private: 107 private:
95 // Set of all filters (clients) associated with this worker. 108 // Set of all filters (clients) associated with this worker.
96 GURL url_; 109 GURL url_;
97 bool shared_; 110 bool shared_;
98 bool incognito_; 111 bool incognito_;
99 bool closed_; 112 bool closed_;
100 string16 name_; 113 string16 name_;
101 int worker_route_id_; 114 int worker_route_id_;
102 int parent_process_id_; 115 int parent_process_id_;
103 int parent_appcache_host_id_; 116 int parent_appcache_host_id_;
104 int64 main_resource_appcache_id_; 117 int64 main_resource_appcache_id_;
105 scoped_refptr<net::URLRequestContextGetter> request_context_; 118 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
106 FilterList filters_; 119 FilterList filters_;
107 scoped_refptr<WorkerDocumentSet> worker_document_set_; 120 scoped_refptr<WorkerDocumentSet> worker_document_set_;
121 const content::ResourceContext* const resource_context_;
108 }; 122 };
109 123
110 WorkerProcessHost( 124 WorkerProcessHost(
111 ResourceDispatcherHost* resource_dispatcher_host, 125 net::URLRequestContextGetter* request_context_getter,
112 net::URLRequestContextGetter* request_context); 126 const content::ResourceContext& resource_context,
127 ResourceDispatcherHost* resource_dispatcher_host);
113 ~WorkerProcessHost(); 128 ~WorkerProcessHost();
114 129
115 // Starts the process. Returns true iff it succeeded. 130 // Starts the process. Returns true iff it succeeded.
116 // |render_process_id| is the renderer process responsible for starting this 131 // |render_process_id| is the renderer process responsible for starting this
117 // worker. 132 // worker.
118 bool Init(int render_process_id); 133 bool Init(int render_process_id);
119 134
120 // Creates a worker object in the process. 135 // Creates a worker object in the process.
121 void CreateWorker(const WorkerInstance& instance); 136 void CreateWorker(const WorkerInstance& instance);
122 137
123 // Returns true iff the given message from a renderer process was forwarded to 138 // Returns true iff the given message from a renderer process was forwarded to
124 // the worker. 139 // the worker.
125 bool FilterMessage(const IPC::Message& message, WorkerMessageFilter* filter); 140 bool FilterMessage(const IPC::Message& message, WorkerMessageFilter* filter);
126 141
127 void FilterShutdown(WorkerMessageFilter* filter); 142 void FilterShutdown(WorkerMessageFilter* filter);
128 143
129 // Shuts down any shared workers that are no longer referenced by active 144 // Shuts down any shared workers that are no longer referenced by active
130 // documents. 145 // documents.
131 void DocumentDetached(WorkerMessageFilter* filter, 146 void DocumentDetached(WorkerMessageFilter* filter,
132 unsigned long long document_id); 147 unsigned long long document_id);
133 148
134 net::URLRequestContextGetter* request_context() const {
135 return request_context_;
136 }
137
138 protected: 149 protected:
139 friend class WorkerService; 150 friend class WorkerService;
140 151
141 typedef std::list<WorkerInstance> Instances; 152 typedef std::list<WorkerInstance> Instances;
142 const Instances& instances() const { return instances_; } 153 const Instances& instances() const { return instances_; }
143 Instances& mutable_instances() { return instances_; } 154 Instances& mutable_instances() { return instances_; }
144 155
145 private: 156 private:
146 // Called when the process has been launched successfully. 157 // Called when the process has been launched successfully.
147 virtual void OnProcessLaunched(); 158 virtual void OnProcessLaunched();
(...skipping 21 matching lines...) Expand all
169 180
170 virtual bool CanShutdown(); 181 virtual bool CanShutdown();
171 182
172 // Updates the title shown in the task manager. 183 // Updates the title shown in the task manager.
173 void UpdateTitle(); 184 void UpdateTitle();
174 185
175 ChromeURLRequestContext* GetChromeURLRequestContext(); 186 ChromeURLRequestContext* GetChromeURLRequestContext();
176 187
177 Instances instances_; 188 Instances instances_;
178 189
179 scoped_refptr<net::URLRequestContextGetter> request_context_; 190 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
eroman 2011/04/15 03:05:27 Thanks for fixing the naming on these.
191
192 const content::ResourceContext* const resource_context_;
180 193
181 // A reference to the filter associated with this worker process. We need to 194 // A reference to the filter associated with this worker process. We need to
182 // keep this around since we'll use it when forward messages to the worker 195 // keep this around since we'll use it when forward messages to the worker
183 // process. 196 // process.
184 scoped_refptr<WorkerMessageFilter> worker_message_filter_; 197 scoped_refptr<WorkerMessageFilter> worker_message_filter_;
185 198
199 ResourceDispatcherHost* const resource_dispatcher_host_;
200
186 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost); 201 DISALLOW_COPY_AND_ASSIGN(WorkerProcessHost);
187 }; 202 };
188 203
189 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_ 204 #endif // CONTENT_BROWSER_WORKER_HOST_WORKER_PROCESS_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698