| 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 "sync/util/get_session_name.h" | 5 #include "sync/util/get_session_name.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
| 12 #include "base/task_runner.h" | 12 #include "base/task_runner.h" |
| 13 | 13 |
| 14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
| 15 #include "chrome/browser/chromeos/system/statistics_provider.h" | 15 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 16 #elif defined(OS_LINUX) | 16 #elif defined(OS_LINUX) |
| 17 #include "base/linux_util.h" | 17 #include "base/linux_util.h" |
| 18 #elif defined(OS_IOS) | 18 #elif defined(OS_IOS) |
| 19 #include "sync/util/get_session_name_ios.h" | 19 #include "sync/util/get_session_name_ios.h" |
| 20 #elif defined(OS_MACOSX) | 20 #elif defined(OS_MACOSX) |
| 21 #include "sync/util/get_session_name_mac.h" | 21 #include "sync/util/get_session_name_mac.h" |
| 22 #elif defined(OS_WIN) | 22 #elif defined(OS_WIN) |
| 23 #include "sync/util/get_session_name_win.h" | 23 #include "sync/util/get_session_name_win.h" |
| 24 #elif defined(OS_ANDROID) | 24 #elif defined(OS_ANDROID) |
| 25 #include "sync/util/session_utils_android.h" | 25 #include "base/android/build_info.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace syncer { | 28 namespace syncer { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 std::string GetSessionNameSynchronously() { | 32 std::string GetSessionNameSynchronously() { |
| 33 std::string session_name; | 33 std::string session_name; |
| 34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| 35 // TODO(kochi): This is very ad hoc and fragile. http://crbug.com/126732. | 35 // TODO(kochi): This is very ad hoc and fragile. http://crbug.com/126732. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 46 session_name = board.substr(0, 6) == "stumpy" ? "Chromebox" : "Chromebook"; | 46 session_name = board.substr(0, 6) == "stumpy" ? "Chromebox" : "Chromebook"; |
| 47 #elif defined(OS_LINUX) | 47 #elif defined(OS_LINUX) |
| 48 session_name = base::GetLinuxDistro(); | 48 session_name = base::GetLinuxDistro(); |
| 49 #elif defined(OS_IOS) | 49 #elif defined(OS_IOS) |
| 50 session_name = internal::GetComputerName(); | 50 session_name = internal::GetComputerName(); |
| 51 #elif defined(OS_MACOSX) | 51 #elif defined(OS_MACOSX) |
| 52 session_name = internal::GetHardwareModelName(); | 52 session_name = internal::GetHardwareModelName(); |
| 53 #elif defined(OS_WIN) | 53 #elif defined(OS_WIN) |
| 54 session_name = internal::GetComputerName(); | 54 session_name = internal::GetComputerName(); |
| 55 #elif defined(OS_ANDROID) | 55 #elif defined(OS_ANDROID) |
| 56 session_name = internal::GetModel(); | 56 base::android::BuildInfo* android_build_info = |
| 57 base::android::BuildInfo::GetInstance(); |
| 58 session_name = android_build_info->model(); |
| 57 #endif | 59 #endif |
| 58 | 60 |
| 59 if (session_name == "Unknown" || session_name.empty()) | 61 if (session_name == "Unknown" || session_name.empty()) |
| 60 session_name = base::SysInfo::OperatingSystemName(); | 62 session_name = base::SysInfo::OperatingSystemName(); |
| 61 | 63 |
| 62 return session_name; | 64 return session_name; |
| 63 } | 65 } |
| 64 | 66 |
| 65 void FillSessionName(std::string* session_name) { | 67 void FillSessionName(std::string* session_name) { |
| 66 *session_name = GetSessionNameSynchronously(); | 68 *session_name = GetSessionNameSynchronously(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 85 base::Bind(&OnSessionNameFilled, | 87 base::Bind(&OnSessionNameFilled, |
| 86 done_callback, | 88 done_callback, |
| 87 base::Owned(session_name))); | 89 base::Owned(session_name))); |
| 88 } | 90 } |
| 89 | 91 |
| 90 std::string GetSessionNameSynchronouslyForTesting() { | 92 std::string GetSessionNameSynchronouslyForTesting() { |
| 91 return GetSessionNameSynchronously(); | 93 return GetSessionNameSynchronously(); |
| 92 } | 94 } |
| 93 | 95 |
| 94 } // namespace syncer | 96 } // namespace syncer |
| OLD | NEW |