| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_WATCHER_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "content/browser/service_worker/service_worker_context_observer.h" | 14 #include "content/browser/service_worker/service_worker_context_core_observer.h" |
| 15 #include "content/browser/service_worker/service_worker_info.h" | 15 #include "content/browser/service_worker/service_worker_info.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 class ServiceWorkerContextWrapper; | 19 class ServiceWorkerContextWrapper; |
| 20 enum class EmbeddedWorkerStatus; | 20 enum class EmbeddedWorkerStatus; |
| 21 | 21 |
| 22 // Used to monitor the status change of the ServiceWorker registrations and | 22 // Used to monitor the status change of the ServiceWorker registrations and |
| 23 // versions in the ServiceWorkerContext from UI thread. | 23 // versions in the ServiceWorkerContext from UI thread. |
| 24 class ServiceWorkerContextWatcher | 24 class ServiceWorkerContextWatcher |
| 25 : public ServiceWorkerContextObserver, | 25 : public ServiceWorkerContextCoreObserver, |
| 26 public base::RefCountedThreadSafe<ServiceWorkerContextWatcher> { | 26 public base::RefCountedThreadSafe<ServiceWorkerContextWatcher> { |
| 27 public: | 27 public: |
| 28 typedef base::Callback<void( | 28 typedef base::Callback<void( |
| 29 const std::vector<ServiceWorkerRegistrationInfo>&)> | 29 const std::vector<ServiceWorkerRegistrationInfo>&)> |
| 30 WorkerRegistrationUpdatedCallback; | 30 WorkerRegistrationUpdatedCallback; |
| 31 typedef base::Callback<void(const std::vector<ServiceWorkerVersionInfo>&)> | 31 typedef base::Callback<void(const std::vector<ServiceWorkerVersionInfo>&)> |
| 32 WorkerVersionUpdatedCallback; | 32 WorkerVersionUpdatedCallback; |
| 33 typedef base::Callback<void(int64_t /* registration_id */, | 33 typedef base::Callback<void(int64_t /* registration_id */, |
| 34 int64_t /* version_id */, | 34 int64_t /* version_id */, |
| 35 const ErrorInfo&)> WorkerErrorReportedCallback; | 35 const ErrorInfo&)> WorkerErrorReportedCallback; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 std::unique_ptr<ServiceWorkerRegistrationInfo>>* | 58 std::unique_ptr<ServiceWorkerRegistrationInfo>>* |
| 59 info_map); | 59 info_map); |
| 60 void StoreVersionInfo(const ServiceWorkerVersionInfo& version); | 60 void StoreVersionInfo(const ServiceWorkerVersionInfo& version); |
| 61 | 61 |
| 62 void SendRegistrationInfo( | 62 void SendRegistrationInfo( |
| 63 int64_t registration_id, | 63 int64_t registration_id, |
| 64 const GURL& pattern, | 64 const GURL& pattern, |
| 65 ServiceWorkerRegistrationInfo::DeleteFlag delete_flag); | 65 ServiceWorkerRegistrationInfo::DeleteFlag delete_flag); |
| 66 void SendVersionInfo(const ServiceWorkerVersionInfo& version); | 66 void SendVersionInfo(const ServiceWorkerVersionInfo& version); |
| 67 | 67 |
| 68 // ServiceWorkerContextObserver implements | 68 // ServiceWorkerContextCoreObserver implements |
| 69 void OnNewLiveRegistration(int64_t registration_id, | 69 void OnNewLiveRegistration(int64_t registration_id, |
| 70 const GURL& pattern) override; | 70 const GURL& pattern) override; |
| 71 void OnNewLiveVersion(const ServiceWorkerVersionInfo& version_info) override; | 71 void OnNewLiveVersion(const ServiceWorkerVersionInfo& version_info) override; |
| 72 void OnRunningStateChanged( | 72 void OnRunningStateChanged( |
| 73 int64_t version_id, | 73 int64_t version_id, |
| 74 content::EmbeddedWorkerStatus running_status) override; | 74 content::EmbeddedWorkerStatus running_status) override; |
| 75 void OnVersionStateChanged( | 75 void OnVersionStateChanged( |
| 76 int64_t version_id, | 76 int64_t version_id, |
| 77 content::ServiceWorkerVersion::Status status) override; | 77 content::ServiceWorkerVersion::Status status) override; |
| 78 void OnVersionDevToolsRoutingIdChanged(int64_t version_id, | 78 void OnVersionDevToolsRoutingIdChanged(int64_t version_id, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 108 version_info_map_; | 108 version_info_map_; |
| 109 scoped_refptr<ServiceWorkerContextWrapper> context_; | 109 scoped_refptr<ServiceWorkerContextWrapper> context_; |
| 110 WorkerRegistrationUpdatedCallback registration_callback_; | 110 WorkerRegistrationUpdatedCallback registration_callback_; |
| 111 WorkerVersionUpdatedCallback version_callback_; | 111 WorkerVersionUpdatedCallback version_callback_; |
| 112 WorkerErrorReportedCallback error_callback_; | 112 WorkerErrorReportedCallback error_callback_; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace content | 115 } // namespace content |
| 116 | 116 |
| 117 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ | 117 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTEXT_WATCHER_H_ |
| OLD | NEW |