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 19 matching lines...) Expand all Loading... |
30 #ifndef ServiceWorkerGlobalScope_h | 30 #ifndef ServiceWorkerGlobalScope_h |
31 #define ServiceWorkerGlobalScope_h | 31 #define ServiceWorkerGlobalScope_h |
32 | 32 |
33 #include "bindings/modules/v8/RequestOrUSVString.h" | 33 #include "bindings/modules/v8/RequestOrUSVString.h" |
34 #include "core/workers/WorkerGlobalScope.h" | 34 #include "core/workers/WorkerGlobalScope.h" |
35 #include "modules/ModulesExport.h" | 35 #include "modules/ModulesExport.h" |
36 #include "platform/heap/Handle.h" | 36 #include "platform/heap/Handle.h" |
37 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" | 37 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" |
38 #include "wtf/Assertions.h" | 38 #include "wtf/Assertions.h" |
39 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
| 40 #include <memory> |
40 | 41 |
41 namespace blink { | 42 namespace blink { |
42 | 43 |
43 class Dictionary; | 44 class Dictionary; |
44 class Request; | 45 class Request; |
45 class ScriptPromise; | 46 class ScriptPromise; |
46 class ScriptState; | 47 class ScriptState; |
47 class ServiceWorkerClients; | 48 class ServiceWorkerClients; |
48 class ServiceWorkerRegistration; | 49 class ServiceWorkerRegistration; |
49 class ServiceWorkerThread; | 50 class ServiceWorkerThread; |
50 class WaitUntilObserver; | 51 class WaitUntilObserver; |
51 class WorkerThreadStartupData; | 52 class WorkerThreadStartupData; |
52 | 53 |
53 typedef RequestOrUSVString RequestInfo; | 54 typedef RequestOrUSVString RequestInfo; |
54 | 55 |
55 class MODULES_EXPORT ServiceWorkerGlobalScope final : public WorkerGlobalScope { | 56 class MODULES_EXPORT ServiceWorkerGlobalScope final : public WorkerGlobalScope { |
56 DEFINE_WRAPPERTYPEINFO(); | 57 DEFINE_WRAPPERTYPEINFO(); |
57 public: | 58 public: |
58 static ServiceWorkerGlobalScope* create(ServiceWorkerThread*, PassOwnPtr<Wor
kerThreadStartupData>); | 59 static ServiceWorkerGlobalScope* create(ServiceWorkerThread*, std::unique_pt
r<WorkerThreadStartupData>); |
59 | 60 |
60 ~ServiceWorkerGlobalScope() override; | 61 ~ServiceWorkerGlobalScope() override; |
61 bool isServiceWorkerGlobalScope() const override { return true; } | 62 bool isServiceWorkerGlobalScope() const override { return true; } |
62 | 63 |
63 // WorkerGlobalScope | 64 // WorkerGlobalScope |
64 void didEvaluateWorkerScript() override; | 65 void didEvaluateWorkerScript() override; |
65 | 66 |
66 // ServiceWorkerGlobalScope.idl | 67 // ServiceWorkerGlobalScope.idl |
67 ServiceWorkerClients* clients(); | 68 ServiceWorkerClients* clients(); |
68 ServiceWorkerRegistration* registration(); | 69 ServiceWorkerRegistration* registration(); |
(...skipping 16 matching lines...) Expand all Loading... |
85 DEFINE_ATTRIBUTE_EVENT_LISTENER(foreignfetch); | 86 DEFINE_ATTRIBUTE_EVENT_LISTENER(foreignfetch); |
86 | 87 |
87 DECLARE_VIRTUAL_TRACE(); | 88 DECLARE_VIRTUAL_TRACE(); |
88 | 89 |
89 protected: | 90 protected: |
90 // EventTarget | 91 // EventTarget |
91 DispatchEventResult dispatchEventInternal(Event*) override; | 92 DispatchEventResult dispatchEventInternal(Event*) override; |
92 bool addEventListenerInternal(const AtomicString& eventType, EventListener*,
const AddEventListenerOptions&) override; | 93 bool addEventListenerInternal(const AtomicString& eventType, EventListener*,
const AddEventListenerOptions&) override; |
93 | 94 |
94 private: | 95 private: |
95 ServiceWorkerGlobalScope(const KURL&, const String& userAgent, ServiceWorker
Thread*, double timeOrigin, PassOwnPtr<SecurityOrigin::PrivilegeData>, WorkerCli
ents*); | 96 ServiceWorkerGlobalScope(const KURL&, const String& userAgent, ServiceWorker
Thread*, double timeOrigin, std::unique_ptr<SecurityOrigin::PrivilegeData>, Work
erClients*); |
96 void importScripts(const Vector<String>& urls, ExceptionState&) override; | 97 void importScripts(const Vector<String>& urls, ExceptionState&) override; |
97 CachedMetadataHandler* createWorkerScriptCachedMetadataHandler(const KURL& s
criptURL, const Vector<char>* metaData) override; | 98 CachedMetadataHandler* createWorkerScriptCachedMetadataHandler(const KURL& s
criptURL, const Vector<char>* metaData) override; |
98 void logExceptionToConsole(const String& errorMessage, PassOwnPtr<SourceLoca
tion>) override; | 99 void logExceptionToConsole(const String& errorMessage, std::unique_ptr<Sourc
eLocation>) override; |
99 void scriptLoaded(size_t scriptSize, size_t cachedMetadataSize) override; | 100 void scriptLoaded(size_t scriptSize, size_t cachedMetadataSize) override; |
100 | 101 |
101 Member<ServiceWorkerClients> m_clients; | 102 Member<ServiceWorkerClients> m_clients; |
102 Member<ServiceWorkerRegistration> m_registration; | 103 Member<ServiceWorkerRegistration> m_registration; |
103 bool m_didEvaluateScript; | 104 bool m_didEvaluateScript; |
104 bool m_hadErrorInTopLevelEventHandler; | 105 bool m_hadErrorInTopLevelEventHandler; |
105 unsigned m_eventNestingLevel; | 106 unsigned m_eventNestingLevel; |
106 size_t m_scriptCount; | 107 size_t m_scriptCount; |
107 size_t m_scriptTotalSize; | 108 size_t m_scriptTotalSize; |
108 size_t m_scriptCachedMetadataTotalSize; | 109 size_t m_scriptCachedMetadataTotalSize; |
109 }; | 110 }; |
110 | 111 |
111 DEFINE_TYPE_CASTS(ServiceWorkerGlobalScope, ExecutionContext, context, context->
isServiceWorkerGlobalScope(), context.isServiceWorkerGlobalScope()); | 112 DEFINE_TYPE_CASTS(ServiceWorkerGlobalScope, ExecutionContext, context, context->
isServiceWorkerGlobalScope(), context.isServiceWorkerGlobalScope()); |
112 | 113 |
113 } // namespace blink | 114 } // namespace blink |
114 | 115 |
115 #endif // ServiceWorkerGlobalScope_h | 116 #endif // ServiceWorkerGlobalScope_h |
OLD | NEW |