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

Side by Side Diff: content/browser/service_worker/service_worker_process_manager.h

Issue 307443003: Revert of Reparent SWProcessManager onto SWContextWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "content/common/service_worker/service_worker_status_code.h" 14 #include "content/common/service_worker/service_worker_status_code.h"
15 15
16 class GURL; 16 class GURL;
17 17
18 namespace content { 18 namespace content {
19 19
20 class BrowserContext; 20 class BrowserContext;
21 class ServiceWorkerContextWrapper;
21 class SiteInstance; 22 class SiteInstance;
22 23
23 // Interacts with the UI thread to keep RenderProcessHosts alive while the 24 // Interacts with the UI thread to keep RenderProcessHosts alive while the
24 // ServiceWorker system is using them. Each instance of 25 // ServiceWorker system is using them. Each instance of
25 // ServiceWorkerProcessManager is destroyed on the UI thread shortly after its 26 // ServiceWorkerProcessManager is destroyed on the UI thread shortly after its
26 // ServiceWorkerContextWrapper is destroyed. 27 // ServiceWorkerContextCore is destroyed on the IO thread.
27 class CONTENT_EXPORT ServiceWorkerProcessManager { 28 class CONTENT_EXPORT ServiceWorkerProcessManager {
28 public: 29 public:
29 // |*this| must be owned by a ServiceWorkerContextWrapper in a 30 // |*this| must be owned by |context_wrapper|->context().
30 // StoragePartition within |browser_context|. 31 explicit ServiceWorkerProcessManager(
31 explicit ServiceWorkerProcessManager(BrowserContext* browser_context); 32 ServiceWorkerContextWrapper* context_wrapper);
32 33
33 // Shutdown must be called before the ProcessManager is destroyed.
34 ~ServiceWorkerProcessManager(); 34 ~ServiceWorkerProcessManager();
35 35
36 // Synchronously prevents new processes from being allocated.
37 // TODO(jyasskin): Drop references to RenderProcessHosts too.
38 void Shutdown();
39
40 // Returns a reference to a running process suitable for starting the Service 36 // Returns a reference to a running process suitable for starting the Service
41 // Worker at |script_url|. Processes in |process_ids| will be checked in order 37 // Worker at |script_url|. Processes in |process_ids| will be checked in order
42 // for existence, and if none exist, then a new process will be created. Posts 38 // for existence, and if none exist, then a new process will be created. Posts
43 // |callback| to the IO thread to indicate whether creation succeeded and the 39 // |callback| to the IO thread to indicate whether creation succeeded and the
44 // process ID that has a new reference. 40 // process ID that has a new reference.
45 // 41 //
46 // Allocation can fail with SERVICE_WORKER_ERROR_START_WORKER_FAILED if 42 // Allocation can fail with SERVICE_WORKER_ERROR_START_WORKER_FAILED if
47 // RenderProcessHost::Init fails. 43 // RenderProcessHost::Init fails.
48 void AllocateWorkerProcess( 44 void AllocateWorkerProcess(
49 int embedded_worker_id, 45 int embedded_worker_id,
(...skipping 27 matching lines...) Expand all
77 // ContentBrowserClient interface. 73 // ContentBrowserClient interface.
78 scoped_refptr<SiteInstance> site_instance; 74 scoped_refptr<SiteInstance> site_instance;
79 75
80 // In case the process was allocated without using a SiteInstance, we need 76 // In case the process was allocated without using a SiteInstance, we need
81 // to store a process ID to decrement a worker reference on shutdown. 77 // to store a process ID to decrement a worker reference on shutdown.
82 // TODO(jyasskin): Implement http://crbug.com/372045 or thread a frame_id in 78 // TODO(jyasskin): Implement http://crbug.com/372045 or thread a frame_id in
83 // so all processes can be allocated with a SiteInstance. 79 // so all processes can be allocated with a SiteInstance.
84 int process_id; 80 int process_id;
85 }; 81 };
86 82
87 // These fields are only accessed on the UI thread. 83 // These fields are only accessed on the UI thread after construction.
88 BrowserContext* browser_context_; 84 // The reference cycle through context_wrapper_ is broken in
85 // ServiceWorkerContextWrapper::Shutdown().
86 scoped_refptr<ServiceWorkerContextWrapper> context_wrapper_;
89 87
90 // Maps the ID of a running EmbeddedWorkerInstance to information about the 88 // Maps the ID of a running EmbeddedWorkerInstance to information about the
91 // process it's running inside. Since the Instances themselves live on the IO 89 // process it's running inside. Since the Instances themselves live on the IO
92 // thread, this can be slightly out of date: 90 // thread, this can be slightly out of date:
93 // * instance_info_ is populated while an Instance is STARTING and before 91 // * instance_info_ is populated while an Instance is STARTING and before
94 // it's RUNNING. 92 // it's RUNNING.
95 // * instance_info_ is depopulated in a message sent as the Instance becomes 93 // * instance_info_ is depopulated in a message sent as the Instance becomes
96 // STOPPED. 94 // STOPPED.
97 std::map<int, ProcessInfo> instance_info_; 95 std::map<int, ProcessInfo> instance_info_;
98 96
(...skipping 10 matching lines...) Expand all
109 107
110 namespace base { 108 namespace base {
111 // Specialized to post the deletion to the UI thread. 109 // Specialized to post the deletion to the UI thread.
112 template <> 110 template <>
113 struct CONTENT_EXPORT DefaultDeleter<content::ServiceWorkerProcessManager> { 111 struct CONTENT_EXPORT DefaultDeleter<content::ServiceWorkerProcessManager> {
114 void operator()(content::ServiceWorkerProcessManager* ptr) const; 112 void operator()(content::ServiceWorkerProcessManager* ptr) const;
115 }; 113 };
116 } // namespace base 114 } // namespace base
117 115
118 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_ 116 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698