OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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_VERSION_H_ | |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/gtest_prod_util.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "content/common/content_export.h" | |
12 | |
13 class GURL; | |
14 | |
15 namespace content { | |
16 | |
17 class ServiceWorkerRegistration; | |
18 | |
19 // This class corresponds to a specific version of a ServiceWorker | |
20 // script for a given pattern. When a script is upgraded, there may be | |
21 // more than one ServiceWorkerVersion "running" at a time, but only | |
22 // one of them is active. This class connects the actual script with a | |
23 // running worker. | |
24 // Instances of this class are in one of two install states: | |
25 // - Pending: The script is in the process of being installed. There | |
26 // may be another active script running. | |
27 // - Active: The script is the only worker handling requests for the | |
28 // registration's pattern. | |
29 // | |
30 // In addition, a version has a running state (this is a rough | |
31 // sketch). Since a service worker can be stopped and started at any | |
32 // time, it will transition among these states multiple times during | |
33 // its lifetime. | |
34 // - Stopped: The script is not running | |
35 // - Starting: A request to fire an event against the version has been | |
36 // queued, but the worker is not yet | |
37 // loaded/initialized/etc. | |
38 // - Started: The worker is ready to receive events | |
39 // - Stopping: The worker is returning to the stopped state. | |
40 // | |
41 // The worker can "run" in both the Pending and the Active | |
42 // install states above. During the Pending state, the worker is only | |
43 // started in order to fire the 'install' and 'activate' | |
44 // events. During the Active state, it can receive other events such | |
45 // as 'fetch'. | |
46 // | |
47 // And finally, is_shutdown_ is detects the live-ness of the object | |
48 // itself. If the object is shut down, then it is in the process of | |
49 // being deleted from memory. This happens when a version is replaced | |
50 // as well as at browser shutdown. | |
51 class CONTENT_EXPORT ServiceWorkerVersion | |
52 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>) { | |
53 public: | |
54 explicit ServiceWorkerVersion( | |
55 scoped_refptr<ServiceWorkerRegistration> registration); | |
michaeln
2013/11/14 22:30:55
and here
| |
56 | |
57 void Shutdown(); | |
michaeln
2013/11/14 22:30:55
I think we expect the only callsite for Shutdown()
| |
58 bool is_shutdown() const { return is_shutdown_; } | |
59 | |
60 private: | |
61 ~ServiceWorkerVersion(); | |
62 friend class base::RefCounted<ServiceWorkerVersion>; | |
63 | |
64 bool is_shutdown_; | |
65 scoped_refptr<ServiceWorkerRegistration> registration_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | |
68 }; | |
69 } // namespace content | |
70 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | |
OLD | NEW |