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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef ServiceWorkerGlobalScopeProxy_h | 31 #ifndef ServiceWorkerGlobalScopeProxy_h |
32 #define ServiceWorkerGlobalScopeProxy_h | 32 #define ServiceWorkerGlobalScopeProxy_h |
33 | 33 |
34 #include "core/workers/WorkerReportingProxy.h" | 34 #include "core/workers/WorkerReportingProxy.h" |
35 #include "platform/heap/Handle.h" | 35 #include "platform/heap/Handle.h" |
| 36 #include "platform/heap/HeapAllocator.h" |
36 #include "platform/weborigin/KURL.h" | 37 #include "platform/weborigin/KURL.h" |
37 #include "public/platform/WebString.h" | 38 #include "public/platform/WebString.h" |
38 #include "public/web/modules/serviceworker/WebServiceWorkerContextProxy.h" | 39 #include "public/web/modules/serviceworker/WebServiceWorkerContextProxy.h" |
39 #include "wtf/Forward.h" | 40 #include "wtf/Forward.h" |
40 #include <memory> | 41 #include <memory> |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
44 class ConsoleMessage; | 45 class ConsoleMessage; |
45 class Document; | 46 class Document; |
| 47 class FetchEvent; |
46 class ServiceWorkerGlobalScope; | 48 class ServiceWorkerGlobalScope; |
| 49 class WebDataConsumerHandle; |
47 class WebEmbeddedWorkerImpl; | 50 class WebEmbeddedWorkerImpl; |
48 class WebServiceWorkerContextClient; | 51 class WebServiceWorkerContextClient; |
| 52 struct WebServiceWorkerError; |
49 class WebServiceWorkerRequest; | 53 class WebServiceWorkerRequest; |
| 54 class WebServiceWorkerResponse; |
50 | 55 |
51 // This class is created and destructed on the main thread, but live most | 56 // This class is created and destructed on the main thread, but live most |
52 // of its time as a resident of the worker thread. | 57 // of its time as a resident of the worker thread. |
53 // All methods other than its ctor/dtor are called on the worker thread. | 58 // All methods other than its ctor/dtor are called on the worker thread. |
54 // | 59 // |
55 // This implements WebServiceWorkerContextProxy, which connects ServiceWorker's | 60 // This implements WebServiceWorkerContextProxy, which connects ServiceWorker's |
56 // WorkerGlobalScope and embedder/chrome, and implements ServiceWorker-specific | 61 // WorkerGlobalScope and embedder/chrome, and implements ServiceWorker-specific |
57 // events/upcall methods that are to be called by embedder/chromium, | 62 // events/upcall methods that are to be called by embedder/chromium, |
58 // e.g. onfetch. | 63 // e.g. onfetch. |
59 // | 64 // |
(...skipping 22 matching lines...) Expand all Loading... |
82 const WebSecurityOrigin& sourceOrigin, | 87 const WebSecurityOrigin& sourceOrigin, |
83 const WebMessagePortChannelArray&, | 88 const WebMessagePortChannelArray&, |
84 const WebServiceWorkerClientInfo&) override; | 89 const WebServiceWorkerClientInfo&) override; |
85 void dispatchExtendableMessageEvent( | 90 void dispatchExtendableMessageEvent( |
86 int eventID, | 91 int eventID, |
87 const WebString& message, | 92 const WebString& message, |
88 const WebSecurityOrigin& sourceOrigin, | 93 const WebSecurityOrigin& sourceOrigin, |
89 const WebMessagePortChannelArray&, | 94 const WebMessagePortChannelArray&, |
90 std::unique_ptr<WebServiceWorker::Handle>) override; | 95 std::unique_ptr<WebServiceWorker::Handle>) override; |
91 void dispatchFetchEvent(int fetchEventID, | 96 void dispatchFetchEvent(int fetchEventID, |
92 const WebServiceWorkerRequest&) override; | 97 const WebServiceWorkerRequest&, |
| 98 bool navigationPreloadSent) override; |
93 void dispatchForeignFetchEvent(int fetchEventID, | 99 void dispatchForeignFetchEvent(int fetchEventID, |
94 const WebServiceWorkerRequest&) override; | 100 const WebServiceWorkerRequest&) override; |
95 void dispatchInstallEvent(int) override; | 101 void dispatchInstallEvent(int) override; |
96 void dispatchNotificationClickEvent(int, | 102 void dispatchNotificationClickEvent(int, |
97 const WebString& notificationID, | 103 const WebString& notificationID, |
98 const WebNotificationData&, | 104 const WebNotificationData&, |
99 int actionIndex, | 105 int actionIndex, |
100 const WebString& reply) override; | 106 const WebString& reply) override; |
101 void dispatchNotificationCloseEvent(int, | 107 void dispatchNotificationCloseEvent(int, |
102 const WebString& notificationID, | 108 const WebString& notificationID, |
103 const WebNotificationData&) override; | 109 const WebNotificationData&) override; |
104 void dispatchPushEvent(int, const WebString& data) override; | 110 void dispatchPushEvent(int, const WebString& data) override; |
105 void dispatchSyncEvent(int, const WebString& tag, LastChanceOption) override; | 111 void dispatchSyncEvent(int, const WebString& tag, LastChanceOption) override; |
106 bool hasFetchEventHandler() override; | 112 bool hasFetchEventHandler() override; |
| 113 void onNavigationPreloadResponse( |
| 114 int fetchEventID, |
| 115 std::unique_ptr<WebServiceWorkerResponse>, |
| 116 std::unique_ptr<WebDataConsumerHandle>) override; |
| 117 void onNavigationPreloadError( |
| 118 int fetchEventID, |
| 119 std::unique_ptr<WebServiceWorkerError>) override; |
107 | 120 |
108 // WorkerReportingProxy overrides: | 121 // WorkerReportingProxy overrides: |
109 void reportException(const String& errorMessage, | 122 void reportException(const String& errorMessage, |
110 std::unique_ptr<SourceLocation>, | 123 std::unique_ptr<SourceLocation>, |
111 int exceptionId) override; | 124 int exceptionId) override; |
112 void reportConsoleMessage(MessageSource, | 125 void reportConsoleMessage(MessageSource, |
113 MessageLevel, | 126 MessageLevel, |
114 const String& message, | 127 const String& message, |
115 SourceLocation*) override; | 128 SourceLocation*) override; |
116 void postMessageToPageInspector(const String&) override; | 129 void postMessageToPageInspector(const String&) override; |
(...skipping 24 matching lines...) Expand all Loading... |
141 | 154 |
142 WebServiceWorkerContextClient& client() const; | 155 WebServiceWorkerContextClient& client() const; |
143 Document& document() const; | 156 Document& document() const; |
144 ServiceWorkerGlobalScope* workerGlobalScope() const; | 157 ServiceWorkerGlobalScope* workerGlobalScope() const; |
145 | 158 |
146 // Non-null until the WebEmbeddedWorkerImpl explicitly detach()es | 159 // Non-null until the WebEmbeddedWorkerImpl explicitly detach()es |
147 // as part of its finalization. | 160 // as part of its finalization. |
148 WebEmbeddedWorkerImpl* m_embeddedWorker; | 161 WebEmbeddedWorkerImpl* m_embeddedWorker; |
149 Member<Document> m_document; | 162 Member<Document> m_document; |
150 | 163 |
| 164 HeapHashMap<int, Member<FetchEvent>> m_pendingPreloadFetchEvents; |
| 165 |
151 WebServiceWorkerContextClient* m_client; | 166 WebServiceWorkerContextClient* m_client; |
152 | 167 |
153 CrossThreadPersistent<ServiceWorkerGlobalScope> m_workerGlobalScope; | 168 CrossThreadPersistent<ServiceWorkerGlobalScope> m_workerGlobalScope; |
154 }; | 169 }; |
155 | 170 |
156 } // namespace blink | 171 } // namespace blink |
157 | 172 |
158 #endif // ServiceWorkerGlobalScopeProxy_h | 173 #endif // ServiceWorkerGlobalScopeProxy_h |
OLD | NEW |