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

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

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

Powered by Google App Engine
This is Rietveld 408576698