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 "update_engine/prefs.h" | 5 #include "update_engine/prefs.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "update_engine/utils.h" | 10 #include "update_engine/utils.h" |
11 | 11 |
12 using std::string; | 12 using std::string; |
13 | 13 |
14 namespace chromeos_update_engine { | 14 namespace chromeos_update_engine { |
15 | 15 |
| 16 const char kPrefsLastActivePingDay[] = "last-active-ping-day"; |
| 17 const char kPrefsLastRollCallPingDay[] = "last-roll-call-ping-day"; |
| 18 |
16 bool Prefs::Init(const FilePath& prefs_dir) { | 19 bool Prefs::Init(const FilePath& prefs_dir) { |
17 prefs_dir_ = prefs_dir; | 20 prefs_dir_ = prefs_dir; |
18 return true; | 21 return true; |
19 } | 22 } |
20 | 23 |
21 bool Prefs::GetString(const string& key, string* value) { | 24 bool Prefs::GetString(const string& key, string* value) { |
22 LOG(INFO) << "Getting key \"" << key << "\""; | 25 LOG(INFO) << "Getting key \"" << key << "\""; |
23 FilePath filename; | 26 FilePath filename; |
24 TEST_AND_RETURN_FALSE(GetFileNameForKey(key, &filename)); | 27 TEST_AND_RETURN_FALSE(GetFileNameForKey(key, &filename)); |
25 TEST_AND_RETURN_FALSE(file_util::ReadFileToString(filename, value)); | 28 TEST_AND_RETURN_FALSE(file_util::ReadFileToString(filename, value)); |
(...skipping 30 matching lines...) Expand all Loading... |
56 for (size_t i = 0; i < key.size(); ++i) { | 59 for (size_t i = 0; i < key.size(); ++i) { |
57 char c = key.at(i); | 60 char c = key.at(i); |
58 TEST_AND_RETURN_FALSE(IsAsciiAlpha(c) || IsAsciiDigit(c) || | 61 TEST_AND_RETURN_FALSE(IsAsciiAlpha(c) || IsAsciiDigit(c) || |
59 c == '_' || c == '-'); | 62 c == '_' || c == '-'); |
60 } | 63 } |
61 *filename = prefs_dir_.Append(key); | 64 *filename = prefs_dir_.Append(key); |
62 return true; | 65 return true; |
63 } | 66 } |
64 | 67 |
65 } // namespace chromeos_update_engine | 68 } // namespace chromeos_update_engine |
OLD | NEW |