Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 "power_manager/power_prefs.h" | 5 #include "power_manager/power_prefs.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
|
tfarina
2010/06/05 01:08:56
sort these alphabetical.
| |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 | 12 |
| 13 using std::string; | 13 using std::string; |
|
tfarina
2010/06/05 01:08:56
can we get rid of this using? there are just to ca
| |
| 14 | 14 |
| 15 namespace power_manager { | 15 namespace power_manager { |
| 16 | 16 |
| 17 PowerPrefs::PowerPrefs(const FilePath& base_path) | 17 PowerPrefs::PowerPrefs(const FilePath& base_path) |
| 18 : base_path_(base_path) {} | 18 : base_path_(base_path) {} |
| 19 | 19 |
| 20 bool PowerPrefs::ReadSetting(const char* setting_name, int64 *val) { | 20 bool PowerPrefs::ReadSetting(const char* setting_name, int64* val) { |
| 21 FilePath path = base_path_.Append(setting_name); | 21 FilePath path = base_path_.Append(setting_name); |
|
tfarina
2010/06/05 01:08:56
David, I was going to do this change, but since I'
| |
| 22 string buf; | 22 string buf; |
| 23 if (!file_util::ReadFileToString(path, &buf)) | 23 if (!file_util::ReadFileToString(path, &buf)) |
| 24 return false; | 24 return false; |
| 25 TrimWhitespaceASCII(buf, TRIM_TRAILING, &buf); | 25 TrimWhitespaceASCII(buf, TRIM_TRAILING, &buf); |
| 26 return StringToInt64(buf, val); | 26 return StringToInt64(buf, val); |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool PowerPrefs::WriteSetting(const char* setting_name, int64 val) { | 29 bool PowerPrefs::WriteSetting(const char* setting_name, int64 val) { |
| 30 FilePath path = base_path_.Append(setting_name); | 30 FilePath path = base_path_.Append(setting_name); |
| 31 string buf = Int64ToString(val); | 31 string buf = Int64ToString(val); |
| 32 return -1 != file_util::WriteFile(path, buf.data(), buf.size()); | 32 return -1 != file_util::WriteFile(path, buf.data(), buf.size()); |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace power_manager | 35 } // namespace power_manager |
| OLD | NEW |