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

Unified Diff: content/common/bluetooth/web_bluetooth_device_id_struct_traits.h

Issue 2019853002: bluetooth: Use WebBluetoothDeviceId instead of string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-uuid-typemap
Patch Set: Rebase Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/common/bluetooth/web_bluetooth_device_id_struct_traits.h
diff --git a/content/common/bluetooth/web_bluetooth_device_id_struct_traits.h b/content/common/bluetooth/web_bluetooth_device_id_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..82fa21b4696cd400509448f19d783edcfec5302b
--- /dev/null
+++ b/content/common/bluetooth/web_bluetooth_device_id_struct_traits.h
@@ -0,0 +1,39 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_
+#define CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_
+
+#include <string>
+
+#include "content/common/bluetooth/web_bluetooth_device_id.h"
+#include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<blink::mojom::WebBluetoothDeviceId,
+ content::WebBluetoothDeviceId> {
+ static const std::string& device_id(
+ const content::WebBluetoothDeviceId& device_id) {
+ return device_id.str();
+ }
+
+ static bool Read(blink::mojom::WebBluetoothDeviceIdDataView input,
+ content::WebBluetoothDeviceId* output) {
+ std::string result;
+
+ if (!input.ReadDeviceId(&result))
+ return false;
+ if (!content::WebBluetoothDeviceId::IsValid(result))
+ return false;
+
+ *output = content::WebBluetoothDeviceId(std::move(result));
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_
« no previous file with comments | « content/common/bluetooth/web_bluetooth_device_id.typemap ('k') | content/common/bluetooth/web_bluetooth_device_id_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698