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 28 matching lines...) Expand all Loading... | |
| 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" | 45 #include "modules/background_fetch/BackgroundFetchClickEvent.h" |
| 46 #include "modules/background_fetch/BackgroundFetchClickEventInit.h" | 46 #include "modules/background_fetch/BackgroundFetchClickEventInit.h" |
| 47 #include "modules/background_fetch/BackgroundFetchEvent.h" | 47 #include "modules/background_fetch/BackgroundFetchEvent.h" |
| 48 #include "modules/background_fetch/BackgroundFetchEventInit.h" | 48 #include "modules/background_fetch/BackgroundFetchEventInit.h" |
| 49 #include "modules/background_fetch/BackgroundFetchFailEvent.h" | |
| 50 #include "modules/background_fetch/BackgroundFetchFailEventInit.h" | |
| 51 #include "modules/background_fetch/BackgroundFetchedEvent.h" | |
| 52 #include "modules/background_fetch/BackgroundFetchedEventInit.h" | |
| 49 #include "modules/background_sync/SyncEvent.h" | 53 #include "modules/background_sync/SyncEvent.h" |
| 50 #include "modules/fetch/Headers.h" | 54 #include "modules/fetch/Headers.h" |
| 51 #include "modules/notifications/Notification.h" | 55 #include "modules/notifications/Notification.h" |
| 52 #include "modules/notifications/NotificationEvent.h" | 56 #include "modules/notifications/NotificationEvent.h" |
| 53 #include "modules/notifications/NotificationEventInit.h" | 57 #include "modules/notifications/NotificationEventInit.h" |
| 54 #include "modules/payments/PaymentAppRequest.h" | 58 #include "modules/payments/PaymentAppRequest.h" |
| 55 #include "modules/payments/PaymentAppRequestConversion.h" | 59 #include "modules/payments/PaymentAppRequestConversion.h" |
| 56 #include "modules/payments/PaymentRequestEvent.h" | 60 #include "modules/payments/PaymentRequestEvent.h" |
| 57 #include "modules/payments/PaymentRequestRespondWithObserver.h" | 61 #include "modules/payments/PaymentRequestRespondWithObserver.h" |
| 58 #include "modules/push_messaging/PushEvent.h" | 62 #include "modules/push_messaging/PushEvent.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 init.setState("failed"); | 142 init.setState("failed"); |
| 139 break; | 143 break; |
| 140 } | 144 } |
| 141 | 145 |
| 142 BackgroundFetchClickEvent* event = BackgroundFetchClickEvent::create( | 146 BackgroundFetchClickEvent* event = BackgroundFetchClickEvent::create( |
| 143 EventTypeNames::backgroundfetchclick, init, observer); | 147 EventTypeNames::backgroundfetchclick, init, observer); |
| 144 | 148 |
| 145 workerGlobalScope()->dispatchExtendableEvent(event, observer); | 149 workerGlobalScope()->dispatchExtendableEvent(event, observer); |
| 146 } | 150 } |
| 147 | 151 |
| 152 void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchFailEvent( | |
| 153 int eventID, | |
| 154 const WebString& tag, | |
| 155 const WebVector<WebBackgroundFetchSettledFetch>& fetches) { | |
| 156 WaitUntilObserver* observer = WaitUntilObserver::create( | |
| 157 workerGlobalScope(), WaitUntilObserver::BackgroundFetchFail, eventID); | |
| 158 | |
| 159 BackgroundFetchFailEventInit init; | |
| 160 init.setTag(tag); | |
| 161 | |
| 162 ScriptState::Scope scope( | |
| 163 workerGlobalScope()->scriptController()->getScriptState()); | |
| 164 ScriptState* scriptState = | |
| 165 workerGlobalScope()->scriptController()->getScriptState(); | |
|
kinuko
2017/03/24 03:40:03
nit: you can reverse these lines to make the scope
Peter Beverloo
2017/03/24 14:11:09
Done. Also in dispatchBackgroundFetchedEvent.
| |
| 166 | |
| 167 BackgroundFetchFailEvent* event = | |
| 168 BackgroundFetchFailEvent::create(EventTypeNames::backgroundfetchfail, | |
| 169 init, fetches, scriptState, observer); | |
| 170 | |
| 171 workerGlobalScope()->dispatchExtendableEvent(event, observer); | |
| 172 } | |
| 173 | |
| 174 void ServiceWorkerGlobalScopeProxy::dispatchBackgroundFetchedEvent( | |
| 175 int eventID, | |
| 176 const WebString& tag, | |
| 177 const WebVector<WebBackgroundFetchSettledFetch>& fetches) { | |
| 178 WaitUntilObserver* observer = WaitUntilObserver::create( | |
| 179 workerGlobalScope(), WaitUntilObserver::BackgroundFetched, eventID); | |
| 180 | |
| 181 BackgroundFetchedEventInit init; | |
| 182 init.setTag(tag); | |
| 183 | |
| 184 ScriptState::Scope scope( | |
| 185 workerGlobalScope()->scriptController()->getScriptState()); | |
| 186 ScriptState* scriptState = | |
| 187 workerGlobalScope()->scriptController()->getScriptState(); | |
| 188 | |
| 189 BackgroundFetchedEvent* event = BackgroundFetchedEvent::create( | |
| 190 EventTypeNames::backgroundfetched, init, fetches, scriptState, observer, | |
| 191 m_workerGlobalScope->registration()); | |
| 192 | |
| 193 workerGlobalScope()->dispatchExtendableEvent(event, observer); | |
| 194 } | |
| 195 | |
| 148 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) { | 196 void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID) { |
| 149 WaitUntilObserver* observer = WaitUntilObserver::create( | 197 WaitUntilObserver* observer = WaitUntilObserver::create( |
| 150 workerGlobalScope(), WaitUntilObserver::Activate, eventID); | 198 workerGlobalScope(), WaitUntilObserver::Activate, eventID); |
| 151 Event* event = ExtendableEvent::create(EventTypeNames::activate, | 199 Event* event = ExtendableEvent::create(EventTypeNames::activate, |
| 152 ExtendableEventInit(), observer); | 200 ExtendableEventInit(), observer); |
| 153 workerGlobalScope()->dispatchExtendableEvent(event, observer); | 201 workerGlobalScope()->dispatchExtendableEvent(event, observer); |
| 154 } | 202 } |
| 155 | 203 |
| 156 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent( | 204 void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent( |
| 157 int eventID, | 205 int eventID, |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 return *m_document; | 591 return *m_document; |
| 544 } | 592 } |
| 545 | 593 |
| 546 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() | 594 ServiceWorkerGlobalScope* ServiceWorkerGlobalScopeProxy::workerGlobalScope() |
| 547 const { | 595 const { |
| 548 DCHECK(m_workerGlobalScope); | 596 DCHECK(m_workerGlobalScope); |
| 549 return m_workerGlobalScope; | 597 return m_workerGlobalScope; |
| 550 } | 598 } |
| 551 | 599 |
| 552 } // namespace blink | 600 } // namespace blink |
| OLD | NEW |