Chromium Code Reviews| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" | 67 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" |
| 68 #include "public/web/WebSerializedScriptValue.h" | 68 #include "public/web/WebSerializedScriptValue.h" |
| 69 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" | 69 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" |
| 70 #include "web/WebEmbeddedWorkerImpl.h" | 70 #include "web/WebEmbeddedWorkerImpl.h" |
| 71 #include "wtf/Assertions.h" | 71 #include "wtf/Assertions.h" |
| 72 #include "wtf/Functional.h" | 72 #include "wtf/Functional.h" |
| 73 #include "wtf/PassOwnPtr.h" | 73 #include "wtf/PassOwnPtr.h" |
| 74 | 74 |
| 75 namespace blink { | 75 namespace blink { |
| 76 | 76 |
| 77 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create( WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerConte xtClient& client) | 77 PassOwnPtrWillBeRawPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopePr oxy::create(WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServic eWorkerContextClient& client) |
| 78 { | 78 { |
| 79 return adoptPtr(new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client)); | 79 return adoptPtrWillBeNoop(new ServiceWorkerGlobalScopeProxy(embeddedWorker, document, client)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() | 82 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() |
| 83 { | 83 { |
|
haraken
2015/11/17 23:53:59
Can we assert that detach() has been called?
sof
2015/11/18 08:58:09
Done; asserting for !m_embeddedWorker.
| |
| 84 } | 84 } |
| 85 | 85 |
| 86 DEFINE_TRACE(ServiceWorkerGlobalScopeProxy) | |
| 87 { | |
| 88 visitor->trace(m_document); | |
| 89 visitor->trace(m_workerGlobalScope); | |
| 90 } | |
| 91 | |
| 86 void ServiceWorkerGlobalScopeProxy::setRegistration(WebPassOwnPtr<WebServiceWork erRegistration::Handle> handle) | 92 void ServiceWorkerGlobalScopeProxy::setRegistration(WebPassOwnPtr<WebServiceWork erRegistration::Handle> handle) |
| 87 { | 93 { |
| 88 ASSERT(m_workerGlobalScope); | 94 workerGlobalScope()->setRegistration(handle); |
| 89 m_workerGlobalScope->setRegistration(handle); | |
| 90 } | 95 } |
| 91 | 96 |
| 92 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) | 97 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) |
| 93 { | 98 { |
| 94 ASSERT(m_workerGlobalScope); | 99 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Activate, eventID); |
| 95 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Activate, eventID); | |
| 96 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti vate, ExtendableEventInit(), observer)); | 100 RefPtrWillBeRawPtr<Event> event(ExtendableEvent::create(EventTypeNames::acti vate, ExtendableEventInit(), observer)); |
| 97 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); | 101 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 98 } | 102 } |
| 99 | 103 |
| 100 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) | 104 void ServiceWorkerGlobalScopeProxy::dispatchFetchEvent(int eventID, const WebSer viceWorkerRequest& webRequest) |
| 101 { | 105 { |
| 102 ASSERT(m_workerGlobalScope); | 106 RespondWithObserver* observer = RespondWithObserver::create(workerGlobalScop e(), eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe quest.requestContext()); |
| 103 RespondWithObserver* observer = RespondWithObserver::create(m_workerGlobalSc ope, eventID, webRequest.url(), webRequest.mode(), webRequest.frameType(), webRe quest.requestContext()); | |
| 104 bool defaultPrevented = false; | 107 bool defaultPrevented = false; |
| 105 Request* request = Request::create(m_workerGlobalScope, webRequest); | 108 Request* request = Request::create(workerGlobalScope(), webRequest); |
| 106 request->headers()->setGuard(Headers::ImmutableGuard); | 109 request->headers()->setGuard(Headers::ImmutableGuard); |
| 107 FetchEventInit eventInit; | 110 FetchEventInit eventInit; |
| 108 eventInit.setCancelable(true); | 111 eventInit.setCancelable(true); |
| 109 eventInit.setRequest(request); | 112 eventInit.setRequest(request); |
| 110 eventInit.setIsReload(webRequest.isReload()); | 113 eventInit.setIsReload(webRequest.isReload()); |
| 111 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(EventTypeNames: :fetch, eventInit, observer)); | 114 RefPtrWillBeRawPtr<FetchEvent> fetchEvent(FetchEvent::create(EventTypeNames: :fetch, eventInit, observer)); |
| 112 defaultPrevented = !m_workerGlobalScope->dispatchEvent(fetchEvent.release()) ; | 115 defaultPrevented = !workerGlobalScope()->dispatchEvent(fetchEvent.release()) ; |
| 113 observer->didDispatchEvent(defaultPrevented); | 116 observer->didDispatchEvent(defaultPrevented); |
| 114 } | 117 } |
| 115 | 118 |
| 116 void ServiceWorkerGlobalScopeProxy::dispatchGeofencingEvent(int eventID, WebGeof encingEventType eventType, const WebString& regionID, const WebCircularGeofencin gRegion& region) | 119 void ServiceWorkerGlobalScopeProxy::dispatchGeofencingEvent(int eventID, WebGeof encingEventType eventType, const WebString& regionID, const WebCircularGeofencin gRegion& region) |
| 117 { | 120 { |
| 118 ASSERT(m_workerGlobalScope); | |
| 119 const AtomicString& type = eventType == WebGeofencingEventTypeEnter ? EventT ypeNames::geofenceenter : EventTypeNames::geofenceleave; | 121 const AtomicString& type = eventType == WebGeofencingEventTypeEnter ? EventT ypeNames::geofenceenter : EventTypeNames::geofenceleave; |
| 120 m_workerGlobalScope->dispatchEvent(GeofencingEvent::create(type, regionID, C ircularGeofencingRegion::create(regionID, region))); | 122 workerGlobalScope()->dispatchEvent(GeofencingEvent::create(type, regionID, C ircularGeofencingRegion::create(regionID, region))); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) | 125 void ServiceWorkerGlobalScopeProxy::dispatchInstallEvent(int eventID) |
| 124 { | 126 { |
| 125 ASSERT(m_workerGlobalScope); | 127 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Install, eventID); |
| 126 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Install, eventID); | |
| 127 RefPtrWillBeRawPtr<Event> event; | 128 RefPtrWillBeRawPtr<Event> event; |
| 128 if (RuntimeEnabledFeatures::foreignFetchEnabled()) { | 129 if (RuntimeEnabledFeatures::foreignFetchEnabled()) |
| 129 event = InstallEvent::create(EventTypeNames::install, ExtendableEventIni t(), observer); | 130 event = InstallEvent::create(EventTypeNames::install, ExtendableEventIni t(), observer); |
| 130 } else { | 131 else |
| 131 event = ExtendableEvent::create(EventTypeNames::install, ExtendableEvent Init(), observer); | 132 event = ExtendableEvent::create(EventTypeNames::install, ExtendableEvent Init(), observer); |
| 132 } | 133 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 133 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); | |
| 134 } | 134 } |
| 135 | 135 |
| 136 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels) | 136 void ServiceWorkerGlobalScopeProxy::dispatchMessageEvent(const WebString& messag e, const WebMessagePortChannelArray& webChannels) |
| 137 { | 137 { |
| 138 ASSERT(m_workerGlobalScope); | 138 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels); |
| 139 | |
| 140 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); | |
| 141 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); | 139 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); |
| 142 m_workerGlobalScope->dispatchEvent(MessageEvent::create(ports, value)); | 140 workerGlobalScope()->dispatchEvent(MessageEvent::create(ports, value)); |
| 143 } | 141 } |
| 144 | 142 |
| 145 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex) | 143 void ServiceWorkerGlobalScopeProxy::dispatchNotificationClickEvent(int eventID, int64_t notificationID, const WebNotificationData& data, int actionIndex) |
| 146 { | 144 { |
| 147 ASSERT(m_workerGlobalScope); | 145 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::NotificationClick, eventID); |
| 148 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::NotificationClick, eventID); | |
| 149 NotificationEventInit eventInit; | 146 NotificationEventInit eventInit; |
| 150 eventInit.setNotification(Notification::create(m_workerGlobalScope, notifica tionID, data)); | 147 eventInit.setNotification(Notification::create(workerGlobalScope(), notifica tionID, data)); |
| 151 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size())) | 148 if (0 <= actionIndex && actionIndex < static_cast<int>(data.actions.size())) |
| 152 eventInit.setAction(data.actions[actionIndex].action); | 149 eventInit.setAction(data.actions[actionIndex].action); |
| 153 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer)); | 150 RefPtrWillBeRawPtr<Event> event(NotificationEvent::create(EventTypeNames::no tificationclick, eventInit, observer)); |
| 154 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); | 151 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 155 } | 152 } |
| 156 | 153 |
| 157 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) | 154 void ServiceWorkerGlobalScopeProxy::dispatchPushEvent(int eventID, const WebStri ng& data) |
| 158 { | 155 { |
| 159 ASSERT(m_workerGlobalScope); | 156 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Push, eventID); |
| 160 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Push, eventID); | |
| 161 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); | 157 RefPtrWillBeRawPtr<Event> event(PushEvent::create(EventTypeNames::push, Push MessageData::create(data), observer)); |
| 162 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); | 158 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 163 } | 159 } |
| 164 | 160 |
| 165 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID) | 161 void ServiceWorkerGlobalScopeProxy::dispatchServicePortConnectEvent(WebServicePo rtConnectEventCallbacks* rawCallbacks, const WebURL& targetURL, const WebString& origin, WebServicePortID portID) |
| 166 { | 162 { |
| 167 ASSERT(m_workerGlobalScope); | |
| 168 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s); | 163 OwnPtr<WebServicePortConnectEventCallbacks> callbacks = adoptPtr(rawCallback s); |
| 169 ServicePortCollection* collection = WorkerNavigatorServices::services(m_work erGlobalScope, *m_workerGlobalScope->navigator()); | 164 ServicePortCollection* collection = WorkerNavigatorServices::services(worker GlobalScope(), *workerGlobalScope()->navigator()); |
| 170 collection->dispatchConnectEvent(callbacks.release(), targetURL, origin, por tID); | 165 collection->dispatchConnectEvent(callbacks.release(), targetURL, origin, por tID); |
| 171 } | 166 } |
| 172 | 167 |
| 173 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID, const WebSync Registration& registration, LastChanceOption lastChance) | 168 void ServiceWorkerGlobalScopeProxy::dispatchSyncEvent(int eventID, const WebSync Registration& registration, LastChanceOption lastChance) |
| 174 { | 169 { |
| 175 ASSERT(m_workerGlobalScope); | |
| 176 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { | 170 if (!RuntimeEnabledFeatures::backgroundSyncEnabled()) { |
| 177 ServiceWorkerGlobalScopeClient::from(m_workerGlobalScope)->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted); | 171 ServiceWorkerGlobalScopeClient::from(workerGlobalScope())->didHandleSync Event(eventID, WebServiceWorkerEventResultCompleted); |
| 178 return; | 172 return; |
| 179 } | 173 } |
| 180 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope, WaitUntilObserver::Sync, eventID); | 174 WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Sync, eventID); |
| 181 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, regi stration.tag, lastChance == IsLastChance, observer)); | 175 RefPtrWillBeRawPtr<Event> event(SyncEvent::create(EventTypeNames::sync, regi stration.tag, lastChance == IsLastChance, observer)); |
| 182 m_workerGlobalScope->dispatchExtendableEvent(event.release(), observer); | 176 workerGlobalScope()->dispatchExtendableEvent(event.release(), observer); |
| 183 } | 177 } |
| 184 | 178 |
| 185 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa gePortChannelArray& webChannels) | 179 void ServiceWorkerGlobalScopeProxy::dispatchCrossOriginMessageEvent(const WebCro ssOriginServiceWorkerClient& webClient, const WebString& message, const WebMessa gePortChannelArray& webChannels) |
| 186 { | 180 { |
| 187 ASSERT(m_workerGlobalScope); | 181 MessagePortArray* ports = MessagePort::toMessagePortArray(workerGlobalScope( ), webChannels); |
| 188 MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScop e, webChannels); | |
| 189 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); | 182 WebSerializedScriptValue value = WebSerializedScriptValue::fromString(messag e); |
| 190 // FIXME: Have proper source for this MessageEvent. | 183 // FIXME: Have proper source for this MessageEvent. |
| 191 RefPtrWillBeRawPtr<MessageEvent> event = MessageEvent::create(ports, value, webClient.origin.string()); | 184 RefPtrWillBeRawPtr<MessageEvent> event = MessageEvent::create(ports, value, webClient.origin.string()); |
| 192 event->setType(EventTypeNames::crossoriginmessage); | 185 event->setType(EventTypeNames::crossoriginmessage); |
| 193 m_workerGlobalScope->dispatchEvent(event); | 186 workerGlobalScope()->dispatchEvent(event); |
| 194 } | 187 } |
| 195 | 188 |
| 196 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, int) | 189 void ServiceWorkerGlobalScopeProxy::reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, int) |
| 197 { | 190 { |
| 198 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); | 191 client().reportException(errorMessage, lineNumber, columnNumber, sourceURL); |
| 199 } | 192 } |
| 200 | 193 |
| 201 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(PassRefPtrWillBeRawPtr< ConsoleMessage> consoleMessage) | 194 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(PassRefPtrWillBeRawPtr< ConsoleMessage> consoleMessage) |
| 202 { | 195 { |
| 203 m_client.reportConsoleMessage(consoleMessage->source(), consoleMessage->leve l(), consoleMessage->message(), consoleMessage->lineNumber(), consoleMessage->ur l()); | 196 client().reportConsoleMessage(consoleMessage->source(), consoleMessage->leve l(), consoleMessage->message(), consoleMessage->lineNumber(), consoleMessage->ur l()); |
| 204 } | 197 } |
| 205 | 198 |
| 206 void ServiceWorkerGlobalScopeProxy::postMessageToPageInspector(const String& mes sage) | 199 void ServiceWorkerGlobalScopeProxy::postMessageToPageInspector(const String& mes sage) |
| 207 { | 200 { |
| 208 m_document.postInspectorTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbe ddedWorkerImpl::postMessageToPageInspector, &m_embeddedWorker, message)); | 201 ASSERT(m_embeddedWorker); |
| 202 document().postInspectorTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbe ddedWorkerImpl::postMessageToPageInspector, m_embeddedWorker, message)); | |
| 209 } | 203 } |
| 210 | 204 |
| 211 void ServiceWorkerGlobalScopeProxy::didEvaluateWorkerScript(bool success) | 205 void ServiceWorkerGlobalScopeProxy::didEvaluateWorkerScript(bool success) |
| 212 { | 206 { |
| 213 m_client.didEvaluateWorkerScript(success); | 207 client().didEvaluateWorkerScript(success); |
| 214 } | 208 } |
| 215 | 209 |
| 216 void ServiceWorkerGlobalScopeProxy::didInitializeWorkerContext() | 210 void ServiceWorkerGlobalScopeProxy::didInitializeWorkerContext() |
| 217 { | 211 { |
| 218 ASSERT(m_workerGlobalScope); | 212 ScriptState::Scope scope(workerGlobalScope()->script()->scriptState()); |
| 219 ScriptState::Scope scope(m_workerGlobalScope->script()->scriptState()); | 213 client().didInitializeWorkerContext(workerGlobalScope()->script()->context() , WebURL(m_documentURL)); |
| 220 m_client.didInitializeWorkerContext(m_workerGlobalScope->script()->context() , WebURL(m_documentURL)); | |
| 221 } | 214 } |
| 222 | 215 |
| 223 void ServiceWorkerGlobalScopeProxy::workerGlobalScopeStarted(WorkerGlobalScope* workerGlobalScope) | 216 void ServiceWorkerGlobalScopeProxy::workerGlobalScopeStarted(WorkerGlobalScope* workerGlobalScope) |
| 224 { | 217 { |
| 225 ASSERT(!m_workerGlobalScope); | 218 ASSERT(!m_workerGlobalScope); |
| 226 m_workerGlobalScope = static_cast<ServiceWorkerGlobalScope*>(workerGlobalSco pe); | 219 m_workerGlobalScope = static_cast<ServiceWorkerGlobalScope*>(workerGlobalSco pe); |
| 227 m_client.workerContextStarted(this); | 220 client().workerContextStarted(this); |
| 228 } | 221 } |
| 229 | 222 |
| 230 void ServiceWorkerGlobalScopeProxy::workerGlobalScopeClosed() | 223 void ServiceWorkerGlobalScopeProxy::workerGlobalScopeClosed() |
| 231 { | 224 { |
| 232 m_document.postTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbeddedWorke rImpl::terminateWorkerContext, &m_embeddedWorker)); | 225 ASSERT(m_embeddedWorker); |
| 226 document().postTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbeddedWorke rImpl::terminateWorkerContext, m_embeddedWorker)); | |
| 233 } | 227 } |
| 234 | 228 |
| 235 void ServiceWorkerGlobalScopeProxy::willDestroyWorkerGlobalScope() | 229 void ServiceWorkerGlobalScopeProxy::willDestroyWorkerGlobalScope() |
| 236 { | 230 { |
| 237 v8::HandleScope handleScope(m_workerGlobalScope->thread()->isolate()); | 231 v8::HandleScope handleScope(workerGlobalScope()->thread()->isolate()); |
| 238 m_client.willDestroyWorkerContext(m_workerGlobalScope->script()->context()); | 232 client().willDestroyWorkerContext(workerGlobalScope()->script()->context()); |
| 239 m_workerGlobalScope = nullptr; | 233 m_workerGlobalScope = nullptr; |
| 240 } | 234 } |
| 241 | 235 |
| 242 void ServiceWorkerGlobalScopeProxy::workerThreadTerminated() | 236 void ServiceWorkerGlobalScopeProxy::workerThreadTerminated() |
| 243 { | 237 { |
| 244 m_client.workerContextDestroyed(); | 238 client().workerContextDestroyed(); |
| 245 } | 239 } |
| 246 | 240 |
| 247 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) | 241 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) |
| 248 : m_embeddedWorker(embeddedWorker) | 242 : m_embeddedWorker(&embeddedWorker) |
| 249 , m_document(document) | 243 , m_document(&document) |
| 250 , m_documentURL(document.url().copy()) | 244 , m_documentURL(document.url().copy()) |
| 251 , m_client(client) | 245 , m_client(&client) |
| 252 , m_workerGlobalScope(nullptr) | 246 , m_workerGlobalScope(nullptr) |
| 253 { | 247 { |
| 254 } | 248 } |
| 255 | 249 |
| 250 void ServiceWorkerGlobalScopeProxy::detach() | |
| 251 { | |
| 252 m_embeddedWorker = nullptr; | |
| 253 m_document = nullptr; | |
| 254 m_client = nullptr; | |
| 255 m_workerGlobalScope = nullptr; | |
| 256 } | |
| 257 | |
| 258 WebServiceWorkerContextClient& ServiceWorkerGlobalScopeProxy::client() const | |
|
haraken
2015/11/17 23:53:59
Nit: I'd inline these getters.
| |
| 259 { | |
| 260 ASSERT(m_client); | |
| 261 return *m_client; | |
| 262 } | |
| 263 | |
| 264 Document& ServiceWorkerGlobalScopeProxy::document() const | |
| 265 { | |
| 266 ASSERT(m_document); | |
| 267 return *m_document; | |
| 268 } | |
| 269 | |
| 270 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() con st | |
| 271 { | |
| 272 ASSERT(m_workerGlobalScope); | |
| 273 return m_workerGlobalScope; | |
| 274 } | |
| 275 | |
| 256 } // namespace blink | 276 } // namespace blink |
| OLD | NEW |