| 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 "chromeos/accelerometer/accelerometer_reader.h" | 5 #include "chromeos/accelerometer/accelerometer_reader.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const int kNumberOfAxes = 3; | 84 const int kNumberOfAxes = 3; |
| 85 | 85 |
| 86 // The size of data in one reading of the accelerometers. | 86 // The size of data in one reading of the accelerometers. |
| 87 const int kSizeOfReading = kDataSize * kNumberOfAxes; | 87 const int kSizeOfReading = kDataSize * kNumberOfAxes; |
| 88 | 88 |
| 89 // Reads |path| to the unsigned int pointed to by |value|. Returns true on | 89 // Reads |path| to the unsigned int pointed to by |value|. Returns true on |
| 90 // success or false on failure. | 90 // success or false on failure. |
| 91 bool ReadFileToInt(const base::FilePath& path, int* value) { | 91 bool ReadFileToInt(const base::FilePath& path, int* value) { |
| 92 std::string s; | 92 std::string s; |
| 93 DCHECK(value); | 93 DCHECK(value); |
| 94 if (!base::ReadFileToString(path, &s, kMaxAsciiUintLength)) { | 94 if (!base::ReadFileToStringWithMaxSize(path, &s, kMaxAsciiUintLength)) { |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 97 base::TrimWhitespaceASCII(s, base::TRIM_ALL, &s); | 97 base::TrimWhitespaceASCII(s, base::TRIM_ALL, &s); |
| 98 if (!base::StringToInt(s, value)) { | 98 if (!base::StringToInt(s, value)) { |
| 99 LOG(ERROR) << "Failed to parse int \"" << s << "\" from " << path.value(); | 99 LOG(ERROR) << "Failed to parse int \"" << s << "\" from " << path.value(); |
| 100 return false; | 100 return false; |
| 101 } | 101 } |
| 102 return true; | 102 return true; |
| 103 } | 103 } |
| 104 | 104 |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 } | 501 } |
| 502 | 502 |
| 503 AccelerometerReader::AccelerometerReader() | 503 AccelerometerReader::AccelerometerReader() |
| 504 : accelerometer_file_reader_(new AccelerometerFileReader()) { | 504 : accelerometer_file_reader_(new AccelerometerFileReader()) { |
| 505 } | 505 } |
| 506 | 506 |
| 507 AccelerometerReader::~AccelerometerReader() { | 507 AccelerometerReader::~AccelerometerReader() { |
| 508 } | 508 } |
| 509 | 509 |
| 510 } // namespace chromeos | 510 } // namespace chromeos |
| OLD | NEW |