| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "bindings/core/v8/SerializedScriptValue.h" | 36 #include "bindings/core/v8/SerializedScriptValue.h" |
| 37 #include "core/workers/AbstractWorker.h" | 37 #include "core/workers/AbstractWorker.h" |
| 38 #include "modules/ModulesExport.h" | 38 #include "modules/ModulesExport.h" |
| 39 #include "public/platform/modules/serviceworker/WebServiceWorker.h" | 39 #include "public/platform/modules/serviceworker/WebServiceWorker.h" |
| 40 #include "public/platform/modules/serviceworker/WebServiceWorkerProxy.h" | 40 #include "public/platform/modules/serviceworker/WebServiceWorkerProxy.h" |
| 41 #include "wtf/PassRefPtr.h" | 41 #include "wtf/PassRefPtr.h" |
| 42 #include <memory> | 42 #include <memory> |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 class NavigationPreloadOptions; |
| 46 class ScriptPromiseResolver; | 47 class ScriptPromiseResolver; |
| 47 | 48 |
| 48 class MODULES_EXPORT ServiceWorker final : public AbstractWorker, | 49 class MODULES_EXPORT ServiceWorker final : public AbstractWorker, |
| 49 public ActiveScriptWrappable, | 50 public ActiveScriptWrappable, |
| 50 public WebServiceWorkerProxy { | 51 public WebServiceWorkerProxy { |
| 51 DEFINE_WRAPPERTYPEINFO(); | 52 DEFINE_WRAPPERTYPEINFO(); |
| 52 USING_GARBAGE_COLLECTED_MIXIN(ServiceWorker); | 53 USING_GARBAGE_COLLECTED_MIXIN(ServiceWorker); |
| 53 | 54 |
| 54 public: | 55 public: |
| 55 static ServiceWorker* from(ExecutionContext*, | 56 static ServiceWorker* from(ExecutionContext*, |
| 56 std::unique_ptr<WebServiceWorker::Handle>); | 57 std::unique_ptr<WebServiceWorker::Handle>); |
| 57 | 58 |
| 58 ~ServiceWorker() override; | 59 ~ServiceWorker() override; |
| 59 DECLARE_VIRTUAL_TRACE(); | 60 DECLARE_VIRTUAL_TRACE(); |
| 60 | 61 |
| 61 // Eager finalization needed to promptly release owned WebServiceWorker. | 62 // Eager finalization needed to promptly release owned WebServiceWorker. |
| 62 EAGERLY_FINALIZE(); | 63 EAGERLY_FINALIZE(); |
| 63 | 64 |
| 64 void postMessage(ExecutionContext*, | 65 void postMessage(ExecutionContext*, |
| 65 PassRefPtr<SerializedScriptValue> message, | 66 PassRefPtr<SerializedScriptValue> message, |
| 66 const MessagePortArray&, | 67 const MessagePortArray&, |
| 67 ExceptionState&); | 68 ExceptionState&); |
| 68 | 69 |
| 69 String scriptURL() const; | 70 String scriptURL() const; |
| 70 String state() const; | 71 String state() const; |
| 71 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 72 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
| 72 | 73 |
| 74 ScriptPromise getNavigationPreload(ScriptState*); |
| 75 ScriptPromise setNavigationPreload(ScriptState*, |
| 76 const NavigationPreloadOptions&); |
| 77 |
| 73 // ScriptWrappable overrides. | 78 // ScriptWrappable overrides. |
| 74 bool hasPendingActivity() const final; | 79 bool hasPendingActivity() const final; |
| 75 | 80 |
| 76 // WebServiceWorkerProxy overrides. | 81 // WebServiceWorkerProxy overrides. |
| 77 void dispatchStateChangeEvent() override; | 82 void dispatchStateChangeEvent() override; |
| 78 | 83 |
| 79 // AbstractWorker overrides. | 84 // AbstractWorker overrides. |
| 80 const AtomicString& interfaceName() const override; | 85 const AtomicString& interfaceName() const override; |
| 81 | 86 |
| 82 void internalsTerminate(); | 87 void internalsTerminate(); |
| 83 | 88 |
| 84 private: | 89 private: |
| 85 static ServiceWorker* getOrCreate(ExecutionContext*, | 90 static ServiceWorker* getOrCreate(ExecutionContext*, |
| 86 std::unique_ptr<WebServiceWorker::Handle>); | 91 std::unique_ptr<WebServiceWorker::Handle>); |
| 87 ServiceWorker(ExecutionContext*, std::unique_ptr<WebServiceWorker::Handle>); | 92 ServiceWorker(ExecutionContext*, std::unique_ptr<WebServiceWorker::Handle>); |
| 88 | 93 |
| 89 // ActiveDOMObject overrides. | 94 // ActiveDOMObject overrides. |
| 90 void stop() override; | 95 void stop() override; |
| 91 | 96 |
| 92 // A handle to the service worker representation in the embedder. | 97 // A handle to the service worker representation in the embedder. |
| 93 std::unique_ptr<WebServiceWorker::Handle> m_handle; | 98 std::unique_ptr<WebServiceWorker::Handle> m_handle; |
| 94 bool m_wasStopped; | 99 bool m_wasStopped; |
| 95 }; | 100 }; |
| 96 | 101 |
| 97 } // namespace blink | 102 } // namespace blink |
| 98 | 103 |
| 99 #endif // ServiceWorker_h | 104 #endif // ServiceWorker_h |
| OLD | NEW |