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

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: 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
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"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
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>::GetSize(base::PickleSizer* s,
100 const param_type& p) {
101 s->AddString(p.canonical_value());
102 }
103
99 void IPC::ParamTraits<device::BluetoothUUID>::Write(base::Pickle* m, 104 void IPC::ParamTraits<device::BluetoothUUID>::Write(base::Pickle* m,
100 const param_type& p) { 105 const param_type& p) {
101 m->WriteString(p.canonical_value()); 106 m->WriteString(p.canonical_value());
102 } 107 }
103 108
104 bool IPC::ParamTraits<device::BluetoothUUID>::Read(const base::Pickle* m, 109 bool IPC::ParamTraits<device::BluetoothUUID>::Read(const base::Pickle* m,
105 base::PickleIterator* iter, 110 base::PickleIterator* iter,
106 param_type* r) { 111 param_type* r) {
107 std::string value; 112 std::string value;
108 if (!iter->ReadString(&value)) 113 if (!iter->ReadString(&value))
109 return false; 114 return false;
110 *r = device::BluetoothUUID(value); 115 *r = device::BluetoothUUID(value);
111 // If the format isn't 128-bit, .value() would return a different answer than 116 // 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() 117 // .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 118 // against a 128-bit string literal, a hostile renderer could use the 16- or
114 // 32-bit format and evade the check. 119 // 32-bit format and evade the check.
115 return r->format() == device::BluetoothUUID::kFormat128Bit; 120 return r->format() == device::BluetoothUUID::kFormat128Bit;
116 } 121 }
117 122
118 void IPC::ParamTraits<device::BluetoothUUID>::Log(const param_type& p, 123 void IPC::ParamTraits<device::BluetoothUUID>::Log(const param_type& p,
119 std::string* l) { 124 std::string* l) {
120 l->append(p.canonical_value()); 125 l->append(p.canonical_value());
121 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698