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

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

Issue 2959903002: Revert of Implement dumb URLLoader{Factory} for ServiceWorker script loading (Closed)
Patch Set: pull master and rebase Created 3 years, 5 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_CORE_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 17 matching lines...) Expand all
28 #include "content/public/browser/service_worker_context.h" 28 #include "content/public/browser/service_worker_context.h"
29 29
30 class GURL; 30 class GURL;
31 31
32 namespace base { 32 namespace base {
33 class FilePath; 33 class FilePath;
34 class SingleThreadTaskRunner; 34 class SingleThreadTaskRunner;
35 } 35 }
36 36
37 namespace storage { 37 namespace storage {
38 class BlobStorageContext;
39 class QuotaManagerProxy; 38 class QuotaManagerProxy;
40 class SpecialStoragePolicy; 39 class SpecialStoragePolicy;
41 } 40 }
42 41
43 namespace content { 42 namespace content {
44 43
45 class EmbeddedWorkerRegistry; 44 class EmbeddedWorkerRegistry;
46 class ServiceWorkerContextCoreObserver; 45 class ServiceWorkerContextCoreObserver;
47 class ServiceWorkerContextWrapper; 46 class ServiceWorkerContextWrapper;
48 class ServiceWorkerDatabaseTaskManager; 47 class ServiceWorkerDatabaseTaskManager;
49 class ServiceWorkerDispatcherHost; 48 class ServiceWorkerDispatcherHost;
50 class ServiceWorkerJobCoordinator; 49 class ServiceWorkerJobCoordinator;
51 class ServiceWorkerNavigationHandleCore; 50 class ServiceWorkerNavigationHandleCore;
52 class ServiceWorkerProviderHost; 51 class ServiceWorkerProviderHost;
53 class ServiceWorkerRegistration; 52 class ServiceWorkerRegistration;
54 class ServiceWorkerStorage; 53 class ServiceWorkerStorage;
55 class URLLoaderFactoryGetter;
56 54
57 // This class manages data associated with service workers. 55 // This class manages data associated with service workers.
58 // The class is single threaded and should only be used on the IO thread. 56 // The class is single threaded and should only be used on the IO thread.
59 // In chromium, there is one instance per storagepartition. This class 57 // In chromium, there is one instance per storagepartition. This class
60 // is the root of the containment hierarchy for service worker data 58 // is the root of the containment hierarchy for service worker data
61 // associated with a particular partition. 59 // associated with a particular partition.
62 class CONTENT_EXPORT ServiceWorkerContextCore 60 class CONTENT_EXPORT ServiceWorkerContextCore
63 : NON_EXPORTED_BASE(public ServiceWorkerVersion::Listener) { 61 : NON_EXPORTED_BASE(public ServiceWorkerVersion::Listener) {
64 public: 62 public:
65 using BoolCallback = base::Callback<void(bool)>; 63 using BoolCallback = base::Callback<void(bool)>;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 104
107 DISALLOW_COPY_AND_ASSIGN(ProviderHostIterator); 105 DISALLOW_COPY_AND_ASSIGN(ProviderHostIterator);
108 }; 106 };
109 107
110 // This is owned by the StoragePartition, which will supply it with 108 // This is owned by the StoragePartition, which will supply it with
111 // the local path on disk. Given an empty |user_data_directory|, 109 // the local path on disk. Given an empty |user_data_directory|,
112 // nothing will be stored on disk. |observer_list| is created in 110 // nothing will be stored on disk. |observer_list| is created in
113 // ServiceWorkerContextWrapper. When Notify() of |observer_list| is called in 111 // ServiceWorkerContextWrapper. When Notify() of |observer_list| is called in
114 // ServiceWorkerContextCore, the methods of ServiceWorkerContextCoreObserver 112 // ServiceWorkerContextCore, the methods of ServiceWorkerContextCoreObserver
115 // will be called on the thread which called AddObserver() of |observer_list|. 113 // will be called on the thread which called AddObserver() of |observer_list|.
116 // |blob_context| and |url_loader_factory_getter| are used only
117 // when IsServicificationEnabled is true.
118 ServiceWorkerContextCore( 114 ServiceWorkerContextCore(
119 const base::FilePath& user_data_directory, 115 const base::FilePath& user_data_directory,
120 std::unique_ptr<ServiceWorkerDatabaseTaskManager> 116 std::unique_ptr<ServiceWorkerDatabaseTaskManager>
121 database_task_runner_manager, 117 database_task_runner_manager,
122 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread, 118 const scoped_refptr<base::SingleThreadTaskRunner>& disk_cache_thread,
123 storage::QuotaManagerProxy* quota_manager_proxy, 119 storage::QuotaManagerProxy* quota_manager_proxy,
124 storage::SpecialStoragePolicy* special_storage_policy, 120 storage::SpecialStoragePolicy* special_storage_policy,
125 base::WeakPtr<storage::BlobStorageContext> blob_context,
126 URLLoaderFactoryGetter* url_loader_factory_getter,
127 base::ObserverListThreadSafe<ServiceWorkerContextCoreObserver>* 121 base::ObserverListThreadSafe<ServiceWorkerContextCoreObserver>*
128 observer_list, 122 observer_list,
129 ServiceWorkerContextWrapper* wrapper); 123 ServiceWorkerContextWrapper* wrapper);
130 ServiceWorkerContextCore( 124 ServiceWorkerContextCore(
131 ServiceWorkerContextCore* old_context, 125 ServiceWorkerContextCore* old_context,
132 ServiceWorkerContextWrapper* wrapper); 126 ServiceWorkerContextWrapper* wrapper);
133 ~ServiceWorkerContextCore() override; 127 ~ServiceWorkerContextCore() override;
134 128
135 void OnStorageWiped(); 129 void OnStorageWiped();
136 130
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 int GetVersionFailureCount(int64_t version_id); 300 int GetVersionFailureCount(int64_t version_id);
307 301
308 // Binds the ServiceWorkerWorkerClient of a dedicated (or shared) worker to 302 // Binds the ServiceWorkerWorkerClient of a dedicated (or shared) worker to
309 // the parent frame's ServiceWorkerProviderHost. (This is used only when 303 // the parent frame's ServiceWorkerProviderHost. (This is used only when
310 // off-main-thread-fetch is enabled.) 304 // off-main-thread-fetch is enabled.)
311 void BindWorkerFetchContext( 305 void BindWorkerFetchContext(
312 int render_process_id, 306 int render_process_id,
313 int service_worker_provider_id, 307 int service_worker_provider_id,
314 mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info); 308 mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info);
315 309
316 base::WeakPtr<storage::BlobStorageContext> blob_storage_context() {
317 return blob_storage_context_;
318 }
319
320 URLLoaderFactoryGetter* loader_factory_getter() {
321 return loader_factory_getter_.get();
322 }
323
324 base::WeakPtr<ServiceWorkerContextCore> AsWeakPtr() { 310 base::WeakPtr<ServiceWorkerContextCore> AsWeakPtr() {
325 return weak_factory_.GetWeakPtr(); 311 return weak_factory_.GetWeakPtr();
326 } 312 }
327 313
328 private: 314 private:
329 friend class ServiceWorkerContextCoreTest; 315 friend class ServiceWorkerContextCoreTest;
330 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextCoreTest, FailureInfo); 316 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerContextCoreTest, FailureInfo);
331 317
332 typedef std::map<int64_t, ServiceWorkerRegistration*> RegistrationsMap; 318 typedef std::map<int64_t, ServiceWorkerRegistration*> RegistrationsMap;
333 typedef std::map<int64_t, ServiceWorkerVersion*> VersionMap; 319 typedef std::map<int64_t, ServiceWorkerVersion*> VersionMap;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 std::map<int64_t, ServiceWorkerVersion*> live_versions_; 373 std::map<int64_t, ServiceWorkerVersion*> live_versions_;
388 std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_; 374 std::map<int64_t, scoped_refptr<ServiceWorkerVersion>> protected_versions_;
389 375
390 std::map<int64_t /* version_id */, FailureInfo> failure_counts_; 376 std::map<int64_t /* version_id */, FailureInfo> failure_counts_;
391 377
392 // PlzNavigate 378 // PlzNavigate
393 // Map of ServiceWorkerNavigationHandleCores used for navigation requests. 379 // Map of ServiceWorkerNavigationHandleCores used for navigation requests.
394 std::map<int, ServiceWorkerNavigationHandleCore*> 380 std::map<int, ServiceWorkerNavigationHandleCore*>
395 navigation_handle_cores_map_; 381 navigation_handle_cores_map_;
396 382
397 // IsServicificationEnabled
398 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_;
399 scoped_refptr<URLLoaderFactoryGetter> loader_factory_getter_;
400
401 bool force_update_on_page_load_; 383 bool force_update_on_page_load_;
402 int next_handle_id_; 384 int next_handle_id_;
403 int next_registration_handle_id_; 385 int next_registration_handle_id_;
404 // Set in RegisterServiceWorker(), cleared in ClearAllServiceWorkersForTest(). 386 // Set in RegisterServiceWorker(), cleared in ClearAllServiceWorkersForTest().
405 // This is used to avoid unnecessary disk read operation in tests. This value 387 // This is used to avoid unnecessary disk read operation in tests. This value
406 // is false if Chrome was relaunched after service workers were registered. 388 // is false if Chrome was relaunched after service workers were registered.
407 bool was_service_worker_registered_; 389 bool was_service_worker_registered_;
408 scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextCoreObserver>> 390 scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextCoreObserver>>
409 observer_list_; 391 observer_list_;
410 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_; 392 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_;
411 393
412 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore); 394 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore);
413 }; 395 };
414 396
415 } // namespace content 397 } // namespace content
416 398
417 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ 399 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698