Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: third_party/WebKit/Source/modules/background_sync/SyncCallbacks.cpp

Issue 2481393002: [background-sync] Remove WebSyncError and SyncCallbacks (Closed)
Patch Set: Remove stray SyncError declaration Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "modules/background_sync/SyncCallbacks.h"
6
7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "modules/background_sync/SyncError.h"
9 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
10 #include "wtf/PtrUtil.h"
11 #include <memory>
12
13 namespace blink {
14
15 SyncRegistrationCallbacks::SyncRegistrationCallbacks(
16 ScriptPromiseResolver* resolver,
17 ServiceWorkerRegistration* serviceWorkerRegistration)
18 : m_resolver(resolver),
19 m_serviceWorkerRegistration(serviceWorkerRegistration) {
20 ASSERT(m_resolver);
21 ASSERT(m_serviceWorkerRegistration);
22 }
23
24 SyncRegistrationCallbacks::~SyncRegistrationCallbacks() {}
25
26 void SyncRegistrationCallbacks::onSuccess(
27 mojom::blink::SyncRegistrationPtr syncRegistration) {
28 if (!m_resolver->getExecutionContext() ||
29 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) {
30 return;
31 }
32
33 if (!syncRegistration) {
34 m_resolver->resolve(v8::Null(m_resolver->getScriptState()->isolate()));
35 return;
36 }
37 m_resolver->resolve();
38 }
39
40 void SyncRegistrationCallbacks::onError(const WebSyncError& error) {
41 if (!m_resolver->getExecutionContext() ||
42 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) {
43 return;
44 }
45 m_resolver->reject(SyncError::take(m_resolver.get(), error));
46 }
47
48 SyncGetRegistrationsCallbacks::SyncGetRegistrationsCallbacks(
49 ScriptPromiseResolver* resolver,
50 ServiceWorkerRegistration* serviceWorkerRegistration)
51 : m_resolver(resolver),
52 m_serviceWorkerRegistration(serviceWorkerRegistration) {
53 ASSERT(m_resolver);
54 ASSERT(m_serviceWorkerRegistration);
55 }
56
57 SyncGetRegistrationsCallbacks::~SyncGetRegistrationsCallbacks() {}
58
59 void SyncGetRegistrationsCallbacks::onSuccess(
60 const WebVector<mojom::blink::SyncRegistration*>& syncRegistrations) {
61 if (!m_resolver->getExecutionContext() ||
62 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) {
63 return;
64 }
65 Vector<String> tags;
66 for (const mojom::blink::SyncRegistration* r : syncRegistrations) {
67 tags.append(r->tag);
68 }
69 m_resolver->resolve(tags);
70 }
71
72 void SyncGetRegistrationsCallbacks::onError(const WebSyncError& error) {
73 if (!m_resolver->getExecutionContext() ||
74 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) {
75 return;
76 }
77 m_resolver->reject(SyncError::take(m_resolver.get(), error));
78 }
79
80 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698