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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 2552993002: Rename activeDOMObjectsAreStopped to isContextDestroyed (Closed)
Patch Set: Created 4 years 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 class RegistrationCallback 65 class RegistrationCallback
66 : public WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks { 66 : public WebServiceWorkerProvider::WebServiceWorkerRegistrationCallbacks {
67 public: 67 public:
68 explicit RegistrationCallback(ScriptPromiseResolver* resolver) 68 explicit RegistrationCallback(ScriptPromiseResolver* resolver)
69 : m_resolver(resolver) {} 69 : m_resolver(resolver) {}
70 ~RegistrationCallback() override {} 70 ~RegistrationCallback() override {}
71 71
72 void onSuccess( 72 void onSuccess(
73 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) override { 73 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) override {
74 if (!m_resolver->getExecutionContext() || 74 if (!m_resolver->getExecutionContext() ||
75 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 75 m_resolver->getExecutionContext()->isContextDestroyed())
76 return; 76 return;
77 m_resolver->resolve(ServiceWorkerRegistration::getOrCreate( 77 m_resolver->resolve(ServiceWorkerRegistration::getOrCreate(
78 m_resolver->getExecutionContext(), wrapUnique(handle.release()))); 78 m_resolver->getExecutionContext(), wrapUnique(handle.release())));
79 } 79 }
80 80
81 void onError(const WebServiceWorkerError& error) override { 81 void onError(const WebServiceWorkerError& error) override {
82 if (!m_resolver->getExecutionContext() || 82 if (!m_resolver->getExecutionContext() ||
83 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 83 m_resolver->getExecutionContext()->isContextDestroyed())
84 return; 84 return;
85 ScriptState::Scope scope(m_resolver->getScriptState()); 85 ScriptState::Scope scope(m_resolver->getScriptState());
86 if (error.errorType == WebServiceWorkerError::ErrorTypeType) { 86 if (error.errorType == WebServiceWorkerError::ErrorTypeType) {
87 m_resolver->reject(V8ThrowException::createTypeError( 87 m_resolver->reject(V8ThrowException::createTypeError(
88 m_resolver->getScriptState()->isolate(), error.message)); 88 m_resolver->getScriptState()->isolate(), error.message));
89 } else { 89 } else {
90 m_resolver->reject( 90 m_resolver->reject(
91 ServiceWorkerErrorForUpdate::take(m_resolver.get(), error)); 91 ServiceWorkerErrorForUpdate::take(m_resolver.get(), error));
92 } 92 }
93 } 93 }
94 94
95 private: 95 private:
96 Persistent<ScriptPromiseResolver> m_resolver; 96 Persistent<ScriptPromiseResolver> m_resolver;
97 WTF_MAKE_NONCOPYABLE(RegistrationCallback); 97 WTF_MAKE_NONCOPYABLE(RegistrationCallback);
98 }; 98 };
99 99
100 class GetRegistrationCallback : public WebServiceWorkerProvider:: 100 class GetRegistrationCallback : public WebServiceWorkerProvider::
101 WebServiceWorkerGetRegistrationCallbacks { 101 WebServiceWorkerGetRegistrationCallbacks {
102 public: 102 public:
103 explicit GetRegistrationCallback(ScriptPromiseResolver* resolver) 103 explicit GetRegistrationCallback(ScriptPromiseResolver* resolver)
104 : m_resolver(resolver) {} 104 : m_resolver(resolver) {}
105 ~GetRegistrationCallback() override {} 105 ~GetRegistrationCallback() override {}
106 106
107 void onSuccess(std::unique_ptr<WebServiceWorkerRegistration::Handle> 107 void onSuccess(std::unique_ptr<WebServiceWorkerRegistration::Handle>
108 webPassHandle) override { 108 webPassHandle) override {
109 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle = 109 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle =
110 wrapUnique(webPassHandle.release()); 110 wrapUnique(webPassHandle.release());
111 if (!m_resolver->getExecutionContext() || 111 if (!m_resolver->getExecutionContext() ||
112 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 112 m_resolver->getExecutionContext()->isContextDestroyed())
113 return; 113 return;
114 if (!handle) { 114 if (!handle) {
115 // Resolve the promise with undefined. 115 // Resolve the promise with undefined.
116 m_resolver->resolve(); 116 m_resolver->resolve();
117 return; 117 return;
118 } 118 }
119 m_resolver->resolve(ServiceWorkerRegistration::getOrCreate( 119 m_resolver->resolve(ServiceWorkerRegistration::getOrCreate(
120 m_resolver->getExecutionContext(), std::move(handle))); 120 m_resolver->getExecutionContext(), std::move(handle)));
121 } 121 }
122 122
123 void onError(const WebServiceWorkerError& error) override { 123 void onError(const WebServiceWorkerError& error) override {
124 if (!m_resolver->getExecutionContext() || 124 if (!m_resolver->getExecutionContext() ||
125 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 125 m_resolver->getExecutionContext()->isContextDestroyed())
126 return; 126 return;
127 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); 127 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error));
128 } 128 }
129 129
130 private: 130 private:
131 Persistent<ScriptPromiseResolver> m_resolver; 131 Persistent<ScriptPromiseResolver> m_resolver;
132 WTF_MAKE_NONCOPYABLE(GetRegistrationCallback); 132 WTF_MAKE_NONCOPYABLE(GetRegistrationCallback);
133 }; 133 };
134 134
135 class GetRegistrationsCallback : public WebServiceWorkerProvider:: 135 class GetRegistrationsCallback : public WebServiceWorkerProvider::
136 WebServiceWorkerGetRegistrationsCallbacks { 136 WebServiceWorkerGetRegistrationsCallbacks {
137 public: 137 public:
138 explicit GetRegistrationsCallback(ScriptPromiseResolver* resolver) 138 explicit GetRegistrationsCallback(ScriptPromiseResolver* resolver)
139 : m_resolver(resolver) {} 139 : m_resolver(resolver) {}
140 ~GetRegistrationsCallback() override {} 140 ~GetRegistrationsCallback() override {}
141 141
142 void onSuccess( 142 void onSuccess(
143 std::unique_ptr<WebVector<WebServiceWorkerRegistration::Handle*>> 143 std::unique_ptr<WebVector<WebServiceWorkerRegistration::Handle*>>
144 webPassRegistrations) override { 144 webPassRegistrations) override {
145 Vector<std::unique_ptr<WebServiceWorkerRegistration::Handle>> handles; 145 Vector<std::unique_ptr<WebServiceWorkerRegistration::Handle>> handles;
146 std::unique_ptr<WebVector<WebServiceWorkerRegistration::Handle*>> 146 std::unique_ptr<WebVector<WebServiceWorkerRegistration::Handle*>>
147 webRegistrations = wrapUnique(webPassRegistrations.release()); 147 webRegistrations = wrapUnique(webPassRegistrations.release());
148 for (auto& handle : *webRegistrations) { 148 for (auto& handle : *webRegistrations) {
149 handles.append(wrapUnique(handle)); 149 handles.append(wrapUnique(handle));
150 } 150 }
151 151
152 if (!m_resolver->getExecutionContext() || 152 if (!m_resolver->getExecutionContext() ||
153 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 153 m_resolver->getExecutionContext()->isContextDestroyed())
154 return; 154 return;
155 m_resolver->resolve( 155 m_resolver->resolve(
156 ServiceWorkerRegistrationArray::take(m_resolver.get(), &handles)); 156 ServiceWorkerRegistrationArray::take(m_resolver.get(), &handles));
157 } 157 }
158 158
159 void onError(const WebServiceWorkerError& error) override { 159 void onError(const WebServiceWorkerError& error) override {
160 if (!m_resolver->getExecutionContext() || 160 if (!m_resolver->getExecutionContext() ||
161 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 161 m_resolver->getExecutionContext()->isContextDestroyed())
162 return; 162 return;
163 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error)); 163 m_resolver->reject(ServiceWorkerError::take(m_resolver.get(), error));
164 } 164 }
165 165
166 private: 166 private:
167 Persistent<ScriptPromiseResolver> m_resolver; 167 Persistent<ScriptPromiseResolver> m_resolver;
168 WTF_MAKE_NONCOPYABLE(GetRegistrationsCallback); 168 WTF_MAKE_NONCOPYABLE(GetRegistrationsCallback);
169 }; 169 };
170 170
171 class ServiceWorkerContainer::GetRegistrationForReadyCallback 171 class ServiceWorkerContainer::GetRegistrationForReadyCallback
172 : public WebServiceWorkerProvider:: 172 : public WebServiceWorkerProvider::
173 WebServiceWorkerGetRegistrationForReadyCallbacks { 173 WebServiceWorkerGetRegistrationForReadyCallbacks {
174 public: 174 public:
175 explicit GetRegistrationForReadyCallback(ReadyProperty* ready) 175 explicit GetRegistrationForReadyCallback(ReadyProperty* ready)
176 : m_ready(ready) {} 176 : m_ready(ready) {}
177 ~GetRegistrationForReadyCallback() override {} 177 ~GetRegistrationForReadyCallback() override {}
178 178
179 void onSuccess( 179 void onSuccess(
180 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) override { 180 std::unique_ptr<WebServiceWorkerRegistration::Handle> handle) override {
181 ASSERT(m_ready->getState() == ReadyProperty::Pending); 181 ASSERT(m_ready->getState() == ReadyProperty::Pending);
182 182
183 if (m_ready->getExecutionContext() && 183 if (m_ready->getExecutionContext() &&
184 !m_ready->getExecutionContext()->activeDOMObjectsAreStopped()) 184 !m_ready->getExecutionContext()->isContextDestroyed())
185 m_ready->resolve(ServiceWorkerRegistration::getOrCreate( 185 m_ready->resolve(ServiceWorkerRegistration::getOrCreate(
186 m_ready->getExecutionContext(), wrapUnique(handle.release()))); 186 m_ready->getExecutionContext(), wrapUnique(handle.release())));
187 } 187 }
188 188
189 private: 189 private:
190 Persistent<ReadyProperty> m_ready; 190 Persistent<ReadyProperty> m_ready;
191 WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback); 191 WTF_MAKE_NONCOPYABLE(GetRegistrationForReadyCallback);
192 }; 192 };
193 193
194 ServiceWorkerContainer* ServiceWorkerContainer::create( 194 ServiceWorkerContainer* ServiceWorkerContainer::create(
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 531
532 if (ServiceWorkerContainerClient* client = 532 if (ServiceWorkerContainerClient* client =
533 ServiceWorkerContainerClient::from(executionContext)) { 533 ServiceWorkerContainerClient::from(executionContext)) {
534 m_provider = client->provider(); 534 m_provider = client->provider();
535 if (m_provider) 535 if (m_provider)
536 m_provider->setClient(this); 536 m_provider->setClient(this);
537 } 537 }
538 } 538 }
539 539
540 } // namespace blink 540 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698