| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/background_sync/SyncManager.h" | 5 #include "modules/background_sync/SyncManager.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 SyncManager::SyncManager(ServiceWorkerRegistration* registration) | 32 SyncManager::SyncManager(ServiceWorkerRegistration* registration) |
| 33 : m_registration(registration) { | 33 : m_registration(registration) { |
| 34 ASSERT(registration); | 34 ASSERT(registration); |
| 35 } | 35 } |
| 36 | 36 |
| 37 ScriptPromise SyncManager::registerFunction(ScriptState* scriptState, | 37 ScriptPromise SyncManager::registerFunction(ScriptState* scriptState, |
| 38 ExecutionContext* context, | 38 ExecutionContext* context, |
| 39 const String& tag) { | 39 const String& tag) { |
| 40 // TODO(jkarlin): Wait for the registration to become active instead of reject
ing. See crbug.com/542437. | 40 // TODO(jkarlin): Wait for the registration to become active instead of |
| 41 // rejecting. See crbug.com/542437. |
| 41 if (!m_registration->active()) | 42 if (!m_registration->active()) |
| 42 return ScriptPromise::rejectWithDOMException( | 43 return ScriptPromise::rejectWithDOMException( |
| 43 scriptState, | 44 scriptState, |
| 44 DOMException::create(AbortError, | 45 DOMException::create(AbortError, |
| 45 "Registration failed - no active Service Worker")); | 46 "Registration failed - no active Service Worker")); |
| 46 | 47 |
| 47 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 48 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 48 ScriptPromise promise = resolver->promise(); | 49 ScriptPromise promise = resolver->promise(); |
| 49 | 50 |
| 50 WebSyncRegistration* webSyncRegistration = new WebSyncRegistration( | 51 WebSyncRegistration* webSyncRegistration = new WebSyncRegistration( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 67 new SyncGetRegistrationsCallbacks(resolver, m_registration)); | 68 new SyncGetRegistrationsCallbacks(resolver, m_registration)); |
| 68 | 69 |
| 69 return promise; | 70 return promise; |
| 70 } | 71 } |
| 71 | 72 |
| 72 DEFINE_TRACE(SyncManager) { | 73 DEFINE_TRACE(SyncManager) { |
| 73 visitor->trace(m_registration); | 74 visitor->trace(m_registration); |
| 74 } | 75 } |
| 75 | 76 |
| 76 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |