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

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

Issue 2658603003: ServiceWorker: Enable UseCounter for ServiceWorkerGlobalScope (Closed)
Patch Set: int32_t -> uint32_t Created 3 years, 10 months 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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 #include "modules/serviceworkers/ServiceWorkerContainer.h" 30 #include "modules/serviceworkers/ServiceWorkerContainer.h"
31 31
32 #include <memory>
33 #include <utility>
32 #include "bindings/core/v8/CallbackPromiseAdapter.h" 34 #include "bindings/core/v8/CallbackPromiseAdapter.h"
33 #include "bindings/core/v8/ScriptPromise.h" 35 #include "bindings/core/v8/ScriptPromise.h"
34 #include "bindings/core/v8/ScriptPromiseResolver.h" 36 #include "bindings/core/v8/ScriptPromiseResolver.h"
35 #include "bindings/core/v8/ScriptState.h" 37 #include "bindings/core/v8/ScriptState.h"
36 #include "bindings/core/v8/SerializedScriptValue.h" 38 #include "bindings/core/v8/SerializedScriptValue.h"
37 #include "bindings/core/v8/SerializedScriptValueFactory.h" 39 #include "bindings/core/v8/SerializedScriptValueFactory.h"
38 #include "bindings/core/v8/V8ThrowException.h" 40 #include "bindings/core/v8/V8ThrowException.h"
39 #include "core/dom/DOMException.h" 41 #include "core/dom/DOMException.h"
40 #include "core/dom/Document.h" 42 #include "core/dom/Document.h"
41 #include "core/dom/ExceptionCode.h" 43 #include "core/dom/ExceptionCode.h"
42 #include "core/dom/ExecutionContext.h" 44 #include "core/dom/ExecutionContext.h"
43 #include "core/dom/MessagePort.h" 45 #include "core/dom/MessagePort.h"
44 #include "core/events/MessageEvent.h" 46 #include "core/events/MessageEvent.h"
47 #include "core/frame/Deprecation.h"
45 #include "core/frame/LocalDOMWindow.h" 48 #include "core/frame/LocalDOMWindow.h"
46 #include "core/frame/UseCounter.h" 49 #include "core/frame/UseCounter.h"
47 #include "core/frame/csp/ContentSecurityPolicy.h" 50 #include "core/frame/csp/ContentSecurityPolicy.h"
48 #include "modules/EventTargetModules.h" 51 #include "modules/EventTargetModules.h"
49 #include "modules/serviceworkers/NavigatorServiceWorker.h" 52 #include "modules/serviceworkers/NavigatorServiceWorker.h"
50 #include "modules/serviceworkers/ServiceWorker.h" 53 #include "modules/serviceworkers/ServiceWorker.h"
51 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 54 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
52 #include "modules/serviceworkers/ServiceWorkerError.h" 55 #include "modules/serviceworkers/ServiceWorkerError.h"
53 #include "modules/serviceworkers/ServiceWorkerRegistration.h" 56 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
54 #include "platform/RuntimeEnabledFeatures.h" 57 #include "platform/RuntimeEnabledFeatures.h"
55 #include "platform/weborigin/SchemeRegistry.h" 58 #include "platform/weborigin/SchemeRegistry.h"
56 #include "public/platform/WebString.h" 59 #include "public/platform/WebString.h"
57 #include "public/platform/WebURL.h" 60 #include "public/platform/WebURL.h"
58 #include "public/platform/modules/serviceworker/WebServiceWorker.h" 61 #include "public/platform/modules/serviceworker/WebServiceWorker.h"
59 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" 62 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h"
60 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h" 63 #include "public/platform/modules/serviceworker/WebServiceWorkerRegistration.h"
61 #include "wtf/PtrUtil.h" 64 #include "wtf/PtrUtil.h"
62 #include <memory>
63 #include <utility>
64 65
65 namespace blink { 66 namespace blink {
66 67
67 class GetRegistrationCallback : public WebServiceWorkerProvider:: 68 class GetRegistrationCallback : public WebServiceWorkerProvider::
68 WebServiceWorkerGetRegistrationCallbacks { 69 WebServiceWorkerGetRegistrationCallbacks {
69 public: 70 public:
70 explicit GetRegistrationCallback(ScriptPromiseResolver* resolver) 71 explicit GetRegistrationCallback(ScriptPromiseResolver* resolver)
71 : m_resolver(resolver) {} 72 : m_resolver(resolver) {}
72 ~GetRegistrationCallback() override {} 73 ~GetRegistrationCallback() override {}
73 74
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 MessagePortArray* ports = 452 MessagePortArray* ports =
452 MessagePort::toMessagePortArray(getExecutionContext(), webChannels); 453 MessagePort::toMessagePortArray(getExecutionContext(), webChannels);
453 RefPtr<SerializedScriptValue> value = SerializedScriptValue::create(message); 454 RefPtr<SerializedScriptValue> value = SerializedScriptValue::create(message);
454 ServiceWorker* source = ServiceWorker::from( 455 ServiceWorker* source = ServiceWorker::from(
455 getExecutionContext(), WTF::wrapUnique(handle.release())); 456 getExecutionContext(), WTF::wrapUnique(handle.release()));
456 dispatchEvent(MessageEvent::create( 457 dispatchEvent(MessageEvent::create(
457 ports, value, getExecutionContext()->getSecurityOrigin()->toString(), 458 ports, value, getExecutionContext()->getSecurityOrigin()->toString(),
458 String() /* lastEventId */, source, String() /* suborigin */)); 459 String() /* lastEventId */, source, String() /* suborigin */));
459 } 460 }
460 461
462 void ServiceWorkerContainer::countFeature(uint32_t feature) {
463 if (!getExecutionContext())
464 return;
465 UseCounter::Feature useCounterFeature =
466 static_cast<UseCounter::Feature>(feature);
467 if (Deprecation::deprecationMessage(useCounterFeature).isEmpty())
468 UseCounter::count(getExecutionContext(), useCounterFeature);
469 else
470 Deprecation::countDeprecation(getExecutionContext(), useCounterFeature);
471 }
472
461 const AtomicString& ServiceWorkerContainer::interfaceName() const { 473 const AtomicString& ServiceWorkerContainer::interfaceName() const {
462 return EventTargetNames::ServiceWorkerContainer; 474 return EventTargetNames::ServiceWorkerContainer;
463 } 475 }
464 476
465 ServiceWorkerContainer::ServiceWorkerContainer( 477 ServiceWorkerContainer::ServiceWorkerContainer(
466 ExecutionContext* executionContext, 478 ExecutionContext* executionContext,
467 NavigatorServiceWorker* navigator) 479 NavigatorServiceWorker* navigator)
468 : ContextLifecycleObserver(executionContext), 480 : ContextLifecycleObserver(executionContext),
469 m_provider(0), 481 m_provider(0),
470 m_navigator(navigator) { 482 m_navigator(navigator) {
471 if (!executionContext) 483 if (!executionContext)
472 return; 484 return;
473 485
474 if (ServiceWorkerContainerClient* client = 486 if (ServiceWorkerContainerClient* client =
475 ServiceWorkerContainerClient::from(executionContext)) { 487 ServiceWorkerContainerClient::from(executionContext)) {
476 m_provider = client->provider(); 488 m_provider = client->provider();
477 if (m_provider) 489 if (m_provider)
478 m_provider->setClient(this); 490 m_provider->setClient(this);
479 } 491 }
480 } 492 }
481 493
482 } // namespace blink 494 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698