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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" | 66 #include "public/platform/modules/serviceworker/WebServiceWorkerRequest.h" |
67 #include "public/web/WebSerializedScriptValue.h" | 67 #include "public/web/WebSerializedScriptValue.h" |
68 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" | 68 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" |
69 #include "web/WebEmbeddedWorkerImpl.h" | 69 #include "web/WebEmbeddedWorkerImpl.h" |
70 #include "wtf/Assertions.h" | 70 #include "wtf/Assertions.h" |
71 #include "wtf/Functional.h" | 71 #include "wtf/Functional.h" |
72 #include "wtf/PassOwnPtr.h" | 72 #include "wtf/PassOwnPtr.h" |
73 | 73 |
74 namespace blink { | 74 namespace blink { |
75 | 75 |
76 PassOwnPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopeProxy::create(
WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServiceWorkerConte
xtClient& client) | 76 PassOwnPtrWillBeRawPtr<ServiceWorkerGlobalScopeProxy> ServiceWorkerGlobalScopePr
oxy::create(WebEmbeddedWorkerImpl& embeddedWorker, Document& document, WebServic
eWorkerContextClient& client) |
77 { | 77 { |
78 return adoptPtr(new ServiceWorkerGlobalScopeProxy(embeddedWorker, document,
client)); | 78 return adoptPtrWillBeNoop(new ServiceWorkerGlobalScopeProxy(embeddedWorker,
document, client)); |
79 } | 79 } |
80 | 80 |
81 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() | 81 ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() |
82 { | 82 { |
83 } | 83 } |
84 | 84 |
| 85 DEFINE_TRACE(ServiceWorkerGlobalScopeProxy) |
| 86 { |
| 87 visitor->trace(m_document); |
| 88 visitor->trace(m_workerGlobalScope); |
| 89 } |
| 90 |
85 void ServiceWorkerGlobalScopeProxy::setRegistration(WebPassOwnPtr<WebServiceWork
erRegistration::Handle> handle) | 91 void ServiceWorkerGlobalScopeProxy::setRegistration(WebPassOwnPtr<WebServiceWork
erRegistration::Handle> handle) |
86 { | 92 { |
87 ASSERT(m_workerGlobalScope); | 93 ASSERT(m_workerGlobalScope); |
88 m_workerGlobalScope->setRegistration(handle); | 94 m_workerGlobalScope->setRegistration(handle); |
89 } | 95 } |
90 | 96 |
91 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) | 97 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) |
92 { | 98 { |
93 ASSERT(m_workerGlobalScope); | 99 ASSERT(m_workerGlobalScope); |
94 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Activate, eventID); | 100 WaitUntilObserver* observer = WaitUntilObserver::create(m_workerGlobalScope,
WaitUntilObserver::Activate, eventID); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); | 203 m_client.reportException(errorMessage, lineNumber, columnNumber, sourceURL); |
198 } | 204 } |
199 | 205 |
200 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(PassRefPtrWillBeRawPtr<
ConsoleMessage> consoleMessage) | 206 void ServiceWorkerGlobalScopeProxy::reportConsoleMessage(PassRefPtrWillBeRawPtr<
ConsoleMessage> consoleMessage) |
201 { | 207 { |
202 m_client.reportConsoleMessage(consoleMessage->source(), consoleMessage->leve
l(), consoleMessage->message(), consoleMessage->lineNumber(), consoleMessage->ur
l()); | 208 m_client.reportConsoleMessage(consoleMessage->source(), consoleMessage->leve
l(), consoleMessage->message(), consoleMessage->lineNumber(), consoleMessage->ur
l()); |
203 } | 209 } |
204 | 210 |
205 void ServiceWorkerGlobalScopeProxy::postMessageToPageInspector(const String& mes
sage) | 211 void ServiceWorkerGlobalScopeProxy::postMessageToPageInspector(const String& mes
sage) |
206 { | 212 { |
207 m_document.postInspectorTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbe
ddedWorkerImpl::postMessageToPageInspector, &m_embeddedWorker, message)); | 213 m_document->postInspectorTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmb
eddedWorkerImpl::postMessageToPageInspector, &m_embeddedWorker, message)); |
208 } | 214 } |
209 | 215 |
210 void ServiceWorkerGlobalScopeProxy::didEvaluateWorkerScript(bool success) | 216 void ServiceWorkerGlobalScopeProxy::didEvaluateWorkerScript(bool success) |
211 { | 217 { |
212 m_client.didEvaluateWorkerScript(success); | 218 m_client.didEvaluateWorkerScript(success); |
213 } | 219 } |
214 | 220 |
215 void ServiceWorkerGlobalScopeProxy::didInitializeWorkerContext() | 221 void ServiceWorkerGlobalScopeProxy::didInitializeWorkerContext() |
216 { | 222 { |
217 ASSERT(m_workerGlobalScope); | 223 ASSERT(m_workerGlobalScope); |
218 ScriptState::Scope scope(m_workerGlobalScope->script()->scriptState()); | 224 ScriptState::Scope scope(m_workerGlobalScope->script()->scriptState()); |
219 m_client.didInitializeWorkerContext(m_workerGlobalScope->script()->context()
, WebURL(m_documentURL)); | 225 m_client.didInitializeWorkerContext(m_workerGlobalScope->script()->context()
, WebURL(m_documentURL)); |
220 } | 226 } |
221 | 227 |
222 void ServiceWorkerGlobalScopeProxy::workerGlobalScopeStarted(WorkerGlobalScope*
workerGlobalScope) | 228 void ServiceWorkerGlobalScopeProxy::workerGlobalScopeStarted(WorkerGlobalScope*
workerGlobalScope) |
223 { | 229 { |
224 ASSERT(!m_workerGlobalScope); | 230 ASSERT(!m_workerGlobalScope); |
225 m_workerGlobalScope = static_cast<ServiceWorkerGlobalScope*>(workerGlobalSco
pe); | 231 m_workerGlobalScope = static_cast<ServiceWorkerGlobalScope*>(workerGlobalSco
pe); |
226 m_client.workerContextStarted(this); | 232 m_client.workerContextStarted(this); |
227 } | 233 } |
228 | 234 |
229 void ServiceWorkerGlobalScopeProxy::workerGlobalScopeClosed() | 235 void ServiceWorkerGlobalScopeProxy::workerGlobalScopeClosed() |
230 { | 236 { |
231 m_document.postTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbeddedWorke
rImpl::terminateWorkerContext, &m_embeddedWorker)); | 237 m_document->postTask(BLINK_FROM_HERE, createCrossThreadTask(&WebEmbeddedWork
erImpl::terminateWorkerContext, &m_embeddedWorker)); |
232 } | 238 } |
233 | 239 |
234 void ServiceWorkerGlobalScopeProxy::willDestroyWorkerGlobalScope() | 240 void ServiceWorkerGlobalScopeProxy::willDestroyWorkerGlobalScope() |
235 { | 241 { |
236 v8::HandleScope handleScope(m_workerGlobalScope->thread()->isolate()); | 242 v8::HandleScope handleScope(m_workerGlobalScope->thread()->isolate()); |
237 m_client.willDestroyWorkerContext(m_workerGlobalScope->script()->context()); | 243 m_client.willDestroyWorkerContext(m_workerGlobalScope->script()->context()); |
238 m_workerGlobalScope = nullptr; | 244 m_workerGlobalScope = nullptr; |
239 } | 245 } |
240 | 246 |
241 void ServiceWorkerGlobalScopeProxy::workerThreadTerminated() | 247 void ServiceWorkerGlobalScopeProxy::workerThreadTerminated() |
242 { | 248 { |
243 m_client.workerContextDestroyed(); | 249 m_client.workerContextDestroyed(); |
244 } | 250 } |
245 | 251 |
246 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm
pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) | 252 ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(WebEmbeddedWorkerIm
pl& embeddedWorker, Document& document, WebServiceWorkerContextClient& client) |
247 : m_embeddedWorker(embeddedWorker) | 253 : m_embeddedWorker(embeddedWorker) |
248 , m_document(document) | 254 , m_document(&document) |
249 , m_documentURL(document.url().copy()) | 255 , m_documentURL(document.url().copy()) |
250 , m_client(client) | 256 , m_client(client) |
251 , m_workerGlobalScope(nullptr) | 257 , m_workerGlobalScope(nullptr) |
252 { | 258 { |
253 } | 259 } |
254 | 260 |
255 } // namespace blink | 261 } // namespace blink |
OLD | NEW |