| 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 "chromeos/cryptohome/system_salt_getter.h" | 5 #include "chromeos/cryptohome/system_salt_getter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 base::Bind(&SystemSaltGetter::GetSystemSaltInternal, | 31 base::Bind(&SystemSaltGetter::GetSystemSaltInternal, |
| 32 weak_ptr_factory_.GetWeakPtr(), | 32 weak_ptr_factory_.GetWeakPtr(), |
| 33 callback)); | 33 callback)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 std::string SystemSaltGetter::GetSystemSaltSync() { | 36 std::string SystemSaltGetter::GetSystemSaltSync() { |
| 37 LoadSystemSalt(); // no-op if it's already loaded. | 37 LoadSystemSalt(); // no-op if it's already loaded. |
| 38 return system_salt_; | 38 return system_salt_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 std::string SystemSaltGetter::GetCachedSystemSalt() { | |
| 42 return system_salt_; | |
| 43 } | |
| 44 | |
| 45 void SystemSaltGetter::GetSystemSaltInternal( | 41 void SystemSaltGetter::GetSystemSaltInternal( |
| 46 const GetSystemSaltCallback& callback, | 42 const GetSystemSaltCallback& callback, |
| 47 bool service_is_available) { | 43 bool service_is_available) { |
| 48 LOG_IF(ERROR, !service_is_available) << "WaitForServiceToBeAvailable failed."; | 44 LOG_IF(ERROR, !service_is_available) << "WaitForServiceToBeAvailable failed."; |
| 49 // TODO(hashimoto): Stop using GetSystemSaltSync(). crbug.com/141009 | 45 // TODO(hashimoto): Stop using GetSystemSaltSync(). crbug.com/141009 |
| 50 callback.Run(GetSystemSaltSync()); | 46 callback.Run(GetSystemSaltSync()); |
| 51 } | 47 } |
| 52 | 48 |
| 53 void SystemSaltGetter::LoadSystemSalt() { | 49 void SystemSaltGetter::LoadSystemSalt() { |
| 54 if (!system_salt_.empty()) | 50 if (!system_salt_.empty()) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 84 } |
| 89 | 85 |
| 90 // static | 86 // static |
| 91 std::string SystemSaltGetter::ConvertRawSaltToHexString( | 87 std::string SystemSaltGetter::ConvertRawSaltToHexString( |
| 92 const std::vector<uint8>& salt) { | 88 const std::vector<uint8>& salt) { |
| 93 return StringToLowerASCII(base::HexEncode( | 89 return StringToLowerASCII(base::HexEncode( |
| 94 reinterpret_cast<const void*>(salt.data()), salt.size())); | 90 reinterpret_cast<const void*>(salt.data()), salt.size())); |
| 95 } | 91 } |
| 96 | 92 |
| 97 } // namespace chromeos | 93 } // namespace chromeos |
| OLD | NEW |