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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.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 // 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/bluetooth/BluetoothRemoteGATTServer.h" 5 #include "modules/bluetooth/BluetoothRemoteGATTServer.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 "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 visitor->trace(m_device); 55 visitor->trace(m_device);
56 } 56 }
57 57
58 class ConnectCallback : public WebBluetoothRemoteGATTServerConnectCallbacks { 58 class ConnectCallback : public WebBluetoothRemoteGATTServerConnectCallbacks {
59 public: 59 public:
60 ConnectCallback(BluetoothDevice* device, ScriptPromiseResolver* resolver) 60 ConnectCallback(BluetoothDevice* device, ScriptPromiseResolver* resolver)
61 : m_device(device), m_resolver(resolver) {} 61 : m_device(device), m_resolver(resolver) {}
62 62
63 void onSuccess() override { 63 void onSuccess() override {
64 if (!m_resolver->getExecutionContext() || 64 if (!m_resolver->getExecutionContext() ||
65 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 65 m_resolver->getExecutionContext()->isContextDestroyed())
66 return; 66 return;
67 m_device->gatt()->setConnected(true); 67 m_device->gatt()->setConnected(true);
68 m_resolver->resolve(m_device->gatt()); 68 m_resolver->resolve(m_device->gatt());
69 } 69 }
70 70
71 void onError( 71 void onError(
72 int32_t 72 int32_t
73 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) 73 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */)
74 override { 74 override {
75 if (!m_resolver->getExecutionContext() || 75 if (!m_resolver->getExecutionContext() ||
76 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 76 m_resolver->getExecutionContext()->isContextDestroyed())
77 return; 77 return;
78 m_resolver->reject(BluetoothError::take(m_resolver, error)); 78 m_resolver->reject(BluetoothError::take(m_resolver, error));
79 } 79 }
80 80
81 private: 81 private:
82 Persistent<BluetoothDevice> m_device; 82 Persistent<BluetoothDevice> m_device;
83 Persistent<ScriptPromiseResolver> m_resolver; 83 Persistent<ScriptPromiseResolver> m_resolver;
84 }; 84 };
85 85
86 ScriptPromise BluetoothRemoteGATTServer::connect(ScriptState* scriptState) { 86 ScriptPromise BluetoothRemoteGATTServer::connect(ScriptState* scriptState) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 : m_device(device), m_quantity(quantity), m_resolver(resolver) { 118 : m_device(device), m_quantity(quantity), m_resolver(resolver) {
119 // We always check that the device is connected before constructing this 119 // We always check that the device is connected before constructing this
120 // object. 120 // object.
121 CHECK(m_device->gatt()->connected()); 121 CHECK(m_device->gatt()->connected());
122 m_device->gatt()->AddToActiveAlgorithms(m_resolver.get()); 122 m_device->gatt()->AddToActiveAlgorithms(m_resolver.get());
123 } 123 }
124 124
125 void onSuccess( 125 void onSuccess(
126 const WebVector<WebBluetoothRemoteGATTService*>& webServices) override { 126 const WebVector<WebBluetoothRemoteGATTService*>& webServices) override {
127 if (!m_resolver->getExecutionContext() || 127 if (!m_resolver->getExecutionContext() ||
128 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 128 m_resolver->getExecutionContext()->isContextDestroyed())
129 return; 129 return;
130 130
131 // If the resolver is not in the set of ActiveAlgorithms then the frame 131 // If the resolver is not in the set of ActiveAlgorithms then the frame
132 // disconnected so we reject. 132 // disconnected so we reject.
133 if (!m_device->gatt()->RemoveFromActiveAlgorithms(m_resolver.get())) { 133 if (!m_device->gatt()->RemoveFromActiveAlgorithms(m_resolver.get())) {
134 m_resolver->reject( 134 m_resolver->reject(
135 DOMException::create(NetworkError, kGATTServerDisconnected)); 135 DOMException::create(NetworkError, kGATTServerDisconnected));
136 return; 136 return;
137 } 137 }
138 138
(...skipping 11 matching lines...) Expand all
150 wrapUnique(webService))); 150 wrapUnique(webService)));
151 } 151 }
152 m_resolver->resolve(services); 152 m_resolver->resolve(services);
153 } 153 }
154 154
155 void onError( 155 void onError(
156 int32_t 156 int32_t
157 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) 157 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */)
158 override { 158 override {
159 if (!m_resolver->getExecutionContext() || 159 if (!m_resolver->getExecutionContext() ||
160 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) 160 m_resolver->getExecutionContext()->isContextDestroyed())
161 return; 161 return;
162 162
163 if (!m_device->gatt()->RemoveFromActiveAlgorithms(m_resolver.get())) { 163 if (!m_device->gatt()->RemoveFromActiveAlgorithms(m_resolver.get())) {
164 m_resolver->reject( 164 m_resolver->reject(
165 DOMException::create(NetworkError, kGATTServerDisconnected)); 165 DOMException::create(NetworkError, kGATTServerDisconnected));
166 return; 166 return;
167 } 167 }
168 168
169 m_resolver->reject(BluetoothError::take(m_resolver, error)); 169 m_resolver->reject(BluetoothError::take(m_resolver, error));
170 } 170 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 WebBluetooth* webbluetooth = 224 WebBluetooth* webbluetooth =
225 BluetoothSupplement::fromScriptState(scriptState); 225 BluetoothSupplement::fromScriptState(scriptState);
226 webbluetooth->getPrimaryServices( 226 webbluetooth->getPrimaryServices(
227 device()->id(), static_cast<int32_t>(quantity), servicesUUID, 227 device()->id(), static_cast<int32_t>(quantity), servicesUUID,
228 new GetPrimaryServicesCallback(device(), quantity, resolver)); 228 new GetPrimaryServicesCallback(device(), quantity, resolver));
229 229
230 return promise; 230 return promise;
231 } 231 }
232 232
233 } // namespace blink 233 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698