Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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; | |
|
michaeln
2016/10/05 19:22:53
is this needed?
lazyboy
2016/10/06 01:02:06
Not anymore, removed.
| |
| 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 Loading... | |
| 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, | |
|
Devlin
2016/10/05 17:02:25
drive-by: function comment?
lazyboy
2016/10/06 01:02:06
Obsolete now with new patch.
| |
| 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 found. Also returns |request_id| in that | |
| 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_; | |
|
michaeln
2016/10/05 19:22:53
Please consider moving this mapping of external_re
lazyboy
2016/10/06 01:02:06
Done.
| |
| 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_ |
| OLD | NEW |