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

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

Issue 2166523003: Add ref count to service workers for extension API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addres comments from falken@ Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CONTEXT_WRAPPER_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 const GURL& url, 105 const GURL& url,
106 const GURL& other_url, 106 const GURL& other_url,
107 const CheckHasServiceWorkerCallback& callback) override; 107 const CheckHasServiceWorkerCallback& callback) override;
108 void StopAllServiceWorkersForOrigin(const GURL& origin) override; 108 void StopAllServiceWorkersForOrigin(const GURL& origin) override;
109 void ClearAllServiceWorkersForTest(const base::Closure& callback) override; 109 void ClearAllServiceWorkersForTest(const base::Closure& callback) override;
110 void StartServiceWorkerForNavigationHint( 110 void StartServiceWorkerForNavigationHint(
111 const GURL& document_url, 111 const GURL& document_url,
112 blink::WebNavigationHintType type, 112 blink::WebNavigationHintType type,
113 int render_process_id, 113 int render_process_id,
114 const ResultCallback& callback) override; 114 const ResultCallback& callback) override;
115 bool IncrementPendingActivity(int64_t service_worker_version_id) override;
116 bool DecrementPendingActivity(int64_t service_worker_version_id) override;
115 117
116 // These methods must only be called from the IO thread. 118 // These methods must only be called from the IO thread.
117 ServiceWorkerRegistration* GetLiveRegistration(int64_t registration_id); 119 ServiceWorkerRegistration* GetLiveRegistration(int64_t registration_id);
118 ServiceWorkerVersion* GetLiveVersion(int64_t version_id); 120 ServiceWorkerVersion* GetLiveVersion(int64_t version_id);
119 std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo(); 121 std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo();
120 std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo(); 122 std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo();
121 123
122 // Must be called from the IO thread. 124 // Must be called from the IO thread.
123 void HasMainFrameProviderHost(const GURL& origin, 125 void HasMainFrameProviderHost(const GURL& origin,
124 const BoolCallback& callback) const; 126 const BoolCallback& callback) const;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool OriginHasForeignFetchRegistrations(const GURL& origin); 191 bool OriginHasForeignFetchRegistrations(const GURL& origin);
190 192
191 // Must be called from the UI thread. 193 // Must be called from the UI thread.
192 bool IsRunningNavigationHintTask(int render_process_id) const; 194 bool IsRunningNavigationHintTask(int render_process_id) const;
193 195
194 private: 196 private:
195 friend class BackgroundSyncManagerTest; 197 friend class BackgroundSyncManagerTest;
196 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; 198 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
197 friend class EmbeddedWorkerTestHelper; 199 friend class EmbeddedWorkerTestHelper;
198 friend class EmbeddedWorkerBrowserTest; 200 friend class EmbeddedWorkerBrowserTest;
201 friend class ServiceWorkerContext;
199 friend class ServiceWorkerDispatcherHost; 202 friend class ServiceWorkerDispatcherHost;
200 friend class ServiceWorkerInternalsUI; 203 friend class ServiceWorkerInternalsUI;
201 friend class ServiceWorkerNavigationHandleCore; 204 friend class ServiceWorkerNavigationHandleCore;
202 friend class ServiceWorkerProcessManager; 205 friend class ServiceWorkerProcessManager;
203 friend class ServiceWorkerRequestHandler; 206 friend class ServiceWorkerRequestHandler;
204 friend class ServiceWorkerVersionBrowserTest; 207 friend class ServiceWorkerVersionBrowserTest;
205 friend class MockServiceWorkerContextWrapper; 208 friend class MockServiceWorkerContextWrapper;
206 209
207 ~ServiceWorkerContextWrapper() override; 210 ~ServiceWorkerContextWrapper() override;
208 211
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 scoped_refptr<ServiceWorkerRegistration> registration); 252 scoped_refptr<ServiceWorkerRegistration> registration);
250 253
251 void DidStartServiceWorkerForNavigationHint(const GURL& pattern, 254 void DidStartServiceWorkerForNavigationHint(const GURL& pattern,
252 int render_process_id, 255 int render_process_id,
253 const ResultCallback& callback, 256 const ResultCallback& callback,
254 ServiceWorkerStatusCode code); 257 ServiceWorkerStatusCode code);
255 void DidFinishNavigationHintTaskOnUI(int render_process_id, 258 void DidFinishNavigationHintTaskOnUI(int render_process_id,
256 const ResultCallback& callback, 259 const ResultCallback& callback,
257 bool result); 260 bool result);
258 261
262 void ExternalRequestErrorCallback(int64_t service_worker_version_id,
263 ServiceWorkerStatusCode status);
264
259 // The core context is only for use on the IO thread. 265 // The core context is only for use on the IO thread.
260 // Can be null before/during init, during/after shutdown, and after 266 // Can be null before/during init, during/after shutdown, and after
261 // DeleteAndStartOver fails. 267 // DeleteAndStartOver fails.
262 ServiceWorkerContextCore* context(); 268 ServiceWorkerContextCore* context();
263 269
264 const scoped_refptr<base::ObserverListThreadSafe< 270 const scoped_refptr<base::ObserverListThreadSafe<
265 ServiceWorkerContextObserver>> observer_list_; 271 ServiceWorkerContextObserver>> observer_list_;
266 const std::unique_ptr<ServiceWorkerProcessManager> process_manager_; 272 const std::unique_ptr<ServiceWorkerProcessManager> process_manager_;
267 // Cleared in ShutdownOnIO(): 273 // Cleared in ShutdownOnIO():
268 std::unique_ptr<ServiceWorkerContextCore> context_core_; 274 std::unique_ptr<ServiceWorkerContextCore> context_core_;
269 275
270 // Initialized in Init(); true if the user data directory is empty. 276 // Initialized in Init(); true if the user data directory is empty.
271 bool is_incognito_; 277 bool is_incognito_;
272 278
273 // Raw pointer to the StoragePartitionImpl owning |this|. 279 // Raw pointer to the StoragePartitionImpl owning |this|.
274 StoragePartitionImpl* storage_partition_; 280 StoragePartitionImpl* storage_partition_;
275 281
276 // The ResourceContext associated with this context. 282 // The ResourceContext associated with this context.
277 ResourceContext* resource_context_; 283 ResourceContext* resource_context_;
278 284
279 // Must be touched on the UI thread. 285 // Must be touched on the UI thread.
280 std::map<int, int> navigation_hint_task_count_per_process_; 286 std::map<int, int> navigation_hint_task_count_per_process_;
281 287
288 // Maps service worker version id -> list of pending request ids in the order
289 // they arrive.
290 // IO thread.
291 std::map<int64_t, std::queue<int>> pending_external_requests_;
292
282 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper); 293 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper);
283 }; 294 };
284 295
285 } // namespace content 296 } // namespace content
286 297
287 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 298 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698