| 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/base_paths.h" | |
| 8 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 9 #include "base/files/important_file_writer.h" | 8 #include "base/files/important_file_writer.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 11 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| 12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 13 #include "base/path_service.h" | |
| 14 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 15 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/values.h" | 14 #include "base/values.h" |
| 17 #include "rlz/lib/lib_values.h" | 15 #include "rlz/lib/lib_values.h" |
| 18 #include "rlz/lib/recursive_cross_process_lock_posix.h" | 16 #include "rlz/lib/recursive_cross_process_lock_posix.h" |
| 19 #include "rlz/lib/rlz_lib.h" | 17 #include "rlz/lib/rlz_lib.h" |
| 20 | 18 |
| 21 namespace rlz_lib { | 19 namespace rlz_lib { |
| 22 | 20 |
| 23 namespace { | 21 namespace { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 | 35 |
| 38 // RLZ store lock filename | 36 // RLZ store lock filename |
| 39 const base::FilePath::CharType kRLZLockFileName[] = | 37 const base::FilePath::CharType kRLZLockFileName[] = |
| 40 FILE_PATH_LITERAL("RLZ Data.lock"); | 38 FILE_PATH_LITERAL("RLZ Data.lock"); |
| 41 | 39 |
| 42 // RLZ store path for testing. | 40 // RLZ store path for testing. |
| 43 base::FilePath g_testing_rlz_store_path_; | 41 base::FilePath g_testing_rlz_store_path_; |
| 44 | 42 |
| 45 // Returns file path of the RLZ storage. | 43 // Returns file path of the RLZ storage. |
| 46 base::FilePath GetRlzStorePath() { | 44 base::FilePath GetRlzStorePath() { |
| 47 base::FilePath homedir; | |
| 48 PathService::Get(base::DIR_HOME, &homedir); | |
| 49 return g_testing_rlz_store_path_.empty() ? | 45 return g_testing_rlz_store_path_.empty() ? |
| 50 homedir.Append(kRLZDataFileName) : | 46 base::GetHomeDir().Append(kRLZDataFileName) : |
| 51 g_testing_rlz_store_path_.Append(kRLZDataFileName); | 47 g_testing_rlz_store_path_.Append(kRLZDataFileName); |
| 52 } | 48 } |
| 53 | 49 |
| 54 // Returns file path of the RLZ storage lock file. | 50 // Returns file path of the RLZ storage lock file. |
| 55 base::FilePath GetRlzStoreLockPath() { | 51 base::FilePath GetRlzStoreLockPath() { |
| 56 base::FilePath homedir; | |
| 57 PathService::Get(base::DIR_HOME, &homedir); | |
| 58 return g_testing_rlz_store_path_.empty() ? | 52 return g_testing_rlz_store_path_.empty() ? |
| 59 homedir.Append(kRLZLockFileName) : | 53 base::GetHomeDir().Append(kRLZLockFileName) : |
| 60 g_testing_rlz_store_path_.Append(kRLZLockFileName); | 54 g_testing_rlz_store_path_.Append(kRLZLockFileName); |
| 61 } | 55 } |
| 62 | 56 |
| 63 // Returns the dictionary key for storing access point-related prefs. | 57 // Returns the dictionary key for storing access point-related prefs. |
| 64 std::string GetKeyName(std::string key, AccessPoint access_point) { | 58 std::string GetKeyName(std::string key, AccessPoint access_point) { |
| 65 std::string brand = SupplementaryBranding::GetBrand(); | 59 std::string brand = SupplementaryBranding::GetBrand(); |
| 66 if (brand.empty()) | 60 if (brand.empty()) |
| 67 brand = kNoSupplementaryBrand; | 61 brand = kNoSupplementaryBrand; |
| 68 return key + "." + GetAccessPointName(access_point) + "." + brand; | 62 return key + "." + GetAccessPointName(access_point) + "." + brand; |
| 69 } | 63 } |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 g_testing_rlz_store_path_ = directory; | 327 g_testing_rlz_store_path_ = directory; |
| 334 } | 328 } |
| 335 | 329 |
| 336 std::string RlzStoreFilenameStr() { | 330 std::string RlzStoreFilenameStr() { |
| 337 return GetRlzStorePath().value(); | 331 return GetRlzStorePath().value(); |
| 338 } | 332 } |
| 339 | 333 |
| 340 } // namespace testing | 334 } // namespace testing |
| 341 | 335 |
| 342 } // namespace rlz_lib | 336 } // namespace rlz_lib |
| OLD | NEW |