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