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

Side by Side Diff: content/browser/bluetooth/web_bluetooth_service_impl.cc

Issue 1861013005: bluetooth: Move GetCharacteristic(s) over to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-separate-tests-read-value
Patch Set: Merge Created 4 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // ID Not In Map Note:
6 // A service, characteristic, or descriptor ID not in the corresponding
7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_,
8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer
Jeffrey Yasskin 2016/04/22 01:16:38 This may not be true after all: if we revoke acces
ortuno 2016/04/25 15:29:45 Yup. Opened issue so we don't forget: http://crbug
9 // obtains the corresponding ID from this class and it will be added to the map
10 // at that time.
11
5 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" 12 #include "content/browser/bluetooth/web_bluetooth_service_impl.h"
6 13
7 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
8 #include "content/browser/bluetooth/bluetooth_blacklist.h" 15 #include "content/browser/bluetooth/bluetooth_blacklist.h"
9 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" 16 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h"
10 #include "content/browser/renderer_host/render_process_host_impl.h" 17 #include "content/browser/renderer_host/render_process_host_impl.h"
11 #include "content/public/browser/navigation_handle.h" 18 #include "content/public/browser/navigation_handle.h"
12 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
13 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
14 #include "device/bluetooth/bluetooth_gatt_characteristic.h" 21 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return blink::mojom::WebBluetoothError::GATT_NOT_PAIRED; 58 return blink::mojom::WebBluetoothError::GATT_NOT_PAIRED;
52 case BluetoothGattService::GATT_ERROR_NOT_SUPPORTED: 59 case BluetoothGattService::GATT_ERROR_NOT_SUPPORTED:
53 RecordGATTOperationOutcome(operation, 60 RecordGATTOperationOutcome(operation,
54 UMAGATTOperationOutcome::NOT_SUPPORTED); 61 UMAGATTOperationOutcome::NOT_SUPPORTED);
55 return blink::mojom::WebBluetoothError::GATT_NOT_SUPPORTED; 62 return blink::mojom::WebBluetoothError::GATT_NOT_SUPPORTED;
56 } 63 }
57 NOTREACHED(); 64 NOTREACHED();
58 return blink::mojom::WebBluetoothError::GATT_UNTRANSLATED_ERROR_CODE; 65 return blink::mojom::WebBluetoothError::GATT_UNTRANSLATED_ERROR_CODE;
59 } 66 }
60 67
68 // TODO(ortuno): This should really be a BluetoothDevice method.
69 // Replace when implemented. http://crbug.com/552022
70 std::vector<device::BluetoothGattCharacteristic*> GetCharacteristicsByUUID(
71 device::BluetoothGattService* service,
72 const std::string& characteristic_uuid) {
73 std::vector<device::BluetoothGattCharacteristic*> characteristics;
74 VLOG(1) << "Looking for characteristic: " << characteristic_uuid;
75 for (device::BluetoothGattCharacteristic* characteristic :
76 service->GetCharacteristics()) {
77 VLOG(1) << "Characteristic in cache: "
78 << characteristic->GetUUID().canonical_value();
79 if (characteristic->GetUUID().canonical_value() == characteristic_uuid) {
80 characteristics.push_back(characteristic);
81 }
82 }
83 return characteristics;
84 }
85
61 } // namespace 86 } // namespace
62 87
63 using CacheQueryResult = BluetoothDispatcherHost::CacheQueryResult;
64
65 WebBluetoothServiceImpl::WebBluetoothServiceImpl( 88 WebBluetoothServiceImpl::WebBluetoothServiceImpl(
66 RenderFrameHost* render_frame_host, 89 RenderFrameHost* render_frame_host,
67 blink::mojom::WebBluetoothServiceRequest request) 90 blink::mojom::WebBluetoothServiceRequest request)
68 : WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)), 91 : WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)),
69 render_frame_host_(render_frame_host), 92 render_frame_host_(render_frame_host),
70 binding_(this, std::move(request)), 93 binding_(this, std::move(request)),
71 weak_ptr_factory_(this) { 94 weak_ptr_factory_(this) {
72 DCHECK_CURRENTLY_ON(BrowserThread::UI); 95 DCHECK_CURRENTLY_ON(BrowserThread::UI);
73 CHECK(web_contents()); 96 CHECK(web_contents());
74 97
75 GetBluetoothDispatcherHost()->AddAdapterObserver(this); 98 GetBluetoothDispatcherHost()->AddAdapterObserver(this);
76 } 99 }
77 100
78 WebBluetoothServiceImpl::~WebBluetoothServiceImpl() { 101 WebBluetoothServiceImpl::~WebBluetoothServiceImpl() {
79 DCHECK_CURRENTLY_ON(BrowserThread::UI); 102 DCHECK_CURRENTLY_ON(BrowserThread::UI);
80 GetBluetoothDispatcherHost()->RemoveAdapterObserver(this); 103 GetBluetoothDispatcherHost()->RemoveAdapterObserver(this);
81 } 104 }
82 105
83 void WebBluetoothServiceImpl::SetClientConnectionErrorHandler( 106 void WebBluetoothServiceImpl::SetClientConnectionErrorHandler(
84 base::Closure closure) { 107 base::Closure closure) {
85 binding_.set_connection_error_handler(closure); 108 binding_.set_connection_error_handler(closure);
86 } 109 }
87 110
88 void WebBluetoothServiceImpl::DidFinishNavigation( 111 void WebBluetoothServiceImpl::DidFinishNavigation(
89 NavigationHandle* navigation_handle) { 112 NavigationHandle* navigation_handle) {
90 if (navigation_handle->HasCommitted() && 113 if (navigation_handle->HasCommitted() &&
91 navigation_handle->GetRenderFrameHost() == render_frame_host_ && 114 navigation_handle->GetRenderFrameHost() == render_frame_host_ &&
92 !navigation_handle->IsSamePage()) { 115 !navigation_handle->IsSamePage()) {
93 // After navigation we need to clear the frame's state.
94 ClearState(); 116 ClearState();
95 } 117 }
96 } 118 }
97 119
98 void WebBluetoothServiceImpl::AdapterPresentChanged( 120 void WebBluetoothServiceImpl::AdapterPresentChanged(
99 device::BluetoothAdapter* adapter, 121 device::BluetoothAdapter* adapter,
100 bool present) { 122 bool present) {
101 if (!present) { 123 if (!present) {
102 ClearState(); 124 ClearState();
103 } 125 }
104 } 126 }
105 127
106 void WebBluetoothServiceImpl::GattCharacteristicValueChanged( 128 void WebBluetoothServiceImpl::GattCharacteristicValueChanged(
107 device::BluetoothAdapter* adapter, 129 device::BluetoothAdapter* adapter,
108 device::BluetoothGattCharacteristic* characteristic, 130 device::BluetoothGattCharacteristic* characteristic,
109 const std::vector<uint8_t>& value) { 131 const std::vector<uint8_t>& value) {
110 // TODO(ortuno): Only send characteristic value changed events for 132 // Don't notify of characteristics that we haven't returned.
111 // characteristics that we've returned in the past. We can't yet do 133 if (!ContainsKey(characteristic_to_service_,
112 // this because WebBluetoothServiceImpl doesn't have direct access 134 characteristic->GetIdentifier())) {
113 // to the list of returned characteristics.
114 // https://crbug.com/508771
115 if (BluetoothBlacklist::Get().IsExcluded(characteristic->GetUUID())) {
116 return; 135 return;
117 } 136 }
118 137
119 // On Chrome OS and Linux, GattCharacteristicValueChanged is called before the 138 // On Chrome OS and Linux, GattCharacteristicValueChanged is called before the
120 // success callback for ReadRemoteCharacteristic is called, which could result 139 // success callback for ReadRemoteCharacteristic is called, which could result
121 // in an event being fired before the readValue promise is resolved. 140 // in an event being fired before the readValue promise is resolved.
122 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( 141 if (!base::ThreadTaskRunnerHandle::Get()->PostTask(
123 FROM_HERE, 142 FROM_HERE,
124 base::Bind(&WebBluetoothServiceImpl::NotifyCharacteristicValueChanged, 143 base::Bind(&WebBluetoothServiceImpl::NotifyCharacteristicValueChanged,
125 weak_ptr_factory_.GetWeakPtr(), 144 weak_ptr_factory_.GetWeakPtr(),
(...skipping 10 matching lines...) Expand all
136 characteristic_instance_id, mojo::Array<uint8_t>(std::move(value))); 155 characteristic_instance_id, mojo::Array<uint8_t>(std::move(value)));
137 } 156 }
138 } 157 }
139 158
140 void WebBluetoothServiceImpl::SetClient( 159 void WebBluetoothServiceImpl::SetClient(
141 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo client) { 160 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo client) {
142 DCHECK(!client_.get()); 161 DCHECK(!client_.get());
143 client_.Bind(std::move(client)); 162 client_.Bind(std::move(client));
144 } 163 }
145 164
165 void WebBluetoothServiceImpl::RemoteServiceGetCharacteristics(
166 const mojo::String& service_instance_id,
167 bool single_characteristic,
168 const mojo::String& characteristics_uuid,
169 const RemoteServiceGetCharacteristicsCallback& callback) {
170 DCHECK_CURRENTLY_ON(BrowserThread::UI);
171 RecordWebBluetoothFunctionCall(
172 single_characteristic
173 ? UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTIC
174 : UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTICS);
175 RecordGetCharacteristicsCharacteristic(single_characteristic,
176 characteristics_uuid);
177
178 if (!characteristics_uuid.is_null() &&
179 BluetoothBlacklist::Get().IsExcluded(
180 device::BluetoothUUID(characteristics_uuid))) {
181 RecordGetCharacteristicsOutcome(single_characteristic,
182 UMAGetCharacteristicOutcome::BLACKLISTED);
183 callback.Run(
184 blink::mojom::WebBluetoothError::BLACKLISTED_CHARACTERISTIC_UUID,
185 nullptr /* characteristics */);
186 return;
187 }
188
189 const CacheQueryResult query_result =
190 GetBluetoothDispatcherHost()->QueryCacheForService(GetOrigin(),
191 service_instance_id);
192
193 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
194 binding_.Close();
195 return;
196 }
197
198 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
199 RecordGetCharacteristicsOutcome(single_characteristic,
200 query_result.outcome);
201 callback.Run(query_result.GetWebError(), nullptr /* characteristics */);
202 return;
203 }
204
205 std::vector<device::BluetoothGattCharacteristic*> characteristics =
206 characteristics_uuid.is_null()
207 ? query_result.service->GetCharacteristics()
208 : GetCharacteristicsByUUID(query_result.service,
209 characteristics_uuid);
210
211 mojo::Array<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr>
212 response_characteristics;
213 for (device::BluetoothGattCharacteristic* characteristic : characteristics) {
214 if (BluetoothBlacklist::Get().IsExcluded(characteristic->GetUUID())) {
215 continue;
216 }
217 std::string characteristic_instance_id = characteristic->GetIdentifier();
218 auto insert_result = characteristic_to_service_.insert(
219 std::make_pair(characteristic_instance_id, service_instance_id));
220 // If value is already in map, DCHECK it's valid.
221 if (!insert_result.second)
222 DCHECK(insert_result.first->second == service_instance_id);
223
224 blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr characteristic_ptr =
225 blink::mojom::WebBluetoothRemoteGATTCharacteristic::New();
226 characteristic_ptr->instance_id =
227 mojo::String::From(characteristic_instance_id);
228 characteristic_ptr->uuid =
229 characteristics_uuid.is_null()
230 ? mojo::String::From(characteristic->GetUUID().canonical_value())
231 : nullptr;
Jeffrey Yasskin 2016/04/22 01:16:38 The characteristic has a UUID even if the user isn
ortuno 2016/04/25 15:29:45 If the user is filtering by UUID then the renderer
Jeffrey Yasskin 2016/04/25 17:26:10 Yeah, we might DCHECK that they're the same on the
ortuno 2016/04/25 20:37:41 Done.
232 characteristic_ptr->properties =
233 static_cast<uint32_t>(characteristic->GetProperties());
234 response_characteristics.push_back(std::move(characteristic_ptr));
235
236 if (single_characteristic) {
237 break;
238 }
239 }
240
241 if (!response_characteristics.empty()) {
242 RecordGetCharacteristicsOutcome(single_characteristic,
243 UMAGetCharacteristicOutcome::SUCCESS);
244 callback.Run(blink::mojom::WebBluetoothError::SUCCESS,
245 std::move(response_characteristics));
246 return;
247 }
248 RecordGetCharacteristicsOutcome(
249 single_characteristic,
250 characteristics_uuid.is_null()
251 ? UMAGetCharacteristicOutcome::NO_CHARACTERISTICS
252 : UMAGetCharacteristicOutcome::NOT_FOUND);
253 callback.Run(characteristics_uuid.is_null()
254 ? blink::mojom::WebBluetoothError::NO_CHARACTERISTICS_FOUND
255 : blink::mojom::WebBluetoothError::CHARACTERISTIC_NOT_FOUND,
256 nullptr /* characteristics */);
257 return;
258 }
259
146 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue( 260 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue(
147 const mojo::String& characteristic_instance_id, 261 const mojo::String& characteristic_instance_id,
148 const RemoteCharacteristicReadValueCallback& callback) { 262 const RemoteCharacteristicReadValueCallback& callback) {
149 DCHECK_CURRENTLY_ON(BrowserThread::UI); 263 DCHECK_CURRENTLY_ON(BrowserThread::UI);
150 RecordWebBluetoothFunctionCall( 264 RecordWebBluetoothFunctionCall(
151 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE); 265 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE);
152 266
153 const CacheQueryResult query_result = 267 const CacheQueryResult query_result =
154 GetBluetoothDispatcherHost()->QueryCacheForCharacteristic( 268 QueryCacheForCharacteristic(characteristic_instance_id);
155 GetOrigin(), characteristic_instance_id);
156 269
157 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 270 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
158 return; 271 return;
159 } 272 }
160 273
161 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 274 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
162 RecordCharacteristicReadValueOutcome(query_result.outcome); 275 RecordCharacteristicReadValueOutcome(query_result.outcome);
163 callback.Run(query_result.GetWebError(), nullptr /* value */); 276 callback.Run(query_result.GetWebError(), nullptr /* value */);
164 return; 277 return;
165 } 278 }
(...skipping 23 matching lines...) Expand all
189 302
190 // We perform the length check on the renderer side. So if we 303 // We perform the length check on the renderer side. So if we
191 // get a value with length > 512, we can assume it's a hostile 304 // get a value with length > 512, we can assume it's a hostile
192 // renderer and kill it. 305 // renderer and kill it.
193 if (value.size() > 512) { 306 if (value.size() > 512) {
194 CrashRendererAndClosePipe(bad_message::BDH_INVALID_WRITE_VALUE_LENGTH); 307 CrashRendererAndClosePipe(bad_message::BDH_INVALID_WRITE_VALUE_LENGTH);
195 return; 308 return;
196 } 309 }
197 310
198 const CacheQueryResult query_result = 311 const CacheQueryResult query_result =
199 GetBluetoothDispatcherHost()->QueryCacheForCharacteristic( 312 QueryCacheForCharacteristic(characteristic_instance_id);
200 GetOrigin(), characteristic_instance_id);
201 313
202 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 314 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
203 binding_.Close();
204 return; 315 return;
205 } 316 }
206 317
207 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 318 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
208 RecordCharacteristicWriteValueOutcome(query_result.outcome); 319 RecordCharacteristicWriteValueOutcome(query_result.outcome);
209 callback.Run(query_result.GetWebError()); 320 callback.Run(query_result.GetWebError());
210 return; 321 return;
211 } 322 }
212 323
213 if (BluetoothBlacklist::Get().IsExcludedFromWrites( 324 if (BluetoothBlacklist::Get().IsExcludedFromWrites(
(...skipping 22 matching lines...) Expand all
236 characteristic_id_to_notify_session_.find(characteristic_instance_id); 347 characteristic_id_to_notify_session_.find(characteristic_instance_id);
237 if (iter != characteristic_id_to_notify_session_.end() && 348 if (iter != characteristic_id_to_notify_session_.end() &&
238 iter->second->IsActive()) { 349 iter->second->IsActive()) {
239 // If the frame has already started notifications and the notifications 350 // If the frame has already started notifications and the notifications
240 // are active we return SUCCESS. 351 // are active we return SUCCESS.
241 callback.Run(blink::mojom::WebBluetoothError::SUCCESS); 352 callback.Run(blink::mojom::WebBluetoothError::SUCCESS);
242 return; 353 return;
243 } 354 }
244 355
245 const CacheQueryResult query_result = 356 const CacheQueryResult query_result =
246 GetBluetoothDispatcherHost()->QueryCacheForCharacteristic( 357 QueryCacheForCharacteristic(characteristic_instance_id);
247 GetOrigin(), characteristic_instance_id);
248 358
249 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 359 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
250 binding_.Close();
251 return; 360 return;
252 } 361 }
253 362
254 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 363 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
255 RecordStartNotificationsOutcome(query_result.outcome); 364 RecordStartNotificationsOutcome(query_result.outcome);
256 callback.Run(query_result.GetWebError()); 365 callback.Run(query_result.GetWebError());
257 return; 366 return;
258 } 367 }
259 368
260 device::BluetoothGattCharacteristic::Properties notify_or_indicate = 369 device::BluetoothGattCharacteristic::Properties notify_or_indicate =
(...skipping 13 matching lines...) Expand all
274 } 383 }
275 384
276 void WebBluetoothServiceImpl::RemoteCharacteristicStopNotifications( 385 void WebBluetoothServiceImpl::RemoteCharacteristicStopNotifications(
277 const mojo::String& characteristic_instance_id, 386 const mojo::String& characteristic_instance_id,
278 const RemoteCharacteristicStopNotificationsCallback& callback) { 387 const RemoteCharacteristicStopNotificationsCallback& callback) {
279 DCHECK_CURRENTLY_ON(BrowserThread::UI); 388 DCHECK_CURRENTLY_ON(BrowserThread::UI);
280 RecordWebBluetoothFunctionCall( 389 RecordWebBluetoothFunctionCall(
281 UMAWebBluetoothFunction::CHARACTERISTIC_STOP_NOTIFICATIONS); 390 UMAWebBluetoothFunction::CHARACTERISTIC_STOP_NOTIFICATIONS);
282 391
283 const CacheQueryResult query_result = 392 const CacheQueryResult query_result =
284 GetBluetoothDispatcherHost()->QueryCacheForCharacteristic( 393 QueryCacheForCharacteristic(characteristic_instance_id);
285 GetOrigin(), characteristic_instance_id);
286 394
287 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 395 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
288 binding_.Close();
289 return; 396 return;
290 } 397 }
291 398
292 auto notify_session_iter = 399 auto notify_session_iter =
293 characteristic_id_to_notify_session_.find(characteristic_instance_id); 400 characteristic_id_to_notify_session_.find(characteristic_instance_id);
294 if (notify_session_iter == characteristic_id_to_notify_session_.end()) { 401 if (notify_session_iter == characteristic_id_to_notify_session_.end()) {
295 // If the frame hasn't subscribed to notifications before we just 402 // If the frame hasn't subscribed to notifications before we just
296 // run the callback. 403 // run the callback.
297 callback.Run(); 404 callback.Run();
298 return; 405 return;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 error_code, UMAGATTOperation::START_NOTIFICATIONS)); 464 error_code, UMAGATTOperation::START_NOTIFICATIONS));
358 } 465 }
359 466
360 void WebBluetoothServiceImpl::OnStopNotifySessionComplete( 467 void WebBluetoothServiceImpl::OnStopNotifySessionComplete(
361 const std::string& characteristic_instance_id, 468 const std::string& characteristic_instance_id,
362 const RemoteCharacteristicStopNotificationsCallback& callback) { 469 const RemoteCharacteristicStopNotificationsCallback& callback) {
363 characteristic_id_to_notify_session_.erase(characteristic_instance_id); 470 characteristic_id_to_notify_session_.erase(characteristic_instance_id);
364 callback.Run(); 471 callback.Run();
365 } 472 }
366 473
474 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForCharacteristic(
475 const std::string& characteristic_instance_id) {
476 auto characteristic_iter =
477 characteristic_to_service_.find(characteristic_instance_id);
478
479 // Kill the render, see "ID Not in Map Note" above.
480 if (characteristic_iter == characteristic_to_service_.end()) {
481 CrashRendererAndClosePipe(bad_message::BDH_INVALID_CHARACTERISTIC_ID);
482 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER);
483 }
484
485 CacheQueryResult result = GetBluetoothDispatcherHost()->QueryCacheForService(
Jeffrey Yasskin 2016/04/22 01:16:38 Do you need to close the binding_ if this returns
ortuno 2016/04/25 15:29:45 Done.
486 GetOrigin(), characteristic_iter->second);
487 if (result.outcome != CacheQueryOutcome::SUCCESS) {
488 return result;
489 }
490
491 result.characteristic =
492 result.service->GetCharacteristic(characteristic_instance_id);
493
494 if (result.characteristic == nullptr) {
495 result.outcome = CacheQueryOutcome::NO_CHARACTERISTIC;
496 }
497
498 return result;
499 }
500
367 RenderProcessHost* WebBluetoothServiceImpl::GetRenderProcessHost() { 501 RenderProcessHost* WebBluetoothServiceImpl::GetRenderProcessHost() {
368 return render_frame_host_->GetProcess(); 502 return render_frame_host_->GetProcess();
369 } 503 }
370 504
371 BluetoothDispatcherHost* WebBluetoothServiceImpl::GetBluetoothDispatcherHost() { 505 BluetoothDispatcherHost* WebBluetoothServiceImpl::GetBluetoothDispatcherHost() {
372 RenderProcessHostImpl* render_process_host_impl = 506 RenderProcessHostImpl* render_process_host_impl =
373 static_cast<RenderProcessHostImpl*>(GetRenderProcessHost()); 507 static_cast<RenderProcessHostImpl*>(GetRenderProcessHost());
374 return render_process_host_impl->GetBluetoothDispatcherHost(); 508 return render_process_host_impl->GetBluetoothDispatcherHost();
375 } 509 }
376 510
377 void WebBluetoothServiceImpl::CrashRendererAndClosePipe( 511 void WebBluetoothServiceImpl::CrashRendererAndClosePipe(
378 bad_message::BadMessageReason reason) { 512 bad_message::BadMessageReason reason) {
379 bad_message::ReceivedBadMessage(GetRenderProcessHost(), reason); 513 bad_message::ReceivedBadMessage(GetRenderProcessHost(), reason);
380 binding_.Close(); 514 binding_.Close();
381 } 515 }
382 516
383 url::Origin WebBluetoothServiceImpl::GetOrigin() { 517 url::Origin WebBluetoothServiceImpl::GetOrigin() {
384 return render_frame_host_->GetLastCommittedOrigin(); 518 return render_frame_host_->GetLastCommittedOrigin();
385 } 519 }
386 520
387 void WebBluetoothServiceImpl::ClearState() { 521 void WebBluetoothServiceImpl::ClearState() {
388 characteristic_id_to_notify_session_.clear(); 522 characteristic_id_to_notify_session_.clear();
523 characteristic_to_service_.clear();
389 } 524 }
390 525
391 } // namespace content 526 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698