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

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

Issue 1757023003: Document confusing threading requirements in ServiceWorkerContext(Wrapper). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_context_wrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 10 #include <vector>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override; 95 void GetAllOriginsInfo(const GetUsageInfoCallback& callback) override;
96 void DeleteForOrigin(const GURL& origin, 96 void DeleteForOrigin(const GURL& origin,
97 const ResultCallback& callback) override; 97 const ResultCallback& callback) override;
98 void CheckHasServiceWorker( 98 void CheckHasServiceWorker(
99 const GURL& url, 99 const GURL& url,
100 const GURL& other_url, 100 const GURL& other_url,
101 const CheckHasServiceWorkerCallback& callback) override; 101 const CheckHasServiceWorkerCallback& callback) override;
102 void StopAllServiceWorkersForOrigin(const GURL& origin) override; 102 void StopAllServiceWorkersForOrigin(const GURL& origin) override;
103 void ClearAllServiceWorkersForTest(const base::Closure& callback) override; 103 void ClearAllServiceWorkersForTest(const base::Closure& callback) override;
104 104
105 // These methods must only be called from the IO thread.
105 ServiceWorkerRegistration* GetLiveRegistration(int64_t registration_id); 106 ServiceWorkerRegistration* GetLiveRegistration(int64_t registration_id);
106 ServiceWorkerVersion* GetLiveVersion(int64_t version_id); 107 ServiceWorkerVersion* GetLiveVersion(int64_t version_id);
107 std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo(); 108 std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo();
108 std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo(); 109 std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo();
109 110
111 // Must be called from the IO thread.
110 void HasMainFrameProviderHost(const GURL& origin, 112 void HasMainFrameProviderHost(const GURL& origin,
111 const BoolCallback& callback) const; 113 const BoolCallback& callback) const;
112 114
113 // Returns the registration whose scope longest matches |document_url|. It is 115 // Returns the registration whose scope longest matches |document_url|. It is
114 // guaranteed that the returned registration has the activated worker. 116 // guaranteed that the returned registration has the activated worker.
115 // 117 //
116 // - If the registration is not found, returns ERROR_NOT_FOUND. 118 // - If the registration is not found, returns ERROR_NOT_FOUND.
117 // - If the registration has neither the waiting version nor the active 119 // - If the registration has neither the waiting version nor the active
118 // version, returns ERROR_NOT_FOUND. 120 // version, returns ERROR_NOT_FOUND.
119 // - If the registration does not have the active version but has the waiting 121 // - If the registration does not have the active version but has the waiting
120 // version, activates the waiting version and runs |callback| when it is 122 // version, activates the waiting version and runs |callback| when it is
121 // activated. 123 // activated.
124 //
125 // Must be called from the IO thread.
122 void FindReadyRegistrationForDocument( 126 void FindReadyRegistrationForDocument(
123 const GURL& document_url, 127 const GURL& document_url,
124 const FindRegistrationCallback& callback); 128 const FindRegistrationCallback& callback);
125 129
126 // Returns the registration for |registration_id|. It is guaranteed that the 130 // Returns the registration for |registration_id|. It is guaranteed that the
127 // returned registration has the activated worker. 131 // returned registration has the activated worker.
128 // 132 //
129 // - If the registration is not found, returns ERROR_NOT_FOUND. 133 // - If the registration is not found, returns ERROR_NOT_FOUND.
130 // - If the registration has neither the waiting version nor the active 134 // - If the registration has neither the waiting version nor the active
131 // version, returns ERROR_NOT_FOUND. 135 // version, returns ERROR_NOT_FOUND.
132 // - If the registration does not have the active version but has the waiting 136 // - If the registration does not have the active version but has the waiting
133 // version, activates the waiting version and runs |callback| when it is 137 // version, activates the waiting version and runs |callback| when it is
134 // activated. 138 // activated.
139 //
140 // Must be called from the IO thread.
135 void FindReadyRegistrationForId(int64_t registration_id, 141 void FindReadyRegistrationForId(int64_t registration_id,
136 const GURL& origin, 142 const GURL& origin,
137 const FindRegistrationCallback& callback); 143 const FindRegistrationCallback& callback);
138 144
145 // All these methods must be called from the IO thread.
139 void GetAllRegistrations(const GetRegistrationsInfosCallback& callback); 146 void GetAllRegistrations(const GetRegistrationsInfosCallback& callback);
140 void GetRegistrationUserData(int64_t registration_id, 147 void GetRegistrationUserData(int64_t registration_id,
141 const std::string& key, 148 const std::string& key,
142 const GetUserDataCallback& callback); 149 const GetUserDataCallback& callback);
143 void StoreRegistrationUserData(int64_t registration_id, 150 void StoreRegistrationUserData(int64_t registration_id,
144 const GURL& origin, 151 const GURL& origin,
145 const std::string& key, 152 const std::string& key,
146 const std::string& data, 153 const std::string& data,
147 const StatusCallback& callback); 154 const StatusCallback& callback);
148 void ClearRegistrationUserData(int64_t registration_id, 155 void ClearRegistrationUserData(int64_t registration_id,
149 const std::string& key, 156 const std::string& key,
150 const StatusCallback& callback); 157 const StatusCallback& callback);
151 void GetUserDataForAllRegistrations( 158 void GetUserDataForAllRegistrations(
152 const std::string& key, 159 const std::string& key,
153 const GetUserDataForAllRegistrationsCallback& callback); 160 const GetUserDataForAllRegistrationsCallback& callback);
154 161
162 // This function can be called from any thread, but the callback will always
163 // be called on the UI thread.
155 void StartServiceWorker(const GURL& pattern, const StatusCallback& callback); 164 void StartServiceWorker(const GURL& pattern, const StatusCallback& callback);
165
166 // These methods can be called from any thread.
156 void UpdateRegistration(const GURL& pattern); 167 void UpdateRegistration(const GURL& pattern);
157 void SetForceUpdateOnPageLoad(int64_t registration_id, 168 void SetForceUpdateOnPageLoad(int64_t registration_id,
158 bool force_update_on_page_load); 169 bool force_update_on_page_load);
159 void AddObserver(ServiceWorkerContextObserver* observer); 170 void AddObserver(ServiceWorkerContextObserver* observer);
160 void RemoveObserver(ServiceWorkerContextObserver* observer); 171 void RemoveObserver(ServiceWorkerContextObserver* observer);
161 172
162 bool is_incognito() const { return is_incognito_; } 173 bool is_incognito() const { return is_incognito_; }
163 174
175 // Must be called from the IO thread.
164 bool OriginHasForeignFetchRegistrations(const GURL& origin); 176 bool OriginHasForeignFetchRegistrations(const GURL& origin);
165 177
166 private: 178 private:
167 friend class BackgroundSyncManagerTest; 179 friend class BackgroundSyncManagerTest;
168 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>; 180 friend class base::RefCountedThreadSafe<ServiceWorkerContextWrapper>;
169 friend class EmbeddedWorkerTestHelper; 181 friend class EmbeddedWorkerTestHelper;
170 friend class EmbeddedWorkerBrowserTest; 182 friend class EmbeddedWorkerBrowserTest;
171 friend class ServiceWorkerDispatcherHost; 183 friend class ServiceWorkerDispatcherHost;
172 friend class ServiceWorkerInternalsUI; 184 friend class ServiceWorkerInternalsUI;
173 friend class ServiceWorkerNavigationHandleCore; 185 friend class ServiceWorkerNavigationHandleCore;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 239
228 // The ResourceContext associated with this context. 240 // The ResourceContext associated with this context.
229 ResourceContext* resource_context_; 241 ResourceContext* resource_context_;
230 242
231 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper); 243 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextWrapper);
232 }; 244 };
233 245
234 } // namespace content 246 } // namespace content
235 247
236 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_ 248 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WRAPPER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_context_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698