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 24 matching lines...) Expand all Loading... | |
| 35 #include "bindings/core/v8/SourceLocation.h" | 35 #include "bindings/core/v8/SourceLocation.h" |
| 36 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 36 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 38 #include "core/dom/ExecutionContext.h" | 38 #include "core/dom/ExecutionContext.h" |
| 39 #include "core/dom/MessagePort.h" | 39 #include "core/dom/MessagePort.h" |
| 40 #include "core/inspector/ConsoleMessage.h" | 40 #include "core/inspector/ConsoleMessage.h" |
| 41 #include "core/origin_trials/OriginTrials.h" | 41 #include "core/origin_trials/OriginTrials.h" |
| 42 #include "core/workers/ParentFrameTaskRunners.h" | 42 #include "core/workers/ParentFrameTaskRunners.h" |
| 43 #include "core/workers/WorkerGlobalScope.h" | 43 #include "core/workers/WorkerGlobalScope.h" |
| 44 #include "core/workers/WorkerThread.h" | 44 #include "core/workers/WorkerThread.h" |
| 45 #include "modules/background_fetch/BackgroundFetchClickEvent.h" | |
| 46 #include "modules/background_fetch/BackgroundFetchClickEventInit.h" | |
| 47 #include "modules/background_fetch/BackgroundFetchEvent.h" | |
| 48 #include "modules/background_fetch/BackgroundFetchEventInit.h" | |
| 45 #include "modules/background_sync/SyncEvent.h" | 49 #include "modules/background_sync/SyncEvent.h" |
| 46 #include "modules/fetch/Headers.h" | 50 #include "modules/fetch/Headers.h" |
| 47 #include "modules/notifications/Notification.h" | 51 #include "modules/notifications/Notification.h" |
| 48 #include "modules/notifications/NotificationEvent.h" | 52 #include "modules/notifications/NotificationEvent.h" |
| 49 #include "modules/notifications/NotificationEventInit.h" | 53 #include "modules/notifications/NotificationEventInit.h" |
| 50 #include "modules/payments/PaymentAppRequest.h" | 54 #include "modules/payments/PaymentAppRequest.h" |
| 51 #include "modules/payments/PaymentAppRequestConversion.h" | 55 #include "modules/payments/PaymentAppRequestConversion.h" |
| 52 #include "modules/payments/PaymentRequestEvent.h" | 56 #include "modules/payments/PaymentRequestEvent.h" |
| 53 #include "modules/push_messaging/PushEvent.h" | 57 #include "modules/push_messaging/PushEvent.h" |
| 54 #include "modules/push_messaging/PushMessageData.h" | 58 #include "modules/push_messaging/PushMessageData.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 visitor->trace(m_document); | 95 visitor->trace(m_document); |
| 92 visitor->trace(m_parentFrameTaskRunners); | 96 visitor->trace(m_parentFrameTaskRunners); |
| 93 visitor->trace(m_pendingPreloadFetchEvents); | 97 visitor->trace(m_pendingPreloadFetchEvents); |
| 94 } | 98 } |
| 95 | 99 |
| 96 void ServiceWorkerGlobalScopeProxy::setRegistration( | 100 void ServiceWorkerGlobalScopeProxy::setRegistration( |
| 97 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) { | 101 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) { |
| 98 workerGlobalScope()->setRegistration(std::move(handle)); | 102 workerGlobalScope()->setRegistration(std::move(handle)); |
| 99 } | 103 } |
| 100 | 104 |
| 105 void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchAbortEvent( | |
| 106 int eventID, | |
| 107 const WebString& tag) { | |
| 108 WaitUntilObserver* observer = WaitUntilObserver::create( | |
| 109 workerGlobalScope(), WaitUntilObserver::BackgroundFetchAbort, eventID); | |
| 110 | |
| 111 BackgroundFetchClickEventInit init; | |
| 112 init.setTag(tag); | |
| 113 | |
| 114 BackgroundFetchEvent* event = BackgroundFetchEvent::create( | |
| 115 EventTypeNames::backgroundfetchabort, init, observer); | |
| 116 | |
| 117 workerGlobalScope()->dispatchExtendableEvent(event, observer); | |
| 118 } | |
| 119 | |
| 120 void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchClickEvent( | |
| 121 int eventID, | |
| 122 const WebString& tag, | |
| 123 BackgroundFetchState status) { | |
| 124 DEFINE_STATIC_LOCAL(const AtomicString, pending, ("pending")); | |
|
horo
2017/03/16 07:08:22
We should not use DEFINE_STATIC_LOCAL for AtomicSt
Peter Beverloo
2017/03/16 16:05:58
Removed, thanks
| |
| 125 DEFINE_STATIC_LOCAL(const AtomicString, succeeded, ("succeeded")); | |
| 126 DEFINE_STATIC_LOCAL(const AtomicString, failed, ("failed")); | |
| 127 | |
| 128 WaitUntilObserver* observer = WaitUntilObserver::create( | |
| 129 workerGlobalScope(), WaitUntilObserver::BackgroundFetchClick, eventID); | |
| 130 | |
| 131 BackgroundFetchClickEventInit init; | |
| 132 init.setTag(tag); | |
| 133 | |
| 134 switch (status) { | |
| 135 case BackgroundFetchState::Pending: | |
| 136 init.setState(pending); | |
| 137 break; | |
| 138 case BackgroundFetchState::Succeeded: | |
| 139 init.setState(succeeded); | |
| 140 break; | |
| 141 case BackgroundFetchState::Failed: | |
| 142 init.setState(failed); | |
| 143 break; | |
| 144 } | |
| 145 | |
| 146 BackgroundFetchClickEvent* event = BackgroundFetchClickEvent::create( | |
| 147 EventTypeNames::backgroundfetchclick, init, observer); | |
| 148 | |
| 149 workerGlobalScope()->dispatchExtendableEvent(event, observer); | |
| 150 } | |
| 151 | |
| 101 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) { | 152 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) { |
| 102 WaitUntilObserver* observer = WaitUntilObserver::create( | 153 WaitUntilObserver* observer = WaitUntilObserver::create( |
| 103 workerGlobalScope(), WaitUntilObserver::Activate, eventID); | 154 workerGlobalScope(), WaitUntilObserver::Activate, eventID); |
| 104 Event* event = ExtendableEvent::create(EventTypeNames::activate, | 155 Event* event = ExtendableEvent::create(EventTypeNames::activate, |
| 105 ExtendableEventInit(), observer); | 156 ExtendableEventInit(), observer); |
| 106 workerGlobalScope()->dispatchExtendableEvent(event, observer); | 157 workerGlobalScope()->dispatchExtendableEvent(event, observer); |
| 107 } | 158 } |
| 108 | 159 |
| 109 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent( | 160 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent( |
| 110 int eventID, | 161 int eventID, |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 return *m_document; | 534 return *m_document; |
| 484 } | 535 } |
| 485 | 536 |
| 486 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() | 537 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() |
| 487 const { | 538 const { |
| 488 DCHECK(m_workerGlobalScope); | 539 DCHECK(m_workerGlobalScope); |
| 489 return m_workerGlobalScope; | 540 return m_workerGlobalScope; |
| 490 } | 541 } |
| 491 | 542 |
| 492 } // namespace blink | 543 } // namespace blink |
| OLD | NEW |