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

Side by Side Diff: device/bluetooth/bluetooth_uuid.cc

Issue 1966983003: Generate param traits size methods for IPC files in content/ (and traits it depends on). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix owners Created 4 years, 7 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 | « device/bluetooth/bluetooth_uuid.h ('k') | ipc/ipc_message.cc » ('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 "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"
11 #include "ipc/ipc_message.h" 11 #include "ipc/ipc_message.h"
12 #include "ipc/ipc_message_utils.h"
12 13
13 namespace device { 14 namespace device {
14 15
15 namespace { 16 namespace {
16 17
17 const char* kCommonUuidPostfix = "-0000-1000-8000-00805f9b34fb"; 18 const char* kCommonUuidPostfix = "-0000-1000-8000-00805f9b34fb";
18 const char* kCommonUuidPrefix = "0000"; 19 const char* kCommonUuidPrefix = "0000";
19 20
20 // Returns the canonical, 128-bit canonical, and the format of the UUID 21 // Returns the canonical, 128-bit canonical, and the format of the UUID
21 // in |canonical|, |canonical_128|, and |format| based on |uuid|. 22 // in |canonical|, |canonical_128|, and |format| based on |uuid|.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 bool BluetoothUUID::operator!=(const BluetoothUUID& uuid) const { 90 bool BluetoothUUID::operator!=(const BluetoothUUID& uuid) const {
90 return canonical_value_ != uuid.canonical_value_; 91 return canonical_value_ != uuid.canonical_value_;
91 } 92 }
92 93
93 void PrintTo(const BluetoothUUID& uuid, std::ostream* out) { 94 void PrintTo(const BluetoothUUID& uuid, std::ostream* out) {
94 *out << uuid.canonical_value(); 95 *out << uuid.canonical_value();
95 } 96 }
96 97
97 } // namespace device 98 } // namespace device
98 99
100 void IPC::ParamTraits<device::BluetoothUUID>::GetSize(base::PickleSizer* s,
101 const param_type& p) {
102 IPC::GetParamSize(s, p.canonical_value());
103 }
104
99 void IPC::ParamTraits<device::BluetoothUUID>::Write(base::Pickle* m, 105 void IPC::ParamTraits<device::BluetoothUUID>::Write(base::Pickle* m,
100 const param_type& p) { 106 const param_type& p) {
101 m->WriteString(p.canonical_value()); 107 m->WriteString(p.canonical_value());
102 } 108 }
103 109
104 bool IPC::ParamTraits<device::BluetoothUUID>::Read(const base::Pickle* m, 110 bool IPC::ParamTraits<device::BluetoothUUID>::Read(const base::Pickle* m,
105 base::PickleIterator* iter, 111 base::PickleIterator* iter,
106 param_type* r) { 112 param_type* r) {
107 std::string value; 113 std::string value;
108 if (!iter->ReadString(&value)) 114 if (!iter->ReadString(&value))
109 return false; 115 return false;
110 *r = device::BluetoothUUID(value); 116 *r = device::BluetoothUUID(value);
111 // If the format isn't 128-bit, .value() would return a different answer than 117 // 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() 118 // .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 119 // against a 128-bit string literal, a hostile renderer could use the 16- or
114 // 32-bit format and evade the check. 120 // 32-bit format and evade the check.
115 return r->format() == device::BluetoothUUID::kFormat128Bit; 121 return r->format() == device::BluetoothUUID::kFormat128Bit;
116 } 122 }
117 123
118 void IPC::ParamTraits<device::BluetoothUUID>::Log(const param_type& p, 124 void IPC::ParamTraits<device::BluetoothUUID>::Log(const param_type& p,
119 std::string* l) { 125 std::string* l) {
120 l->append(p.canonical_value()); 126 l->append(p.canonical_value());
121 } 127 }
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_uuid.h ('k') | ipc/ipc_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698