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

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

Issue 9699057: [Sync] Move 'sync' target to sync/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Tim's comments Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/util/get_session_name.h"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/callback.h"
10 #include "base/location.h"
11 #include "base/sys_info.h"
12 #include "base/task_runner.h"
13
14 #if defined(OS_LINUX)
15 #include "base/linux_util.h"
16 #elif defined(OS_MACOSX)
17 #include "chrome/browser/sync/util/get_session_name_mac.h"
18 #elif defined(OS_WIN)
19 #include "chrome/browser/sync/util/get_session_name_win.h"
20 #endif
21
22 namespace browser_sync {
23
24 namespace {
25
26 std::string GetSessionNameSynchronously() {
27 std::string session_name;
28 #if defined(OS_CHROMEOS)
29 session_name = "Chromebook";
30 #elif defined(OS_LINUX)
31 session_name = base::GetLinuxDistro();
32 #elif defined(OS_MACOSX)
33 session_name = internal::GetHardwareModelName();
34 #elif defined(OS_WIN)
35 session_name = internal::GetComputerName();
36 #endif
37
38 if (session_name == "Unknown" || session_name.empty())
39 session_name = base::SysInfo::OperatingSystemName();
40
41 return session_name;
42 }
43
44 void FillSessionName(std::string* session_name) {
45 *session_name = GetSessionNameSynchronously();
46 }
47
48 void OnSessionNameFilled(
49 const base::Callback<void(const std::string&)>& done_callback,
50 std::string* session_name) {
51 done_callback.Run(*session_name);
52 }
53
54 } // namespace
55
56 void GetSessionName(
57 const scoped_refptr<base::TaskRunner>& task_runner,
58 const base::Callback<void(const std::string&)>& done_callback) {
59 std::string* session_name = new std::string();
60 task_runner->PostTaskAndReply(
61 FROM_HERE,
62 base::Bind(&FillSessionName,
63 base::Unretained(session_name)),
64 base::Bind(&OnSessionNameFilled,
65 done_callback,
66 base::Owned(session_name)));
67 }
68
69 std::string GetSessionNameSynchronouslyForTesting() {
70 return GetSessionNameSynchronously();
71 }
72
73 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/util/get_session_name.h ('k') | chrome/browser/sync/util/get_session_name_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698