Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 783663002: Implement ServiceWorkerClient attributes [1/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
30 #include "config.h" 30 #include "config.h"
31 #include "modules/serviceworkers/ServiceWorkerContainer.h" 31 #include "modules/serviceworkers/ServiceWorkerContainer.h"
32 32
33 #include "bindings/core/v8/CallbackPromiseAdapter.h" 33 #include "bindings/core/v8/CallbackPromiseAdapter.h"
34 #include "bindings/core/v8/ScriptPromise.h" 34 #include "bindings/core/v8/ScriptPromise.h"
35 #include "bindings/core/v8/ScriptPromiseResolver.h" 35 #include "bindings/core/v8/ScriptPromiseResolver.h"
36 #include "bindings/core/v8/ScriptState.h" 36 #include "bindings/core/v8/ScriptState.h"
37 #include "bindings/core/v8/SerializedScriptValue.h" 37 #include "bindings/core/v8/SerializedScriptValue.h"
38 #include "bindings/core/v8/SerializedScriptValueFactory.h" 38 #include "bindings/core/v8/SerializedScriptValueFactory.h"
39 #include "core/dom/DOMException.h" 39 #include "core/dom/DOMException.h"
40 #include "core/dom/Document.h"
40 #include "core/dom/ExceptionCode.h" 41 #include "core/dom/ExceptionCode.h"
41 #include "core/dom/ExecutionContext.h" 42 #include "core/dom/ExecutionContext.h"
42 #include "core/dom/MessagePort.h" 43 #include "core/dom/MessagePort.h"
43 #include "core/events/MessageEvent.h" 44 #include "core/events/MessageEvent.h"
44 #include "core/frame/LocalDOMWindow.h" 45 #include "core/frame/LocalDOMWindow.h"
45 #include "modules/EventTargetModules.h" 46 #include "modules/EventTargetModules.h"
46 #include "modules/serviceworkers/ServiceWorker.h" 47 #include "modules/serviceworkers/ServiceWorker.h"
47 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
48 #include "modules/serviceworkers/ServiceWorkerError.h" 49 #include "modules/serviceworkers/ServiceWorkerError.h"
49 #include "modules/serviceworkers/ServiceWorkerRegistration.h" 50 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
50 #include "platform/RuntimeEnabledFeatures.h" 51 #include "platform/RuntimeEnabledFeatures.h"
51 #include "public/platform/WebServiceWorker.h" 52 #include "public/platform/WebServiceWorker.h"
53 #include "public/platform/WebServiceWorkerClientsInfo.h"
52 #include "public/platform/WebServiceWorkerProvider.h" 54 #include "public/platform/WebServiceWorkerProvider.h"
53 #include "public/platform/WebServiceWorkerRegistration.h" 55 #include "public/platform/WebServiceWorkerRegistration.h"
54 #include "public/platform/WebString.h" 56 #include "public/platform/WebString.h"
55 #include "public/platform/WebURL.h" 57 #include "public/platform/WebURL.h"
56 58
57 namespace blink { 59 namespace blink {
58 60
59 // This wraps CallbackPromiseAdapter and resolves the promise with undefined 61 // This wraps CallbackPromiseAdapter and resolves the promise with undefined
60 // when nullptr is given to onSuccess. 62 // when nullptr is given to onSuccess.
61 class GetRegistrationCallback : public WebServiceWorkerProvider::WebServiceWorke rGetRegistrationCallbacks { 63 class GetRegistrationCallback : public WebServiceWorkerProvider::WebServiceWorke rGetRegistrationCallbacks {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels); 275 OwnPtrWillBeRawPtr<MessagePortArray> ports = MessagePort::toMessagePortArray (executionContext(), webChannels);
274 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message); 276 RefPtr<SerializedScriptValue> value = SerializedScriptValueFactory::instance ().createFromWire(message);
275 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value)); 277 executionContext()->executingWindow()->dispatchEvent(MessageEvent::create(po rts.release(), value));
276 } 278 }
277 279
278 const AtomicString& ServiceWorkerContainer::interfaceName() const 280 const AtomicString& ServiceWorkerContainer::interfaceName() const
279 { 281 {
280 return EventTargetNames::ServiceWorkerContainer; 282 return EventTargetNames::ServiceWorkerContainer;
281 } 283 }
282 284
285 bool ServiceWorkerContainer::getClientInfo(WebServiceWorkerClientInfo* info)
286 {
287 ExecutionContext* context = executionContext();
288 if (!context || !context->isDocument())
nhiroki 2014/12/08 04:07:06 According to the ongoing discussion[1], SharedWork
Kunihiko Sakamoto 2014/12/08 04:45:32 Done.
289 return false;
290 Document* document = toDocument(context);
291 info->visibilityState = document->visibilityState();
292 info->focused = document->hasFocus();
293 info->url = document->url();
294 if (!document->frame())
295 info->frameType = WebURLRequest::FrameTypeNone;
296 else if (document->frame()->isMainFrame())
297 info->frameType = WebURLRequest::FrameTypeTopLevel;
298 else
299 info->frameType = WebURLRequest::FrameTypeNested;
300 return true;
301 }
302
283 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t) 303 ServiceWorkerContainer::ServiceWorkerContainer(ExecutionContext* executionContex t)
284 : ContextLifecycleObserver(executionContext) 304 : ContextLifecycleObserver(executionContext)
285 , m_provider(0) 305 , m_provider(0)
286 { 306 {
287 307
288 if (!executionContext) 308 if (!executionContext)
289 return; 309 return;
290 310
291 m_ready = createReadyProperty(); 311 m_ready = createReadyProperty();
292 312
293 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 313 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
294 m_provider = client->provider(); 314 m_provider = client->provider();
295 if (m_provider) 315 if (m_provider)
296 m_provider->setClient(this); 316 m_provider->setClient(this);
297 } 317 }
298 } 318 }
299 319
300 } // namespace blink 320 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerContainer.h ('k') | Source/modules/serviceworkers/ServiceWorkerContainerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698