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

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: address 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,
116 const std::string& request_uuid) override;
117 bool DecrementPendingActivity(int64_t service_worker_version_id,
118 const std::string& request_uuid) override;
115 119
116 // These methods must only be called from the IO thread. 120 // These methods must only be called from the IO thread.
117 ServiceWorkerRegistration* GetLiveRegistration(int64_t registration_id); 121 ServiceWorkerRegistration* GetLiveRegistration(int64_t registration_id);
118 ServiceWorkerVersion* GetLiveVersion(int64_t version_id); 122 ServiceWorkerVersion* GetLiveVersion(int64_t version_id);
119 std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo(); 123 std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo();
120 std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo(); 124 std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo();
121 125
122 // Must be called from the IO thread. 126 // Must be called from the IO thread.
123 void HasMainFrameProviderHost(const GURL& origin, 127 void HasMainFrameProviderHost(const GURL& origin,
124 const BoolCallback& callback) const; 128 const BoolCallback& callback) const;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool OriginHasForeignFetchRegistrations(const GURL& origin); 193 bool OriginHasForeignFetchRegistrations(const GURL& origin);
190 194
191 // Must be called from the UI thread. 195 // Must be called from the UI thread.
192 bool IsRunningNavigationHintTask(int render_process_id) const; 196 bool IsRunningNavigationHintTask(int render_process_id) const;
193 197
194 private: 198 private:
195 friend class BackgroundSyncManagerTest; 199 friend class BackgroundSyncManagerTest;
196 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; 200 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
197 friend class EmbeddedWorkerTestHelper; 201 friend class EmbeddedWorkerTestHelper;
198 friend class EmbeddedWorkerBrowserTest; 202 friend class EmbeddedWorkerBrowserTest;
203 friend class ServiceWorkerContext;
199 friend class ServiceWorkerDispatcherHost; 204 friend class ServiceWorkerDispatcherHost;
200 friend class ServiceWorkerInternalsUI; 205 friend class ServiceWorkerInternalsUI;
201 friend class ServiceWorkerNavigationHandleCore; 206 friend class ServiceWorkerNavigationHandleCore;
202 friend class ServiceWorkerProcessManager; 207 friend class ServiceWorkerProcessManager;
203 friend class ServiceWorkerRequestHandler; 208 friend class ServiceWorkerRequestHandler;
204 friend class ServiceWorkerVersionBrowserTest; 209 friend class ServiceWorkerVersionBrowserTest;
205 friend class MockServiceWorkerContextWrapper; 210 friend class MockServiceWorkerContextWrapper;
206 211
207 ~ServiceWorkerContextWrapper() override; 212 ~ServiceWorkerContextWrapper() override;
208 213
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 scoped_refptr<ServiceWorkerRegistration> registration); 254 scoped_refptr<ServiceWorkerRegistration> registration);
250 255
251 void DidStartServiceWorkerForNavigationHint(const GURL& pattern, 256 void DidStartServiceWorkerForNavigationHint(const GURL& pattern,
252 int render_process_id, 257 int render_process_id,
253 const ResultCallback& callback, 258 const ResultCallback& callback,
254 ServiceWorkerStatusCode code); 259 ServiceWorkerStatusCode code);
255 void DidFinishNavigationHintTaskOnUI(int render_process_id, 260 void DidFinishNavigationHintTaskOnUI(int render_process_id,
256 const ResultCallback& callback, 261 const ResultCallback& callback,
257 bool result); 262 bool result);
258 263
264 void ExternalRequestErrorCallback(int64_t service_worker_version_id,
265 const std::string& request_uuid,
266 ServiceWorkerStatusCode status);
267
268 // Removes a pending external request identified by |request_uuid|.
269 // Returns true if the request was pending. Also returns |request_id| in that
falken 2016/10/03 04:20:31 "pending" is a bit confusing since by definition i
lazyboy 2016/10/04 02:42:52 Done.
270 // case.
271 bool RemovePendingExternalRequest(int64_t service_worker_version_id,
272 const std::string& request_uuid,
273 int* request_id);
274
259 // The core context is only for use on the IO thread. 275 // The core context is only for use on the IO thread.
260 // Can be null before/during init, during/after shutdown, and after 276 // Can be null before/during init, during/after shutdown, and after
261 // DeleteAndStartOver fails. 277 // DeleteAndStartOver fails.
262 ServiceWorkerContextCore* context(); 278 ServiceWorkerContextCore* context();
263 279
264 const scoped_refptr<base::ObserverListThreadSafe< 280 const scoped_refptr<base::ObserverListThreadSafe<
265 ServiceWorkerContextObserver>> observer_list_; 281 ServiceWorkerContextObserver>> observer_list_;
266 const std::unique_ptr<ServiceWorkerProcessManager> process_manager_; 282 const std::unique_ptr<ServiceWorkerProcessManager> process_manager_;
267 // Cleared in ShutdownOnIO(): 283 // Cleared in ShutdownOnIO():
268 std::unique_ptr<ServiceWorkerContextCore> context_core_; 284 std::unique_ptr<ServiceWorkerContextCore> context_core_;
269 285
270 // Initialized in Init(); true if the user data directory is empty. 286 // Initialized in Init(); true if the user data directory is empty.
271 bool is_incognito_; 287 bool is_incognito_;
272 288
273 // Raw pointer to the StoragePartitionImpl owning |this|. 289 // Raw pointer to the StoragePartitionImpl owning |this|.
274 StoragePartitionImpl* storage_partition_; 290 StoragePartitionImpl* storage_partition_;
275 291
276 // The ResourceContext associated with this context. 292 // The ResourceContext associated with this context.
277 ResourceContext* resource_context_; 293 ResourceContext* resource_context_;
278 294
279 // Must be touched on the UI thread. 295 // Must be touched on the UI thread.
280 std::map<int, int> navigation_hint_task_count_per_process_; 296 std::map<int, int> navigation_hint_task_count_per_process_;
281 297
298 // Container for pending external requests of a service worker.
299 // Each request is (key, value): (request uuid, request id).
300 using RequestUUIDToRequestID = std::map<std::string, int>;
301 // Maps service worker version id -> RequestUUIDToRequestID.
302 // IO thread.
303 std::map<int64_t, RequestUUIDToRequestID> pending_external_requests_;
304
282 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper); 305 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper);
283 }; 306 };
284 307
285 } // namespace content 308 } // namespace content
286 309
287 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 310 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698