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_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 <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 // This class maintains collections of live instances, this class | 186 // This class maintains collections of live instances, this class |
187 // does not own these object or influence their lifetime. | 187 // does not own these object or influence their lifetime. |
188 ServiceWorkerRegistration* GetLiveRegistration(int64 registration_id); | 188 ServiceWorkerRegistration* GetLiveRegistration(int64 registration_id); |
189 void AddLiveRegistration(ServiceWorkerRegistration* registration); | 189 void AddLiveRegistration(ServiceWorkerRegistration* registration); |
190 void RemoveLiveRegistration(int64 registration_id); | 190 void RemoveLiveRegistration(int64 registration_id); |
191 const std::map<int64, ServiceWorkerRegistration*>& GetLiveRegistrations() | 191 const std::map<int64, ServiceWorkerRegistration*>& GetLiveRegistrations() |
192 const { | 192 const { |
193 return live_registrations_; | 193 return live_registrations_; |
194 } | 194 } |
195 ServiceWorkerVersion* GetLiveVersion(int64 version_id); | 195 ServiceWorkerVersion* GetLiveVersion(std::string version_uuid); |
196 void AddLiveVersion(ServiceWorkerVersion* version); | 196 void AddLiveVersion(ServiceWorkerVersion* version); |
197 void RemoveLiveVersion(int64 registration_id); | 197 void RemoveLiveVersion(std::string version_uuid); |
198 const std::map<int64, ServiceWorkerVersion*>& GetLiveVersions() const { | 198 const std::map<std::string, ServiceWorkerVersion*>& GetLiveVersions() const { |
199 return live_versions_; | 199 return live_versions_; |
200 } | 200 } |
201 | 201 |
202 std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo(); | 202 std::vector<ServiceWorkerRegistrationInfo> GetAllLiveRegistrationInfo(); |
203 std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo(); | 203 std::vector<ServiceWorkerVersionInfo> GetAllLiveVersionInfo(); |
204 | 204 |
205 // ProtectVersion holds a reference to |version| until UnprotectVersion is | 205 // ProtectVersion holds a reference to |version| until UnprotectVersion is |
206 // called. | 206 // called. |
207 void ProtectVersion(const scoped_refptr<ServiceWorkerVersion>& version); | 207 void ProtectVersion(const scoped_refptr<ServiceWorkerVersion>& version); |
208 void UnprotectVersion(int64 version_id); | 208 void UnprotectVersion(std::string version_uuid); |
209 | 209 |
210 // Returns new context-local unique ID. | 210 // Returns new context-local unique ID. |
211 int GetNewServiceWorkerHandleId(); | 211 int GetNewServiceWorkerHandleId(); |
212 int GetNewRegistrationHandleId(); | 212 int GetNewRegistrationHandleId(); |
213 | 213 |
214 void ScheduleDeleteAndStartOver() const; | 214 void ScheduleDeleteAndStartOver() const; |
215 | 215 |
216 // Deletes all files on disk and restarts the system. This leaves the system | 216 // Deletes all files on disk and restarts the system. This leaves the system |
217 // in a disabled state until it's done. | 217 // in a disabled state until it's done. |
218 void DeleteAndStartOver(const StatusCallback& callback); | 218 void DeleteAndStartOver(const StatusCallback& callback); |
219 | 219 |
220 // Methods to support cross site navigations. | 220 // Methods to support cross site navigations. |
221 scoped_ptr<ServiceWorkerProviderHost> TransferProviderHostOut( | 221 scoped_ptr<ServiceWorkerProviderHost> TransferProviderHostOut( |
222 int process_id, | 222 int process_id, |
223 int provider_id); | 223 int provider_id); |
224 void TransferProviderHostIn( | 224 void TransferProviderHostIn( |
225 int new_process_id, | 225 int new_process_id, |
226 int new_host_id, | 226 int new_host_id, |
227 scoped_ptr<ServiceWorkerProviderHost> provider_host); | 227 scoped_ptr<ServiceWorkerProviderHost> provider_host); |
228 | 228 |
229 base::WeakPtr<ServiceWorkerContextCore> AsWeakPtr() { | 229 base::WeakPtr<ServiceWorkerContextCore> AsWeakPtr() { |
230 return weak_factory_.GetWeakPtr(); | 230 return weak_factory_.GetWeakPtr(); |
231 } | 231 } |
232 | 232 |
233 private: | 233 private: |
234 friend class ServiceWorkerContext; | 234 friend class ServiceWorkerContext; |
235 typedef std::map<int64, ServiceWorkerRegistration*> RegistrationsMap; | 235 typedef std::map<int64, ServiceWorkerRegistration*> RegistrationsMap; |
236 typedef std::map<int64, ServiceWorkerVersion*> VersionMap; | 236 typedef std::map<std::string, ServiceWorkerVersion*> VersionMap; |
237 | 237 |
238 ProviderMap* GetProviderMapForProcess(int process_id) { | 238 ProviderMap* GetProviderMapForProcess(int process_id) { |
239 return providers_->Lookup(process_id); | 239 return providers_->Lookup(process_id); |
240 } | 240 } |
241 | 241 |
242 void RegistrationComplete(const GURL& pattern, | 242 void RegistrationComplete(const GURL& pattern, |
243 const RegistrationCallback& callback, | 243 const RegistrationCallback& callback, |
244 ServiceWorkerStatusCode status, | 244 ServiceWorkerStatusCode status, |
245 const std::string& status_message, | 245 const std::string& status_message, |
246 ServiceWorkerRegistration* registration); | 246 ServiceWorkerRegistration* registration); |
(...skipping 11 matching lines...) Expand all Loading... |
258 // It's safe to store a raw pointer instead of a scoped_refptr to |wrapper_| | 258 // It's safe to store a raw pointer instead of a scoped_refptr to |wrapper_| |
259 // because the Wrapper::Shutdown call that hops threads to destroy |this| uses | 259 // because the Wrapper::Shutdown call that hops threads to destroy |this| uses |
260 // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed. | 260 // Bind() to hold a reference to |wrapper_| until |this| is fully destroyed. |
261 ServiceWorkerContextWrapper* wrapper_; | 261 ServiceWorkerContextWrapper* wrapper_; |
262 scoped_ptr<ProcessToProviderMap> providers_; | 262 scoped_ptr<ProcessToProviderMap> providers_; |
263 scoped_ptr<ProviderByClientUUIDMap> provider_by_uuid_; | 263 scoped_ptr<ProviderByClientUUIDMap> provider_by_uuid_; |
264 scoped_ptr<ServiceWorkerStorage> storage_; | 264 scoped_ptr<ServiceWorkerStorage> storage_; |
265 scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; | 265 scoped_refptr<EmbeddedWorkerRegistry> embedded_worker_registry_; |
266 scoped_ptr<ServiceWorkerJobCoordinator> job_coordinator_; | 266 scoped_ptr<ServiceWorkerJobCoordinator> job_coordinator_; |
267 std::map<int64, ServiceWorkerRegistration*> live_registrations_; | 267 std::map<int64, ServiceWorkerRegistration*> live_registrations_; |
268 std::map<int64, ServiceWorkerVersion*> live_versions_; | 268 std::map<std::string, ServiceWorkerVersion*> live_versions_; |
269 std::map<int64, scoped_refptr<ServiceWorkerVersion>> protected_versions_; | 269 std::map<std::string, scoped_refptr<ServiceWorkerVersion>> |
| 270 protected_versions_; |
270 int next_handle_id_; | 271 int next_handle_id_; |
271 int next_registration_handle_id_; | 272 int next_registration_handle_id_; |
272 scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextObserver>> | 273 scoped_refptr<base::ObserverListThreadSafe<ServiceWorkerContextObserver>> |
273 observer_list_; | 274 observer_list_; |
274 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_; | 275 base::WeakPtrFactory<ServiceWorkerContextCore> weak_factory_; |
275 | 276 |
276 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore); | 277 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextCore); |
277 }; | 278 }; |
278 | 279 |
279 } // namespace content | 280 } // namespace content |
280 | 281 |
281 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ | 282 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_CORE_H_ |
OLD | NEW |