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

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

Issue 852463002: Keep track of ServiceWorkerContext's BrowserContext and expose it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nullptr
Patch Set: Created 5 years, 11 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 <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 17 matching lines...) Expand all
28 class QuotaManagerProxy; 28 class QuotaManagerProxy;
29 class SpecialStoragePolicy; 29 class SpecialStoragePolicy;
30 } 30 }
31 31
32 namespace content { 32 namespace content {
33 33
34 class BrowserContext; 34 class BrowserContext;
35 class ChromeBlobStorageContext; 35 class ChromeBlobStorageContext;
36 class ServiceWorkerContextCore; 36 class ServiceWorkerContextCore;
37 class ServiceWorkerContextObserver; 37 class ServiceWorkerContextObserver;
38 class StoragePartitionImpl;
38 39
39 // A refcounted wrapper class for our core object. Higher level content lib 40 // A refcounted wrapper class for our core object. Higher level content lib
40 // classes keep references to this class on mutliple threads. The inner core 41 // classes keep references to this class on mutliple threads. The inner core
41 // instance is strictly single threaded and is not refcounted, the core object 42 // instance is strictly single threaded and is not refcounted, the core object
42 // is what is used internally in the service worker lib. 43 // is what is used internally in the service worker lib.
43 class CONTENT_EXPORT ServiceWorkerContextWrapper 44 class CONTENT_EXPORT ServiceWorkerContextWrapper
44 : NON_EXPORTED_BASE(public ServiceWorkerContext), 45 : NON_EXPORTED_BASE(public ServiceWorkerContext),
45 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> { 46 public base::RefCountedThreadSafe<ServiceWorkerContextWrapper> {
46 public: 47 public:
47 ServiceWorkerContextWrapper(BrowserContext* browser_context); 48 ServiceWorkerContextWrapper(BrowserContext* browser_context);
48 49
49 // Init and Shutdown are for use on the UI thread when the profile, 50 // Init and Shutdown are for use on the UI thread when the profile,
50 // storagepartition is being setup and torn down. 51 // storagepartition is being setup and torn down.
51 void Init(const base::FilePath& user_data_directory, 52 void Init(StoragePartitionImpl* storage_partition,
53 const base::FilePath& user_data_directory,
52 storage::QuotaManagerProxy* quota_manager_proxy, 54 storage::QuotaManagerProxy* quota_manager_proxy,
53 storage::SpecialStoragePolicy* special_storage_policy); 55 storage::SpecialStoragePolicy* special_storage_policy);
54 void Shutdown(); 56 void Shutdown();
55 57
56 // Deletes all files on disk and restarts the system asynchronously. This 58 // Deletes all files on disk and restarts the system asynchronously. This
57 // leaves the system in a disabled state until it's done. This should be 59 // leaves the system in a disabled state until it's done. This should be
58 // called on the IO thread. 60 // called on the IO thread.
59 void DeleteAndStartOver(); 61 void DeleteAndStartOver();
60 62
61 // The core context is only for use on the IO thread. 63 // The core context is only for use on the IO thread.
62 ServiceWorkerContextCore* context(); 64 ServiceWorkerContextCore* context();
63 65
66 // The StoragePartition should only be used on the UI thread.
michaeln 2015/01/13 21:27:32 Also say that it may be null before/during init an
mlamouri (slow - plz ping) 2015/01/14 15:46:24 Done.
67 StoragePartitionImpl* storage_partition() const;
68
64 // The process manager can be used on either UI or IO. 69 // The process manager can be used on either UI or IO.
65 ServiceWorkerProcessManager* process_manager() { 70 ServiceWorkerProcessManager* process_manager() {
66 return process_manager_.get(); 71 return process_manager_.get();
67 } 72 }
68 73
69 // ServiceWorkerContext implementation: 74 // ServiceWorkerContext implementation:
70 void RegisterServiceWorker(const GURL& pattern, 75 void RegisterServiceWorker(const GURL& pattern,
71 const GURL& script_url, 76 const GURL& script_url,
72 const ResultCallback& continuation) override; 77 const ResultCallback& continuation) override;
73 void UnregisterServiceWorker(const GURL& pattern, 78 void UnregisterServiceWorker(const GURL& pattern,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 const std::vector<ServiceWorkerRegistrationInfo>& registrations); 128 const std::vector<ServiceWorkerRegistrationInfo>& registrations);
124 129
125 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> > 130 const scoped_refptr<ObserverListThreadSafe<ServiceWorkerContextObserver> >
126 observer_list_; 131 observer_list_;
127 const scoped_ptr<ServiceWorkerProcessManager> process_manager_; 132 const scoped_ptr<ServiceWorkerProcessManager> process_manager_;
128 // Cleared in Shutdown(): 133 // Cleared in Shutdown():
129 scoped_ptr<ServiceWorkerContextCore> context_core_; 134 scoped_ptr<ServiceWorkerContextCore> context_core_;
130 135
131 // Initialized in Init(); true if the user data directory is empty. 136 // Initialized in Init(); true if the user data directory is empty.
132 bool is_incognito_; 137 bool is_incognito_;
138
139 // WeakPtr to the StoragePartitionImpl owning |this|.
michaeln 2015/01/13 21:27:32 Actual use of the WeakPtr<> template here might he
mlamouri (slow - plz ping) 2015/01/14 15:46:24 I would prefer not to abuse WeakPtr<> in order to
140 StoragePartitionImpl* storage_partition_;
133 }; 141 };
134 142
135 } // namespace content 143 } // namespace content
136 144
137 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 145 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698