Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: sync/util/get_session_name.cc

Issue 479703004: Ensure syncer::internal::GetComputerName returns a UTF-8 string. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use the returned size instead of wcslen(). Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/string_util.h"
11 #include "base/sys_info.h" 12 #include "base/sys_info.h"
12 #include "base/task_runner.h" 13 #include "base/task_runner.h"
13 14
14 #if defined(OS_LINUX) 15 #if defined(OS_LINUX)
15 #include "sync/util/get_session_name_linux.h" 16 #include "sync/util/get_session_name_linux.h"
16 #elif defined(OS_IOS) 17 #elif defined(OS_IOS)
17 #include "sync/util/get_session_name_ios.h" 18 #include "sync/util/get_session_name_ios.h"
18 #elif defined(OS_MACOSX) 19 #elif defined(OS_MACOSX)
19 #include "sync/util/get_session_name_mac.h" 20 #include "sync/util/get_session_name_mac.h"
20 #elif defined(OS_WIN) 21 #elif defined(OS_WIN)
(...skipping 25 matching lines...) Expand all
46 session_name = internal::GetComputerName(); 47 session_name = internal::GetComputerName();
47 #elif defined(OS_ANDROID) 48 #elif defined(OS_ANDROID)
48 base::android::BuildInfo* android_build_info = 49 base::android::BuildInfo* android_build_info =
49 base::android::BuildInfo::GetInstance(); 50 base::android::BuildInfo::GetInstance();
50 session_name = android_build_info->model(); 51 session_name = android_build_info->model();
51 #endif 52 #endif
52 53
53 if (session_name == "Unknown" || session_name.empty()) 54 if (session_name == "Unknown" || session_name.empty())
54 session_name = base::SysInfo::OperatingSystemName(); 55 session_name = base::SysInfo::OperatingSystemName();
55 56
57 DCHECK(base::IsStringUTF8(session_name));
56 return session_name; 58 return session_name;
57 } 59 }
58 60
59 void FillSessionName(std::string* session_name) { 61 void FillSessionName(std::string* session_name) {
60 *session_name = GetSessionNameSynchronously(); 62 *session_name = GetSessionNameSynchronously();
61 } 63 }
62 64
63 void OnSessionNameFilled( 65 void OnSessionNameFilled(
64 const base::Callback<void(const std::string&)>& done_callback, 66 const base::Callback<void(const std::string&)>& done_callback,
65 std::string* session_name) { 67 std::string* session_name) {
(...skipping 13 matching lines...) Expand all
79 base::Bind(&OnSessionNameFilled, 81 base::Bind(&OnSessionNameFilled,
80 done_callback, 82 done_callback,
81 base::Owned(session_name))); 83 base::Owned(session_name)));
82 } 84 }
83 85
84 std::string GetSessionNameSynchronouslyForTesting() { 86 std::string GetSessionNameSynchronouslyForTesting() {
85 return GetSessionNameSynchronously(); 87 return GetSessionNameSynchronously();
86 } 88 }
87 89
88 } // namespace syncer 90 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698