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

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

Issue 261753008: Call EmbeddedWorkerDevToolsManager::ServiceWorkerCreated, WorkerContextStarted and WorkerDestroyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
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 <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "content/common/service_worker/service_worker_status_code.h" 13 #include "content/common/service_worker/service_worker_status_code.h"
14 14
15 class GURL; 15 class GURL;
16 16
17 namespace base {
18 class FilePath;
19 }
20
17 namespace content { 21 namespace content {
18 22
19 class BrowserContext; 23 class BrowserContext;
20 class ServiceWorkerContextWrapper; 24 class ServiceWorkerContextWrapper;
21 25
22 // Interacts with the UI thread to keep RenderProcessHosts alive while the 26 // Interacts with the UI thread to keep RenderProcessHosts alive while the
23 // ServiceWorker system is using them. Each instance of 27 // ServiceWorker system is using them. Each instance of
24 // ServiceWorkerProcessManager is destroyed on the UI thread shortly after its 28 // ServiceWorkerProcessManager is destroyed on the UI thread shortly after its
25 // ServiceWorkerContextCore is destroyed on the IO thread. 29 // ServiceWorkerContextCore is destroyed on the IO thread.
26 class CONTENT_EXPORT ServiceWorkerProcessManager { 30 class CONTENT_EXPORT ServiceWorkerProcessManager {
27 public: 31 public:
28 // |*this| must be owned by |context_wrapper|->context(). 32 // |*this| must be owned by |context_wrapper|->context().
29 explicit ServiceWorkerProcessManager( 33 explicit ServiceWorkerProcessManager(
30 ServiceWorkerContextWrapper* context_wrapper); 34 ServiceWorkerContextWrapper* context_wrapper);
31 35
32 ~ServiceWorkerProcessManager(); 36 ~ServiceWorkerProcessManager();
33 37
34 // Returns a reference to a running process suitable for starting the Service 38 // Returns a reference to a running process suitable for starting the Service
35 // Worker at |script_url|. Processes in |process_ids| will be checked in order 39 // Worker at |script_url|. Processes in |process_ids| will be checked in order
36 // for existence, and if none exist, then a new process will be created. Posts 40 // for existence, and if none exist, then a new process will be created. Posts
37 // |callback| to the IO thread to indicate whether creation succeeded and the 41 // |callback| to the IO thread to indicate whether creation succeeded and the
38 // process ID that has a new reference. 42 // process ID that has a new reference.
39 // 43 //
40 // Allocation can fail with SERVICE_WORKER_ERROR_START_WORKER_FAILED if 44 // Allocation can fail with SERVICE_WORKER_ERROR_START_WORKER_FAILED if
41 // RenderProcessHost::Init fails. 45 // RenderProcessHost::Init fails.
42 void AllocateWorkerProcess( 46 void AllocateWorkerProcess(
43 const std::vector<int>& process_ids, 47 const std::vector<int>& process_ids,
48 const base::FilePath& path,
49 const GURL& scope,
44 const GURL& script_url, 50 const GURL& script_url,
45 const base::Callback<void(ServiceWorkerStatusCode, int process_id)>& 51 const base::Callback<void(ServiceWorkerStatusCode,
46 callback) const; 52 int process_id,
53 int worker_devtools_agent_route_id,
54 bool pause_on_start)>& callback) const;
47 55
48 // Drops a reference to a process that was running a Service Worker. This 56 // Drops a reference to a process that was running a Service Worker. This
49 // must match a call to AllocateWorkerProcess. 57 // must match a call to AllocateWorkerProcess.
50 void ReleaseWorkerProcess(int process_id); 58 void ReleaseWorkerProcess(int process_id);
51 59
52 // |increment_for_test| and |decrement_for_test| define how to look up a 60 // |increment_for_test| and |decrement_for_test| define how to look up a
53 // process by ID and increment or decrement its worker reference count. This 61 // process by ID and increment or decrement its worker reference count. This
54 // must be called before any reference to this object escapes to another 62 // must be called before any reference to this object escapes to another
55 // thread, and is considered part of construction. 63 // thread, and is considered part of construction.
56 void SetProcessRefcountOpsForTest( 64 void SetProcessRefcountOpsForTest(
(...skipping 20 matching lines...) Expand all
77 85
78 namespace base { 86 namespace base {
79 // Specialized to post the deletion to the UI thread. 87 // Specialized to post the deletion to the UI thread.
80 template <> 88 template <>
81 struct CONTENT_EXPORT DefaultDeleter<content::ServiceWorkerProcessManager> { 89 struct CONTENT_EXPORT DefaultDeleter<content::ServiceWorkerProcessManager> {
82 void operator()(content::ServiceWorkerProcessManager* ptr) const; 90 void operator()(content::ServiceWorkerProcessManager* ptr) const;
83 }; 91 };
84 } // namespace base 92 } // namespace base
85 93
86 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_ 94 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698