OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 NavigatorServiceWorker_h | 5 #ifndef NavigatorServiceWorker_h |
6 #define NavigatorServiceWorker_h | 6 #define NavigatorServiceWorker_h |
7 | 7 |
8 #include "core/dom/ContextLifecycleObserver.h" | |
9 #include "core/frame/Navigator.h" | 8 #include "core/frame/Navigator.h" |
10 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
11 #include "platform/Supplementable.h" | 10 #include "platform/Supplementable.h" |
12 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
13 | 12 |
14 namespace blink { | 13 namespace blink { |
15 | 14 |
16 class Document; | 15 class Document; |
17 class ExceptionState; | 16 class ExceptionState; |
18 class Navigator; | 17 class Navigator; |
19 class ServiceWorkerContainer; | 18 class ServiceWorkerContainer; |
20 | 19 |
21 class MODULES_EXPORT NavigatorServiceWorker final | 20 class MODULES_EXPORT NavigatorServiceWorker final |
22 : public GarbageCollected<NavigatorServiceWorker>, | 21 : public GarbageCollected<NavigatorServiceWorker>, |
23 public Supplement<Navigator>, | 22 public Supplement<Navigator> { |
24 public ContextLifecycleObserver { | |
25 USING_GARBAGE_COLLECTED_MIXIN(NavigatorServiceWorker); | 23 USING_GARBAGE_COLLECTED_MIXIN(NavigatorServiceWorker); |
26 | 24 |
27 public: | 25 public: |
28 static NavigatorServiceWorker* from(Document&); | 26 static NavigatorServiceWorker* from(Document&); |
29 static NavigatorServiceWorker& from(Navigator&); | 27 static NavigatorServiceWorker& from(Navigator&); |
30 static NavigatorServiceWorker* toNavigatorServiceWorker(Navigator&); | 28 static NavigatorServiceWorker* toNavigatorServiceWorker(Navigator&); |
31 static ServiceWorkerContainer* serviceWorker(ExecutionContext*, | 29 static ServiceWorkerContainer* serviceWorker(ExecutionContext*, |
32 Navigator&, | 30 Navigator&, |
33 ExceptionState&); | 31 ExceptionState&); |
34 static ServiceWorkerContainer* serviceWorker(ExecutionContext*, | 32 static ServiceWorkerContainer* serviceWorker(ExecutionContext*, |
35 Navigator&, | 33 Navigator&, |
36 String& errorMessage); | 34 String& errorMessage); |
| 35 void clearServiceWorker(); |
37 | 36 |
38 DECLARE_VIRTUAL_TRACE(); | 37 DECLARE_VIRTUAL_TRACE(); |
39 | 38 |
40 private: | 39 private: |
41 explicit NavigatorServiceWorker(Navigator&); | 40 explicit NavigatorServiceWorker(Navigator&); |
42 ServiceWorkerContainer* serviceWorker(LocalFrame*, ExceptionState&); | 41 ServiceWorkerContainer* serviceWorker(LocalFrame*, ExceptionState&); |
43 ServiceWorkerContainer* serviceWorker(LocalFrame*, String& errorMessage); | 42 ServiceWorkerContainer* serviceWorker(LocalFrame*, String& errorMessage); |
44 | 43 |
45 static const char* supplementName(); | 44 static const char* supplementName(); |
46 | 45 |
47 // ContextLifecycleObserver override. | |
48 void contextDestroyed() override; | |
49 | |
50 Member<ServiceWorkerContainer> m_serviceWorker; | 46 Member<ServiceWorkerContainer> m_serviceWorker; |
51 }; | 47 }; |
52 | 48 |
53 } // namespace blink | 49 } // namespace blink |
54 | 50 |
55 #endif // NavigatorServiceWorker_h | 51 #endif // NavigatorServiceWorker_h |
OLD | NEW |