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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // | 55 // |
56 // This implements WebServiceWorkerContextProxy, which connects ServiceWorker's | 56 // This implements WebServiceWorkerContextProxy, which connects ServiceWorker's |
57 // WorkerGlobalScope and embedder/chrome, and implements ServiceWorker-specific | 57 // WorkerGlobalScope and embedder/chrome, and implements ServiceWorker-specific |
58 // events/upcall methods that are to be called by embedder/chromium, | 58 // events/upcall methods that are to be called by embedder/chromium, |
59 // e.g. onfetch. | 59 // e.g. onfetch. |
60 // | 60 // |
61 // An instance of this class is supposed to outlive until | 61 // An instance of this class is supposed to outlive until |
62 // workerThreadTerminated() is called by its corresponding | 62 // workerThreadTerminated() is called by its corresponding |
63 // WorkerGlobalScope. | 63 // WorkerGlobalScope. |
64 class ServiceWorkerGlobalScopeProxy final | 64 class ServiceWorkerGlobalScopeProxy final |
65 : public WebServiceWorkerContextProxy | 65 : public NoBaseWillBeGarbageCollectedFinalized<ServiceWorkerGlobalScopeProxy
> |
| 66 , public WebServiceWorkerContextProxy |
66 , public WorkerReportingProxy { | 67 , public WorkerReportingProxy { |
67 WTF_MAKE_NONCOPYABLE(ServiceWorkerGlobalScopeProxy); | 68 WTF_MAKE_NONCOPYABLE(ServiceWorkerGlobalScopeProxy); |
68 USING_FAST_MALLOC(ServiceWorkerGlobalScopeProxy); | 69 USING_FAST_MALLOC_WILL_BE_REMOVED(ServiceWorkerGlobalScopeProxy); |
69 public: | 70 public: |
70 static PassOwnPtr<ServiceWorkerGlobalScopeProxy> create(WebEmbeddedWorkerImp
l&, Document&, WebServiceWorkerContextClient&); | 71 static PassOwnPtrWillBeRawPtr<ServiceWorkerGlobalScopeProxy> create(WebEmbed
dedWorkerImpl&, Document&, WebServiceWorkerContextClient&); |
71 ~ServiceWorkerGlobalScopeProxy() override; | 72 ~ServiceWorkerGlobalScopeProxy() override; |
72 | 73 |
73 // WebServiceWorkerContextProxy overrides: | 74 // WebServiceWorkerContextProxy overrides: |
74 void setRegistration(WebPassOwnPtr<WebServiceWorkerRegistration::Handle>) ov
erride; | 75 void setRegistration(WebPassOwnPtr<WebServiceWorkerRegistration::Handle>) ov
erride; |
75 void dispatchActivateEvent(int) override; | 76 void dispatchActivateEvent(int) override; |
76 void dispatchCrossOriginMessageEvent(const WebCrossOriginServiceWorkerClient
&, const WebString& message, const WebMessagePortChannelArray&) override; | 77 void dispatchCrossOriginMessageEvent(const WebCrossOriginServiceWorkerClient
&, const WebString& message, const WebMessagePortChannelArray&) override; |
77 void dispatchFetchEvent(int, const WebServiceWorkerRequest&) override; | 78 void dispatchFetchEvent(int, const WebServiceWorkerRequest&) override; |
78 void dispatchGeofencingEvent(int, WebGeofencingEventType, const WebString& r
egionID, const WebCircularGeofencingRegion&) override; | 79 void dispatchGeofencingEvent(int, WebGeofencingEventType, const WebString& r
egionID, const WebCircularGeofencingRegion&) override; |
79 void dispatchInstallEvent(int) override; | 80 void dispatchInstallEvent(int) override; |
80 void dispatchMessageEvent(const WebString& message, const WebMessagePortChan
nelArray&) override; | 81 void dispatchMessageEvent(const WebString& message, const WebMessagePortChan
nelArray&) override; |
81 void dispatchNotificationClickEvent(int, int64_t notificationID, const WebNo
tificationData&, int actionIndex) override; | 82 void dispatchNotificationClickEvent(int, int64_t notificationID, const WebNo
tificationData&, int actionIndex) override; |
82 void dispatchPushEvent(int, const WebString& data) override; | 83 void dispatchPushEvent(int, const WebString& data) override; |
83 void dispatchServicePortConnectEvent(WebServicePortConnectEventCallbacks*, c
onst WebURL& targetURL, const WebString& origin, WebServicePortID) override; | 84 void dispatchServicePortConnectEvent(WebServicePortConnectEventCallbacks*, c
onst WebURL& targetURL, const WebString& origin, WebServicePortID) override; |
84 void dispatchSyncEvent(int, const WebSyncRegistration&, LastChanceOption) ov
erride; | 85 void dispatchSyncEvent(int, const WebSyncRegistration&, LastChanceOption) ov
erride; |
85 | 86 |
86 // WorkerReportingProxy overrides: | 87 // WorkerReportingProxy overrides: |
87 void reportException(const String& errorMessage, int lineNumber, int columnN
umber, const String& sourceURL, int exceptionId) override; | 88 void reportException(const String& errorMessage, int lineNumber, int columnN
umber, const String& sourceURL, int exceptionId) override; |
88 void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) override; | 89 void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) override; |
89 void postMessageToPageInspector(const String&) override; | 90 void postMessageToPageInspector(const String&) override; |
90 void postWorkerConsoleAgentEnabled() override { } | 91 void postWorkerConsoleAgentEnabled() override { } |
91 void didEvaluateWorkerScript(bool success) override; | 92 void didEvaluateWorkerScript(bool success) override; |
92 void didInitializeWorkerContext() override; | 93 void didInitializeWorkerContext() override; |
93 void workerGlobalScopeStarted(WorkerGlobalScope*) override; | 94 void workerGlobalScopeStarted(WorkerGlobalScope*) override; |
94 void workerGlobalScopeClosed() override; | 95 void workerGlobalScopeClosed() override; |
95 void willDestroyWorkerGlobalScope() override; | 96 void willDestroyWorkerGlobalScope() override; |
96 void workerThreadTerminated() override; | 97 void workerThreadTerminated() override; |
97 | 98 |
| 99 DECLARE_TRACE(); |
| 100 |
| 101 // Detach this proxy object entirely from the outside world, |
| 102 // clearing out all references. |
| 103 // |
| 104 // It is called during WebEmbeddedWorkerImpl finalization _after_ |
| 105 // the worker thread using the proxy has been terminated. |
| 106 void detach(); |
| 107 |
98 private: | 108 private: |
99 ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerImpl&, Document&, WebServiceW
orkerContextClient&); | 109 ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerImpl&, Document&, WebServiceW
orkerContextClient&); |
100 | 110 |
101 WebEmbeddedWorkerImpl& m_embeddedWorker; | 111 WebServiceWorkerContextClient& client() const; |
102 Document& m_document; | 112 Document& document() const; |
| 113 ServiceWorkerGlobalScope* workerGlobalScope() const; |
| 114 |
| 115 // Non-null until the WebEmbeddedWorkerImpl explicitly detach()es |
| 116 // as part of its finalization. |
| 117 WebEmbeddedWorkerImpl* m_embeddedWorker; |
| 118 RawPtrWillBeMember<Document> m_document; |
103 KURL m_documentURL; | 119 KURL m_documentURL; |
104 | 120 |
105 WebServiceWorkerContextClient& m_client; | 121 WebServiceWorkerContextClient* m_client; |
106 | 122 |
107 ServiceWorkerGlobalScope* m_workerGlobalScope; | 123 RawPtrWillBeMember<ServiceWorkerGlobalScope> m_workerGlobalScope; |
108 }; | 124 }; |
109 | 125 |
110 } // namespace blink | 126 } // namespace blink |
111 | 127 |
112 #endif // ServiceWorkerGlobalScopeProxy_h | 128 #endif // ServiceWorkerGlobalScopeProxy_h |
OLD | NEW |