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

Side by Side Diff: prefs.cc

Issue 3170010: [update_engine] Update to use not-hideously-old logging API from chrome (Closed) Base URL: http://src.chromium.org/git/update_engine.git
Patch Set: Created 10 years, 4 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
« no previous file with comments | « omaha_request_action.cc ('k') | subprocess.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_number_conversions.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "update_engine/utils.h" 11 #include "update_engine/utils.h"
11 12
12 using std::string; 13 using std::string;
13 14
14 namespace chromeos_update_engine { 15 namespace chromeos_update_engine {
15 16
16 const char kPrefsLastActivePingDay[] = "last-active-ping-day"; 17 const char kPrefsLastActivePingDay[] = "last-active-ping-day";
17 const char kPrefsLastRollCallPingDay[] = "last-roll-call-ping-day"; 18 const char kPrefsLastRollCallPingDay[] = "last-roll-call-ping-day";
18 19
(...skipping 19 matching lines...) Expand all
38 TEST_AND_RETURN_FALSE( 39 TEST_AND_RETURN_FALSE(
39 file_util::WriteFile(filename, value.data(), value.size()) == 40 file_util::WriteFile(filename, value.data(), value.size()) ==
40 static_cast<int>(value.size())); 41 static_cast<int>(value.size()));
41 return true; 42 return true;
42 } 43 }
43 44
44 bool Prefs::GetInt64(const string& key, int64_t* value) { 45 bool Prefs::GetInt64(const string& key, int64_t* value) {
45 string str_value; 46 string str_value;
46 TEST_AND_RETURN_FALSE(GetString(key, &str_value)); 47 TEST_AND_RETURN_FALSE(GetString(key, &str_value));
47 TrimWhitespaceASCII(str_value, TRIM_ALL, &str_value); 48 TrimWhitespaceASCII(str_value, TRIM_ALL, &str_value);
48 TEST_AND_RETURN_FALSE(StringToInt64(str_value, value)); 49 TEST_AND_RETURN_FALSE(base::StringToInt64(str_value, value));
49 return true; 50 return true;
50 } 51 }
51 52
52 bool Prefs::SetInt64(const string& key, const int64_t value) { 53 bool Prefs::SetInt64(const string& key, const int64_t value) {
53 return SetString(key, Int64ToString(value)); 54 return SetString(key, base::Int64ToString(value));
54 } 55 }
55 56
56 bool Prefs::GetFileNameForKey(const std::string& key, FilePath* filename) { 57 bool Prefs::GetFileNameForKey(const std::string& key, FilePath* filename) {
57 // Allows only non-empty keys containing [A-Za-z0-9_-]. 58 // Allows only non-empty keys containing [A-Za-z0-9_-].
58 TEST_AND_RETURN_FALSE(!key.empty()); 59 TEST_AND_RETURN_FALSE(!key.empty());
59 for (size_t i = 0; i < key.size(); ++i) { 60 for (size_t i = 0; i < key.size(); ++i) {
60 char c = key.at(i); 61 char c = key.at(i);
61 TEST_AND_RETURN_FALSE(IsAsciiAlpha(c) || IsAsciiDigit(c) || 62 TEST_AND_RETURN_FALSE(IsAsciiAlpha(c) || IsAsciiDigit(c) ||
62 c == '_' || c == '-'); 63 c == '_' || c == '-');
63 } 64 }
64 *filename = prefs_dir_.Append(key); 65 *filename = prefs_dir_.Append(key);
65 return true; 66 return true;
66 } 67 }
67 68
68 } // namespace chromeos_update_engine 69 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « omaha_request_action.cc ('k') | subprocess.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698