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/SyncCallbacks.h" | 5 #include "modules/background_sync/SyncCallbacks.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
8 #include "modules/background_sync/SyncError.h" | 8 #include "modules/background_sync/SyncError.h" |
9 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 9 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
10 #include "wtf/OwnPtr.h" | 10 #include "wtf/OwnPtr.h" |
11 #include "wtf/PassOwnPtr.h" | 11 #include "wtf/PassOwnPtr.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 SyncRegistrationCallbacks::SyncRegistrationCallbacks(ScriptPromiseResolver* reso lver, ServiceWorkerRegistration* serviceWorkerRegistration) | 15 SyncRegistrationCallbacks::SyncRegistrationCallbacks(ScriptPromiseResolver* reso lver, ServiceWorkerRegistration* serviceWorkerRegistration) |
16 : m_resolver(resolver) | 16 : m_resolver(resolver) |
17 , m_serviceWorkerRegistration(serviceWorkerRegistration) | 17 , m_serviceWorkerRegistration(serviceWorkerRegistration) |
18 { | 18 { |
19 ASSERT(m_resolver); | 19 ASSERT(m_resolver); |
20 ASSERT(m_serviceWorkerRegistration); | 20 ASSERT(m_serviceWorkerRegistration); |
21 } | 21 } |
22 | 22 |
23 SyncRegistrationCallbacks::~SyncRegistrationCallbacks() | 23 SyncRegistrationCallbacks::~SyncRegistrationCallbacks() |
24 { | 24 { |
25 } | 25 } |
26 | 26 |
27 void SyncRegistrationCallbacks::onSuccess(WebPassOwnPtr<WebSyncRegistration> web SyncRegistration) | 27 void SyncRegistrationCallbacks::onSuccess(std::unique_ptr<WebSyncRegistration> w ebSyncRegistration) |
28 { | 28 { |
29 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContext()- >activeDOMObjectsAreStopped()) { | 29 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContext()- >activeDOMObjectsAreStopped()) { |
30 return; | 30 return; |
31 } | 31 } |
32 | 32 |
33 OwnPtr<WebSyncRegistration> registration = webSyncRegistration.release(); | 33 OwnPtr<WebSyncRegistration> registration = adoptPtr(webSyncRegistration.rele ase()); |
dcheng
2016/04/07 00:26:12
FWIW, I think we'd be saving ourself trouble down
| |
34 if (!registration) { | 34 if (!registration) { |
35 m_resolver->resolve(v8::Null(m_resolver->getScriptState()->isolate())); | 35 m_resolver->resolve(v8::Null(m_resolver->getScriptState()->isolate())); |
36 return; | 36 return; |
37 } | 37 } |
38 m_resolver->resolve(); | 38 m_resolver->resolve(); |
39 } | 39 } |
40 | 40 |
41 void SyncRegistrationCallbacks::onError(const WebSyncError& error) | 41 void SyncRegistrationCallbacks::onError(const WebSyncError& error) |
42 { | 42 { |
43 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContext()- >activeDOMObjectsAreStopped()) { | 43 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContext()- >activeDOMObjectsAreStopped()) { |
(...skipping 28 matching lines...) Expand all Loading... | |
72 | 72 |
73 void SyncGetRegistrationsCallbacks::onError(const WebSyncError& error) | 73 void SyncGetRegistrationsCallbacks::onError(const WebSyncError& error) |
74 { | 74 { |
75 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContext()- >activeDOMObjectsAreStopped()) { | 75 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContext()- >activeDOMObjectsAreStopped()) { |
76 return; | 76 return; |
77 } | 77 } |
78 m_resolver->reject(SyncError::take(m_resolver.get(), error)); | 78 m_resolver->reject(SyncError::take(m_resolver.get(), error)); |
79 } | 79 } |
80 | 80 |
81 } // namespace blink | 81 } // namespace blink |
OLD | NEW |