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

Side by Side Diff: chromeos/binder/transaction_data_reader.cc

Issue 1540803002: Switch to standard integer types in chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more includes Created 5 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chromeos/binder/transaction_data_reader.h" 5 #include "chromeos/binder/transaction_data_reader.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "chromeos/binder/transaction_data.h" 10 #include "chromeos/binder/transaction_data.h"
8 11
9 namespace binder { 12 namespace binder {
10 13
11 namespace { 14 namespace {
12 15
13 // Adds appropriate padding to the given size to make it 4-byte aligned. 16 // Adds appropriate padding to the given size to make it 4-byte aligned.
14 size_t AddPadding(size_t n) { 17 size_t AddPadding(size_t n) {
15 return (n + 3) & (~3); 18 return (n + 3) & (~3);
16 } 19 }
17 20
18 } // namespace 21 } // namespace
19 22
20 TransactionDataReader::TransactionDataReader(const TransactionData& data) 23 TransactionDataReader::TransactionDataReader(const TransactionData& data)
21 : data_(data), 24 : data_(data),
22 reader_(reinterpret_cast<const char*>(data.GetData()), 25 reader_(reinterpret_cast<const char*>(data.GetData()),
23 data.GetDataSize()) {} 26 data.GetDataSize()) {}
24 27
25 TransactionDataReader::~TransactionDataReader() {} 28 TransactionDataReader::~TransactionDataReader() {}
26 29
27 bool TransactionDataReader::HasMoreData() const { 30 bool TransactionDataReader::HasMoreData() const {
28 return reader_.HasMoreData(); 31 return reader_.HasMoreData();
29 } 32 }
30 33
31 bool TransactionDataReader::ReadData(void* buf, size_t n) { 34 bool TransactionDataReader::ReadData(void* buf, size_t n) {
32 return reader_.Read(buf, n) && reader_.Skip(AddPadding(n) - n); 35 return reader_.Read(buf, n) && reader_.Skip(AddPadding(n) - n);
33 } 36 }
34 37
35 bool TransactionDataReader::ReadInt32(int32* value) { 38 bool TransactionDataReader::ReadInt32(int32_t* value) {
36 return ReadData(value, sizeof(*value)); 39 return ReadData(value, sizeof(*value));
37 } 40 }
38 41
39 bool TransactionDataReader::ReadUint32(uint32* value) { 42 bool TransactionDataReader::ReadUint32(uint32_t* value) {
40 return ReadData(value, sizeof(*value)); 43 return ReadData(value, sizeof(*value));
41 } 44 }
42 45
43 bool TransactionDataReader::ReadInt64(int64* value) { 46 bool TransactionDataReader::ReadInt64(int64_t* value) {
44 return ReadData(value, sizeof(*value)); 47 return ReadData(value, sizeof(*value));
45 } 48 }
46 49
47 bool TransactionDataReader::ReadUint64(uint64* value) { 50 bool TransactionDataReader::ReadUint64(uint64_t* value) {
48 return ReadData(value, sizeof(*value)); 51 return ReadData(value, sizeof(*value));
49 } 52 }
50 53
51 bool TransactionDataReader::ReadFloat(float* value) { 54 bool TransactionDataReader::ReadFloat(float* value) {
52 return ReadData(value, sizeof(*value)); 55 return ReadData(value, sizeof(*value));
53 } 56 }
54 57
55 bool TransactionDataReader::ReadDouble(double* value) { 58 bool TransactionDataReader::ReadDouble(double* value) {
56 return ReadData(value, sizeof(*value)); 59 return ReadData(value, sizeof(*value));
57 } 60 }
58 61
59 } // namespace binder 62 } // namespace binder
OLDNEW
« no previous file with comments | « chromeos/binder/transaction_data_reader.h ('k') | chromeos/binder/transaction_data_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698