OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "rlz/chromeos/lib/rlz_value_store_chromeos.h" | 5 #include "rlz/chromeos/lib/rlz_value_store_chromeos.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/important_file_writer.h" | 8 #include "base/files/important_file_writer.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // Key names. | 27 // Key names. |
28 const char kPingTimeKey[] = "ping_time"; | 28 const char kPingTimeKey[] = "ping_time"; |
29 const char kAccessPointKey[] = "access_points"; | 29 const char kAccessPointKey[] = "access_points"; |
30 const char kProductEventKey[] = "product_events"; | 30 const char kProductEventKey[] = "product_events"; |
31 const char kStatefulEventKey[] = "stateful_events"; | 31 const char kStatefulEventKey[] = "stateful_events"; |
32 | 32 |
33 // Brand name used when there is no supplementary brand name. | 33 // Brand name used when there is no supplementary brand name. |
34 const char kNoSupplementaryBrand[] = "_"; | 34 const char kNoSupplementaryBrand[] = "_"; |
35 | 35 |
36 // RLZ store filename. | 36 // RLZ store filename. |
37 const FilePath::CharType kRLZDataFileName[] = FILE_PATH_LITERAL("RLZ Data"); | 37 const base::FilePath::CharType kRLZDataFileName[] = |
| 38 FILE_PATH_LITERAL("RLZ Data"); |
38 | 39 |
39 // RLZ store lock filename | 40 // RLZ store lock filename |
40 const FilePath::CharType kRLZLockFileName[] = | 41 const base::FilePath::CharType kRLZLockFileName[] = |
41 FILE_PATH_LITERAL("RLZ Data.lock"); | 42 FILE_PATH_LITERAL("RLZ Data.lock"); |
42 | 43 |
43 // RLZ store path for testing. | 44 // RLZ store path for testing. |
44 FilePath g_testing_rlz_store_path_; | 45 FilePath g_testing_rlz_store_path_; |
45 | 46 |
46 // Returns file path of the RLZ storage. | 47 // Returns file path of the RLZ storage. |
47 FilePath GetRlzStorePath() { | 48 FilePath GetRlzStorePath() { |
48 return g_testing_rlz_store_path_.empty() ? | 49 return g_testing_rlz_store_path_.empty() ? |
49 file_util::GetHomeDir().Append(kRLZDataFileName) : | 50 file_util::GetHomeDir().Append(kRLZDataFileName) : |
50 g_testing_rlz_store_path_.Append(kRLZDataFileName); | 51 g_testing_rlz_store_path_.Append(kRLZDataFileName); |
(...skipping 17 matching lines...) Expand all Loading... |
68 // Returns the dictionary key for storing product-related prefs. | 69 // Returns the dictionary key for storing product-related prefs. |
69 std::string GetKeyName(std::string key, Product product) { | 70 std::string GetKeyName(std::string key, Product product) { |
70 std::string brand = SupplementaryBranding::GetBrand(); | 71 std::string brand = SupplementaryBranding::GetBrand(); |
71 if (brand.empty()) | 72 if (brand.empty()) |
72 brand = kNoSupplementaryBrand; | 73 brand = kNoSupplementaryBrand; |
73 return key + "." + GetProductName(product) + "." + brand; | 74 return key + "." + GetProductName(product) + "." + brand; |
74 } | 75 } |
75 | 76 |
76 } // namespace | 77 } // namespace |
77 | 78 |
78 RlzValueStoreChromeOS::RlzValueStoreChromeOS(const FilePath& store_path) | 79 RlzValueStoreChromeOS::RlzValueStoreChromeOS(const base::FilePath& store_path) |
79 : rlz_store_(new base::DictionaryValue), | 80 : rlz_store_(new base::DictionaryValue), |
80 store_path_(store_path), | 81 store_path_(store_path), |
81 read_only_(true) { | 82 read_only_(true) { |
82 ReadStore(); | 83 ReadStore(); |
83 } | 84 } |
84 | 85 |
85 RlzValueStoreChromeOS::~RlzValueStoreChromeOS() { | 86 RlzValueStoreChromeOS::~RlzValueStoreChromeOS() { |
86 WriteStore(); | 87 WriteStore(); |
87 } | 88 } |
88 | 89 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 319 |
319 g_recursive_lock.ReleaseLock(); | 320 g_recursive_lock.ReleaseLock(); |
320 } | 321 } |
321 | 322 |
322 RlzValueStore* ScopedRlzValueStoreLock::GetStore() { | 323 RlzValueStore* ScopedRlzValueStoreLock::GetStore() { |
323 return store_.get(); | 324 return store_.get(); |
324 } | 325 } |
325 | 326 |
326 namespace testing { | 327 namespace testing { |
327 | 328 |
328 void SetRlzStoreDirectory(const FilePath& directory) { | 329 void SetRlzStoreDirectory(const base::FilePath& directory) { |
329 g_testing_rlz_store_path_ = directory; | 330 g_testing_rlz_store_path_ = directory; |
330 } | 331 } |
331 | 332 |
332 std::string RlzStoreFilenameStr() { | 333 std::string RlzStoreFilenameStr() { |
333 return GetRlzStorePath().value(); | 334 return GetRlzStorePath().value(); |
334 } | 335 } |
335 | 336 |
336 } // namespace testing | 337 } // namespace testing |
337 | 338 |
338 } // namespace rlz_lib | 339 } // namespace rlz_lib |
OLD | NEW |