| OLD | NEW |
| 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 "device/bluetooth/bluetooth_uuid.h" | 5 #include "device/bluetooth/bluetooth_uuid.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 bool BluetoothUUID::operator!=(const BluetoothUUID& uuid) const { | 89 bool BluetoothUUID::operator!=(const BluetoothUUID& uuid) const { |
| 90 return canonical_value_ != uuid.canonical_value_; | 90 return canonical_value_ != uuid.canonical_value_; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void PrintTo(const BluetoothUUID& uuid, std::ostream* out) { | 93 void PrintTo(const BluetoothUUID& uuid, std::ostream* out) { |
| 94 *out << uuid.canonical_value(); | 94 *out << uuid.canonical_value(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace device | 97 } // namespace device |
| 98 | 98 |
| 99 void IPC::ParamTraits<device::BluetoothUUID>::Write(Message* m, | 99 void IPC::ParamTraits<device::BluetoothUUID>::Write(base::Pickle* m, |
| 100 const param_type& p) { | 100 const param_type& p) { |
| 101 m->WriteString(p.canonical_value()); | 101 m->WriteString(p.canonical_value()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool IPC::ParamTraits<device::BluetoothUUID>::Read(const Message* m, | 104 bool IPC::ParamTraits<device::BluetoothUUID>::Read(const base::Pickle* m, |
| 105 base::PickleIterator* iter, | 105 base::PickleIterator* iter, |
| 106 param_type* r) { | 106 param_type* r) { |
| 107 std::string value; | 107 std::string value; |
| 108 if (!iter->ReadString(&value)) | 108 if (!iter->ReadString(&value)) |
| 109 return false; | 109 return false; |
| 110 *r = device::BluetoothUUID(value); | 110 *r = device::BluetoothUUID(value); |
| 111 // If the format isn't 128-bit, .value() would return a different answer than | 111 // If the format isn't 128-bit, .value() would return a different answer than |
| 112 // .canonical_value(). Then if browser-side code accidentally checks .value() | 112 // .canonical_value(). Then if browser-side code accidentally checks .value() |
| 113 // against a 128-bit string literal, a hostile renderer could use the 16- or | 113 // against a 128-bit string literal, a hostile renderer could use the 16- or |
| 114 // 32-bit format and evade the check. | 114 // 32-bit format and evade the check. |
| 115 return r->format() == device::BluetoothUUID::kFormat128Bit; | 115 return r->format() == device::BluetoothUUID::kFormat128Bit; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void IPC::ParamTraits<device::BluetoothUUID>::Log(const param_type& p, | 118 void IPC::ParamTraits<device::BluetoothUUID>::Log(const param_type& p, |
| 119 std::string* l) { | 119 std::string* l) { |
| 120 l->append(p.canonical_value()); | 120 l->append(p.canonical_value()); |
| 121 } | 121 } |
| OLD | NEW |