summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorheuristicist@gmail.com <heuristicist@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-07 13:05:05 +0000
committerheuristicist@gmail.com <heuristicist@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-07 13:05:05 +0000
commit63164af79348d9d5137c2c4c23896bb1a361471f (patch)
treeb445efdf24619532167f237f5971e8184d2f5202
parent5e5d68bfec2b38170509e50551c91f9113edb160 (diff)
downloadchromium_src-63164af79348d9d5137c2c4c23896bb1a361471f.zip
chromium_src-63164af79348d9d5137c2c4c23896bb1a361471f.tar.gz
chromium_src-63164af79348d9d5137c2c4c23896bb1a361471f.tar.bz2
Use the machine hostname on Linux machines for the sync session name rather than
the distro name, but retain distro name as a fallback in case the hostname fails. Uses gethostname() from unistd.h. BUG=123827 TEST=Verify on a Linux machine that the hostname apppears in chrome://sync-internals > Sync Node Browser > Root > Device Information. Review URL: https://chromiumcodereview.appspot.com/14963003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198704 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--AUTHORS1
-rw-r--r--sync/sync_core.gypi2
-rw-r--r--sync/util/get_session_name.cc4
-rw-r--r--sync/util/get_session_name_linux.cc24
-rw-r--r--sync/util/get_session_name_linux.h19
5 files changed, 48 insertions, 2 deletions
diff --git a/AUTHORS b/AUTHORS
index a0e975c..f39156b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -251,3 +251,4 @@ Mihai Tica <mihai.o.tica@gmail.com>
Mihai Tica <mitica@adobe.com>
Bem Jones-Bey <bemajaniman@gmail.com>
Bem Jones-Bey <bjonesbe@adobe.com>
+Aditya Bhargava <heuristicist@gmail.com>
diff --git a/sync/sync_core.gypi b/sync/sync_core.gypi
index 9c311ee..df314ce 100644
--- a/sync/sync_core.gypi
+++ b/sync/sync_core.gypi
@@ -181,6 +181,8 @@
'util/get_session_name.h',
'util/get_session_name_ios.mm',
'util/get_session_name_ios.h',
+ 'util/get_session_name_linux.cc',
+ 'util/get_session_name_linux.h',
'util/get_session_name_mac.mm',
'util/get_session_name_mac.h',
'util/get_session_name_win.cc',
diff --git a/sync/util/get_session_name.cc b/sync/util/get_session_name.cc
index d5cf629..73041ae 100644
--- a/sync/util/get_session_name.cc
+++ b/sync/util/get_session_name.cc
@@ -15,7 +15,7 @@
#include "base/command_line.h"
#include "chromeos/chromeos_switches.h"
#elif defined(OS_LINUX)
-#include "base/linux_util.h"
+#include "sync/util/get_session_name_linux.h"
#elif defined(OS_IOS)
#include "sync/util/get_session_name_ios.h"
#elif defined(OS_MACOSX)
@@ -60,7 +60,7 @@ std::string GetSessionNameSynchronously() {
// "CHROMEOS_RELEASE_BOARD" line in chrome://system.
session_name = board.substr(0, 6) == "stumpy" ? "Chromebox" : "Chromebook";
#elif defined(OS_LINUX)
- session_name = base::GetLinuxDistro();
+ session_name = internal::GetHostname();
#elif defined(OS_IOS)
session_name = internal::GetComputerName();
#elif defined(OS_MACOSX)
diff --git a/sync/util/get_session_name_linux.cc b/sync/util/get_session_name_linux.cc
new file mode 100644
index 0000000..172252d
--- /dev/null
+++ b/sync/util/get_session_name_linux.cc
@@ -0,0 +1,24 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sync/util/get_session_name_linux.h"
+
+#include <limits.h> // for HOST_NAME_MAX
+#include <unistd.h> // for gethostname()
+
+#include "base/linux_util.h"
+
+namespace syncer {
+namespace internal {
+
+std::string GetHostname() {
+ char hostname[HOST_NAME_MAX];
+ if (gethostname(hostname, HOST_NAME_MAX) == 0) // Success.
+ return hostname;
+ return base::GetLinuxDistro();
+}
+
+} // namespace internal
+} // namespace syncer
+
diff --git a/sync/util/get_session_name_linux.h b/sync/util/get_session_name_linux.h
new file mode 100644
index 0000000..b6bd273
--- /dev/null
+++ b/sync/util/get_session_name_linux.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SYNC_UTIL_GET_SESSION_NAME_LINUX_H_
+#define SYNC_UTIL_GET_SESSION_NAME_LINUX_H_
+
+#include <string>
+
+namespace syncer {
+namespace internal {
+
+std::string GetHostname();
+
+} // namespace internal
+} // namespace syncer
+
+#endif // SYNC_UTIL_GET_SESSION_NAME_LINUX_H_
+