Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ | |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/containers/scoped_ptr_hash_map.h" | |
| 12 #include "content/browser/service_worker/service_worker_context_observer.h" | |
| 13 #include "content/browser/service_worker/service_worker_info.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class ServiceWorkerContextWrapper; | |
| 18 | |
| 19 class ServiceWorkerContextWatcher | |
|
kinuko
2015/03/13 09:09:21
nit: now that it has its own header can we have a
horo
2015/03/13 10:03:50
Done.
| |
| 20 : public ServiceWorkerContextObserver, | |
| 21 public base::RefCountedThreadSafe<ServiceWorkerContextWatcher> { | |
| 22 public: | |
| 23 typedef base::Callback<void( | |
| 24 const std::vector<ServiceWorkerRegistrationInfo>&)> | |
| 25 WorkerRegistrationUpdatedCallback; | |
| 26 typedef base::Callback<void(const std::vector<ServiceWorkerVersionInfo>&)> | |
| 27 WorkerVersionUpdatedCallback; | |
| 28 ServiceWorkerContextWatcher( | |
| 29 scoped_refptr<ServiceWorkerContextWrapper> context, | |
| 30 const WorkerRegistrationUpdatedCallback& registration_callback, | |
| 31 const WorkerVersionUpdatedCallback& version_callback); | |
| 32 void Start(); | |
| 33 void Stop(); | |
| 34 | |
| 35 private: | |
| 36 friend class base::RefCountedThreadSafe<ServiceWorkerContextWatcher>; | |
| 37 ~ServiceWorkerContextWatcher() override; | |
| 38 | |
| 39 void GetStoredRegistrationsOnIOThread(); | |
| 40 void OnStoredRegistrationsOnIOThread( | |
| 41 const std::vector<ServiceWorkerRegistrationInfo>& stored_registrations); | |
| 42 void StopOnIOThread(); | |
| 43 | |
| 44 void StoreRegistrationInfo( | |
| 45 const ServiceWorkerRegistrationInfo& registration, | |
| 46 base::ScopedPtrHashMap<int64, ServiceWorkerRegistrationInfo>* info_map); | |
| 47 void StoreVersionInfo(const ServiceWorkerVersionInfo& version); | |
| 48 | |
| 49 void SendRegistrationInfo(int64 registration_id, | |
| 50 const GURL& pattern, | |
| 51 bool is_deleted); | |
| 52 void SendVersionInfo(const ServiceWorkerVersionInfo& version); | |
| 53 | |
| 54 // ServiceWorkerContextObserver implements | |
| 55 void OnNewLiveRegistration(int64 registration_id, | |
| 56 const GURL& pattern) override; | |
| 57 void OnNewLiveVersion(int64 version_id, | |
| 58 int64 registration_id, | |
| 59 const GURL& script_url) override; | |
| 60 void OnRunningStateChanged( | |
| 61 int64 version_id, | |
| 62 content::ServiceWorkerVersion::RunningStatus running_status) override; | |
| 63 void OnVersionStateChanged( | |
| 64 int64 version_id, | |
| 65 content::ServiceWorkerVersion::Status status) override; | |
| 66 void OnRegistrationStored(int64 registration_id, | |
| 67 const GURL& pattern) override; | |
| 68 void OnRegistrationDeleted(int64 registration_id, | |
| 69 const GURL& pattern) override; | |
| 70 | |
| 71 base::ScopedPtrHashMap<int64, ServiceWorkerVersionInfo> version_info_map_; | |
| 72 scoped_refptr<ServiceWorkerContextWrapper> context_; | |
| 73 WorkerRegistrationUpdatedCallback registration_callback_; | |
| 74 WorkerVersionUpdatedCallback version_callback_; | |
| 75 }; | |
| 76 | |
| 77 } // namespace content | |
| 78 | |
| 79 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ | |
| OLD | NEW |