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_VERSION_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 STOPPING = EmbeddedWorkerInstance::STOPPING, | 56 STOPPING = EmbeddedWorkerInstance::STOPPING, |
57 }; | 57 }; |
58 | 58 |
59 // Current version status; some of the status (e.g. INSTALLED and ACTIVATED) | 59 // Current version status; some of the status (e.g. INSTALLED and ACTIVATED) |
60 // should be persisted unlike running status. | 60 // should be persisted unlike running status. |
61 enum Status { | 61 enum Status { |
62 NEW, // The version is just created. | 62 NEW, // The version is just created. |
63 INSTALLING, // Install event is dispatched and being handled. | 63 INSTALLING, // Install event is dispatched and being handled. |
64 INSTALLED, // Install event is finished and is ready to be activated. | 64 INSTALLED, // Install event is finished and is ready to be activated. |
65 ACTIVATING, // Activate event is dispatched and being handled. | 65 ACTIVATING, // Activate event is dispatched and being handled. |
66 ACTIVATED, // Activation is finished and can run as activated. | 66 ACTIVATED, // Activation is finished and can run as activated. |
67 REDUNDANT, // The version is no longer running as activated, due to | 67 REDUNDANT, // The version is no longer running as activated, due to |
68 // unregistration or replace. | 68 // unregistration or replace. |
69 }; | 69 }; |
70 | 70 |
71 class Listener { | 71 class Listener { |
72 public: | 72 public: |
73 virtual void OnWorkerStarted(ServiceWorkerVersion* version) {}; | 73 virtual void OnWorkerStarted(ServiceWorkerVersion* version) {} |
74 virtual void OnWorkerStopped(ServiceWorkerVersion* version) {}; | 74 virtual void OnWorkerStopped(ServiceWorkerVersion* version) {} |
75 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {}; | 75 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {} |
76 virtual void OnErrorReported(ServiceWorkerVersion* version, | 76 virtual void OnErrorReported(ServiceWorkerVersion* version, |
77 const base::string16& error_message, | 77 const base::string16& error_message, |
78 int line_number, | 78 int line_number, |
79 int column_number, | 79 int column_number, |
80 const GURL& source_url) {}; | 80 const GURL& source_url) {} |
81 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, | 81 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, |
82 int source_identifier, | 82 int source_identifier, |
83 int message_level, | 83 int message_level, |
84 const base::string16& message, | 84 const base::string16& message, |
85 int line_number, | 85 int line_number, |
86 const GURL& source_url) {}; | 86 const GURL& source_url) {} |
| 87 |
| 88 // Fires when a version transitions from having a controllee to not. |
| 89 virtual void OnNoControllees(ServiceWorkerVersion* version) {} |
| 90 |
| 91 protected: |
| 92 virtual ~Listener() {} |
87 }; | 93 }; |
88 | 94 |
89 ServiceWorkerVersion( | 95 ServiceWorkerVersion( |
90 ServiceWorkerRegistration* registration, | 96 ServiceWorkerRegistration* registration, |
91 int64 version_id, | 97 int64 version_id, |
92 base::WeakPtr<ServiceWorkerContextCore> context); | 98 base::WeakPtr<ServiceWorkerContextCore> context); |
93 | 99 |
94 int64 version_id() const { return version_id_; } | 100 int64 version_id() const { return version_id_; } |
95 int64 registration_id() const { return registration_id_; } | 101 int64 registration_id() const { return registration_id_; } |
96 const GURL& script_url() const { return script_url_; } | 102 const GURL& script_url() const { return script_url_; } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 bool is_doomed_; | 301 bool is_doomed_; |
296 | 302 |
297 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 303 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
298 | 304 |
299 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 305 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
300 }; | 306 }; |
301 | 307 |
302 } // namespace content | 308 } // namespace content |
303 | 309 |
304 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 310 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |