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

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

Issue 2433773006: Remove ExecutionContext::activeDOMObjectsAreStopped()
Patch Set: Created 4 years, 2 months 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
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/PtrUtil.h" 10 #include "wtf/PtrUtil.h"
11 #include <memory> 11 #include <memory>
12 12
13 namespace blink { 13 namespace blink {
14 14
15 SyncRegistrationCallbacks::SyncRegistrationCallbacks( 15 SyncRegistrationCallbacks::SyncRegistrationCallbacks(
16 ScriptPromiseResolver* resolver, 16 ScriptPromiseResolver* resolver,
17 ServiceWorkerRegistration* serviceWorkerRegistration) 17 ServiceWorkerRegistration* serviceWorkerRegistration)
18 : m_resolver(resolver), 18 : m_resolver(resolver),
19 m_serviceWorkerRegistration(serviceWorkerRegistration) { 19 m_serviceWorkerRegistration(serviceWorkerRegistration) {
20 ASSERT(m_resolver); 20 ASSERT(m_resolver);
21 ASSERT(m_serviceWorkerRegistration); 21 ASSERT(m_serviceWorkerRegistration);
22 } 22 }
23 23
24 SyncRegistrationCallbacks::~SyncRegistrationCallbacks() {} 24 SyncRegistrationCallbacks::~SyncRegistrationCallbacks() {}
25 25
26 void SyncRegistrationCallbacks::onSuccess( 26 void SyncRegistrationCallbacks::onSuccess(
27 std::unique_ptr<WebSyncRegistration> webSyncRegistration) { 27 std::unique_ptr<WebSyncRegistration> webSyncRegistration) {
28 if (!m_resolver->getExecutionContext() || 28 if (!m_resolver->getExecutionContext())
29 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) {
30 return; 29 return;
31 }
32 30
33 std::unique_ptr<WebSyncRegistration> registration = 31 std::unique_ptr<WebSyncRegistration> registration =
34 wrapUnique(webSyncRegistration.release()); 32 wrapUnique(webSyncRegistration.release());
35 if (!registration) { 33 if (!registration) {
36 m_resolver->resolve(v8::Null(m_resolver->getScriptState()->isolate())); 34 m_resolver->resolve(v8::Null(m_resolver->getScriptState()->isolate()));
37 return; 35 return;
38 } 36 }
39 m_resolver->resolve(); 37 m_resolver->resolve();
40 } 38 }
41 39
42 void SyncRegistrationCallbacks::onError(const WebSyncError& error) { 40 void SyncRegistrationCallbacks::onError(const WebSyncError& error) {
43 if (!m_resolver->getExecutionContext() || 41 if (!m_resolver->getExecutionContext())
44 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) {
45 return; 42 return;
46 }
47 m_resolver->reject(SyncError::take(m_resolver.get(), error)); 43 m_resolver->reject(SyncError::take(m_resolver.get(), error));
48 } 44 }
49 45
50 SyncGetRegistrationsCallbacks::SyncGetRegistrationsCallbacks( 46 SyncGetRegistrationsCallbacks::SyncGetRegistrationsCallbacks(
51 ScriptPromiseResolver* resolver, 47 ScriptPromiseResolver* resolver,
52 ServiceWorkerRegistration* serviceWorkerRegistration) 48 ServiceWorkerRegistration* serviceWorkerRegistration)
53 : m_resolver(resolver), 49 : m_resolver(resolver),
54 m_serviceWorkerRegistration(serviceWorkerRegistration) { 50 m_serviceWorkerRegistration(serviceWorkerRegistration) {
55 ASSERT(m_resolver); 51 ASSERT(m_resolver);
56 ASSERT(m_serviceWorkerRegistration); 52 ASSERT(m_serviceWorkerRegistration);
57 } 53 }
58 54
59 SyncGetRegistrationsCallbacks::~SyncGetRegistrationsCallbacks() {} 55 SyncGetRegistrationsCallbacks::~SyncGetRegistrationsCallbacks() {}
60 56
61 void SyncGetRegistrationsCallbacks::onSuccess( 57 void SyncGetRegistrationsCallbacks::onSuccess(
62 const WebVector<WebSyncRegistration*>& webSyncRegistrations) { 58 const WebVector<WebSyncRegistration*>& webSyncRegistrations) {
63 if (!m_resolver->getExecutionContext() || 59 if (!m_resolver->getExecutionContext())
64 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) {
65 return; 60 return;
66 }
67 Vector<String> tags; 61 Vector<String> tags;
68 for (const WebSyncRegistration* r : webSyncRegistrations) { 62 for (const WebSyncRegistration* r : webSyncRegistrations) {
69 tags.append(r->tag); 63 tags.append(r->tag);
70 } 64 }
71 m_resolver->resolve(tags); 65 m_resolver->resolve(tags);
72 } 66 }
73 67
74 void SyncGetRegistrationsCallbacks::onError(const WebSyncError& error) { 68 void SyncGetRegistrationsCallbacks::onError(const WebSyncError& error) {
75 if (!m_resolver->getExecutionContext() || 69 if (!m_resolver->getExecutionContext())
76 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) {
77 return; 70 return;
78 }
79 m_resolver->reject(SyncError::take(m_resolver.get(), error)); 71 m_resolver->reject(SyncError::take(m_resolver.get(), error));
80 } 72 }
81 73
82 } // namespace blink 74 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698