| 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 26 matching lines...) Expand all Loading... |
| 37 { | 37 { |
| 38 ASSERT(registration); | 38 ASSERT(registration); |
| 39 } | 39 } |
| 40 | 40 |
| 41 ScriptPromise SyncManager::registerFunction(ScriptState* scriptState, ExecutionC
ontext* context, const String& tag) | 41 ScriptPromise SyncManager::registerFunction(ScriptState* scriptState, ExecutionC
ontext* context, const String& tag) |
| 42 { | 42 { |
| 43 // TODO(jkarlin): Wait for the registration to become active instead of reje
cting. See crbug.com/542437. | 43 // TODO(jkarlin): Wait for the registration to become active instead of reje
cting. See crbug.com/542437. |
| 44 if (!m_registration->active()) | 44 if (!m_registration->active()) |
| 45 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "Registration failed - no active Service Worker")); | 45 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(AbortError, "Registration failed - no active Service Worker")); |
| 46 | 46 |
| 47 if (scriptState->executionContext()->isDocument()) { | 47 if (scriptState->getExecutionContext()->isDocument()) { |
| 48 Document* document = toDocument(scriptState->executionContext()); | 48 Document* document = toDocument(scriptState->getExecutionContext()); |
| 49 if (!document->domWindow() || !document->frame()) | 49 if (!document->domWindow() || !document->frame()) |
| 50 return ScriptPromise::rejectWithDOMException(scriptState, DOMExcepti
on::create(InvalidStateError, "Document is detached from window.")); | 50 return ScriptPromise::rejectWithDOMException(scriptState, DOMExcepti
on::create(InvalidStateError, "Document is detached from window.")); |
| 51 if (!document->frame()->isMainFrame()) | 51 if (!document->frame()->isMainFrame()) |
| 52 return ScriptPromise::rejectWithDOMException(scriptState, DOMExcepti
on::create(AbortError, "Registration failed - not called from a main frame.")); | 52 return ScriptPromise::rejectWithDOMException(scriptState, DOMExcepti
on::create(AbortError, "Registration failed - not called from a main frame.")); |
| 53 } | 53 } |
| 54 | 54 |
| 55 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 55 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 56 ScriptPromise promise = resolver->promise(); | 56 ScriptPromise promise = resolver->promise(); |
| 57 | 57 |
| 58 WebSyncRegistration* webSyncRegistration = new WebSyncRegistration( | 58 WebSyncRegistration* webSyncRegistration = new WebSyncRegistration( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 74 | 74 |
| 75 return promise; | 75 return promise; |
| 76 } | 76 } |
| 77 | 77 |
| 78 DEFINE_TRACE(SyncManager) | 78 DEFINE_TRACE(SyncManager) |
| 79 { | 79 { |
| 80 visitor->trace(m_registration); | 80 visitor->trace(m_registration); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |