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

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

Issue 1708583003: Pass data saver pref value into embedded worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits Created 4 years, 9 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 <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "content/common/service_worker/service_worker_status_code.h" 16 #include "content/common/service_worker/service_worker_status_code.h"
17 17
18 class GURL; 18 class GURL;
19 19
20 namespace content { 20 namespace content {
21 21
22 class BrowserContext; 22 class BrowserContext;
23 struct EmbeddedWorkerSettings;
23 class SiteInstance; 24 class SiteInstance;
24 25
25 // Interacts with the UI thread to keep RenderProcessHosts alive while the 26 // Interacts with the UI thread to keep RenderProcessHosts alive while the
26 // ServiceWorker system is using them. It also tracks candidate processes 27 // ServiceWorker system is using them. It also tracks candidate processes
27 // for each pattern. Each instance of ServiceWorkerProcessManager is destroyed 28 // for each pattern. Each instance of ServiceWorkerProcessManager is destroyed
28 // on the UI thread shortly after its ServiceWorkerContextWrapper is destroyed. 29 // on the UI thread shortly after its ServiceWorkerContextWrapper is destroyed.
29 class CONTENT_EXPORT ServiceWorkerProcessManager { 30 class CONTENT_EXPORT ServiceWorkerProcessManager {
30 public: 31 public:
31 // |*this| must be owned by a ServiceWorkerContextWrapper in a 32 // |*this| must be owned by a ServiceWorkerContextWrapper in a
32 // StoragePartition within |browser_context|. 33 // StoragePartition within |browser_context|.
(...skipping 12 matching lines...) Expand all
45 // 46 //
46 // Allocation can fail with SERVICE_WORKER_PROCESS_NOT_FOUND if 47 // Allocation can fail with SERVICE_WORKER_PROCESS_NOT_FOUND if
47 // RenderProcessHost::Init fails. 48 // RenderProcessHost::Init fails.
48 void AllocateWorkerProcess( 49 void AllocateWorkerProcess(
49 int embedded_worker_id, 50 int embedded_worker_id,
50 const GURL& pattern, 51 const GURL& pattern,
51 const GURL& script_url, 52 const GURL& script_url,
52 bool can_use_existing_process, 53 bool can_use_existing_process,
53 const base::Callback<void(ServiceWorkerStatusCode, 54 const base::Callback<void(ServiceWorkerStatusCode,
54 int process_id, 55 int process_id,
55 bool is_new_process)>& callback); 56 bool is_new_process,
57 const EmbeddedWorkerSettings&)>& callback);
56 58
57 // Drops a reference to a process that was running a Service Worker, and its 59 // Drops a reference to a process that was running a Service Worker, and its
58 // SiteInstance. This must match a call to AllocateWorkerProcess. 60 // SiteInstance. This must match a call to AllocateWorkerProcess.
59 void ReleaseWorkerProcess(int embedded_worker_id); 61 void ReleaseWorkerProcess(int embedded_worker_id);
60 62
61 // Sets a single process ID that will be used for all embedded workers. This 63 // Sets a single process ID that will be used for all embedded workers. This
62 // bypasses the work of creating a process and managing its worker refcount so 64 // bypasses the work of creating a process and managing its worker refcount so
63 // that unittests can run without a BrowserContext. The test is in charge of 65 // that unittests can run without a BrowserContext. The test is in charge of
64 // making sure this is only called on the same thread as runs the UI message 66 // making sure this is only called on the same thread as runs the UI message
65 // loop. 67 // loop.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 156
155 namespace std { 157 namespace std {
156 // Specialized to post the deletion to the UI thread. 158 // Specialized to post the deletion to the UI thread.
157 template <> 159 template <>
158 struct CONTENT_EXPORT default_delete<content::ServiceWorkerProcessManager> { 160 struct CONTENT_EXPORT default_delete<content::ServiceWorkerProcessManager> {
159 void operator()(content::ServiceWorkerProcessManager* ptr) const; 161 void operator()(content::ServiceWorkerProcessManager* ptr) const;
160 }; 162 };
161 } // namespace std 163 } // namespace std
162 164
163 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_ 165 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROCESS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698