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

Side by Side Diff: content/renderer/bluetooth/web_bluetooth_impl.cc

Issue 2015463004: bluetooth: Use BluetoothUUID instead of string when sending uuids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-mojo-request-device
Patch Set: Fix merge conflict Created 4 years, 6 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
« no previous file with comments | « content/renderer/bluetooth/bluetooth_type_converters.cc ('k') | device/bluetooth/bluetooth.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/bluetooth/web_bluetooth_impl.h" 5 #include "content/renderer/bluetooth/web_bluetooth_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/optional.h"
12 #include "content/child/mojo/type_converters.h" 13 #include "content/child/mojo/type_converters.h"
13 #include "content/child/thread_safe_sender.h" 14 #include "content/child/thread_safe_sender.h"
14 #include "content/public/common/service_registry.h" 15 #include "content/public/common/service_registry.h"
15 #include "content/renderer/bluetooth/bluetooth_type_converters.h" 16 #include "content/renderer/bluetooth/bluetooth_type_converters.h"
16 #include "ipc/ipc_message.h" 17 #include "ipc/ipc_message.h"
17 #include "mojo/public/cpp/bindings/array.h" 18 #include "mojo/public/cpp/bindings/array.h"
18 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevic e.h" 19 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevic e.h"
19 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevic eInit.h" 20 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDevic eInit.h"
20 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTCharacteristic.h" 21 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTCharacteristic.h"
21 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTCharacteristicInit.h" 22 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemot eGATTCharacteristicInit.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 60
60 GetWebBluetoothService().RemoteServerDisconnect( 61 GetWebBluetoothService().RemoteServerDisconnect(
61 mojo::String::From(device_id)); 62 mojo::String::From(device_id));
62 } 63 }
63 64
64 void WebBluetoothImpl::getPrimaryService( 65 void WebBluetoothImpl::getPrimaryService(
65 const blink::WebString& device_id, 66 const blink::WebString& device_id,
66 const blink::WebString& service_uuid, 67 const blink::WebString& service_uuid,
67 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks) { 68 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks) {
68 GetWebBluetoothService().RemoteServerGetPrimaryService( 69 GetWebBluetoothService().RemoteServerGetPrimaryService(
69 mojo::String::From(device_id), mojo::String::From(service_uuid), 70 mojo::String::From(device_id),
71 base::make_optional(device::BluetoothUUID(service_uuid.utf8())),
70 base::Bind(&WebBluetoothImpl::OnGetPrimaryServiceComplete, 72 base::Bind(&WebBluetoothImpl::OnGetPrimaryServiceComplete,
71 base::Unretained(this), device_id, 73 base::Unretained(this), device_id,
72 base::Passed(base::WrapUnique(callbacks)))); 74 base::Passed(base::WrapUnique(callbacks))));
73 } 75 }
74 76
75 void WebBluetoothImpl::getCharacteristics( 77 void WebBluetoothImpl::getCharacteristics(
76 const blink::WebString& service_instance_id, 78 const blink::WebString& service_instance_id,
77 blink::mojom::WebBluetoothGATTQueryQuantity quantity, 79 blink::mojom::WebBluetoothGATTQueryQuantity quantity,
78 const blink::WebString& characteristics_uuid, 80 const blink::WebString& characteristics_uuid,
79 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks) { 81 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks) {
80 GetWebBluetoothService().RemoteServiceGetCharacteristics( 82 GetWebBluetoothService().RemoteServiceGetCharacteristics(
81 mojo::String::From(service_instance_id), quantity, 83 mojo::String::From(service_instance_id), quantity,
82 characteristics_uuid.isEmpty() ? nullptr 84 characteristics_uuid.isEmpty()
83 : mojo::String::From(characteristics_uuid), 85 ? base::nullopt
86 : base::make_optional(
87 device::BluetoothUUID(characteristics_uuid.utf8())),
84 base::Bind(&WebBluetoothImpl::OnGetCharacteristicsComplete, 88 base::Bind(&WebBluetoothImpl::OnGetCharacteristicsComplete,
85 base::Unretained(this), service_instance_id, 89 base::Unretained(this), service_instance_id,
86 base::Passed(base::WrapUnique(callbacks)))); 90 base::Passed(base::WrapUnique(callbacks))));
87 } 91 }
88 92
89 void WebBluetoothImpl::readValue( 93 void WebBluetoothImpl::readValue(
90 const blink::WebString& characteristic_instance_id, 94 const blink::WebString& characteristic_instance_id,
91 blink::WebBluetoothReadValueCallbacks* callbacks) { 95 blink::WebBluetoothReadValueCallbacks* callbacks) {
92 GetWebBluetoothService().RemoteCharacteristicReadValue( 96 GetWebBluetoothService().RemoteCharacteristicReadValue(
93 mojo::String::From(characteristic_instance_id), 97 mojo::String::From(characteristic_instance_id),
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Create an associated interface ptr and pass it to the WebBluetoothService 289 // Create an associated interface ptr and pass it to the WebBluetoothService
286 // so that it can send us events without us prompting. 290 // so that it can send us events without us prompting.
287 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo ptr_info; 291 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo ptr_info;
288 binding_.Bind(&ptr_info, web_bluetooth_service_.associated_group()); 292 binding_.Bind(&ptr_info, web_bluetooth_service_.associated_group());
289 web_bluetooth_service_->SetClient(std::move(ptr_info)); 293 web_bluetooth_service_->SetClient(std::move(ptr_info));
290 } 294 }
291 return *web_bluetooth_service_; 295 return *web_bluetooth_service_;
292 } 296 }
293 297
294 } // namespace content 298 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/bluetooth/bluetooth_type_converters.cc ('k') | device/bluetooth/bluetooth.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698