]> khamidou — GitHub mirrors - electron.git/commitdiff
Get POSIX mostly compiling
authorPaul Betts <paul@paulbetts.org>
Mon, 19 Oct 2015 20:51:27 +0000 (13:51 -0700)
committerPaul Betts <paul@paulbetts.org>
Tue, 20 Oct 2015 20:14:08 +0000 (13:14 -0700)
atom/browser/process_singleton_posix.cc

index 119b18e11ab8a568d0dd6d07f37735c45fb802b6..2df9da631bee7052608c9537788ae2fa4b11f882 100644 (file)
 #include "net/base/net_util.h"
 #include "ui/base/l10n/l10n_util.h"
 
+#if defined(TOOLKIT_VIEWS) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#include "ui/views/linux_ui/linux_ui.h"
+#endif
+
 using content::BrowserThread;
 
 namespace {
@@ -101,6 +105,13 @@ const int kMaxACKMessageLength = arraysize(kShutdownToken) - 1;
 
 const char kLockDelimiter = '-';
 
+const base::FilePath::CharType kSingletonCookieFilename[] =
+      FILE_PATH_LITERAL("SingletonCookie");
+
+const base::FilePath::CharType kSingletonLockFilename[] = FILE_PATH_LITERAL("SingletonLock");
+const base::FilePath::CharType kSingletonSocketFilename[] =
+      FILE_PATH_LITERAL("SingletonSocket");
+
 // Set the close-on-exec bit on a file descriptor.
 // Returns 0 on success, -1 on failure.
 int SetCloseOnExec(int fd) {
@@ -293,33 +304,20 @@ bool ParseLockPath(const base::FilePath& path,
 bool DisplayProfileInUseError(const base::FilePath& lock_path,
                               const std::string& hostname,
                               int pid) {
-  base::string16 error = l10n_util::GetStringFUTF16(
-      IDS_PROFILE_IN_USE_POSIX,
-      base::IntToString16(pid),
-      base::ASCIIToUTF16(hostname));
-  LOG(ERROR) << error;
-
-  if (g_disable_prompt)
-    return false;
-
-#if defined(OS_LINUX)
-  base::string16 relaunch_button_text = l10n_util::GetStringUTF16(
-      IDS_PROFILE_IN_USE_LINUX_RELAUNCH);
-  return ShowProcessSingletonDialog(error, relaunch_button_text);
-#elif defined(OS_MACOSX)
-  // On Mac, always usurp the lock.
+  // TODO: yolo
   return true;
-#endif
-
-  NOTREACHED();
-  return false;
 }
 
 bool IsChromeProcess(pid_t pid) {
   base::FilePath other_chrome_path(base::GetProcessExecutablePath(pid));
+
+  auto command_line = base::CommandLine::ForCurrentProcess();
+  base::FilePath exec_path(command_line->GetProgram());
+  PathService::Get(base::FILE_EXE, &exec_path);
+
   return (!other_chrome_path.empty() &&
           other_chrome_path.BaseName() ==
-          base::FilePath(chrome::kBrowserProcessExecutableName));
+          exec_path.BaseName());
 }
 
 // A helper class to hold onto a socket.
@@ -360,7 +358,7 @@ bool ConnectSocket(ScopedSocket* socket,
     if (cookie.empty())
       return false;
     base::FilePath remote_cookie = socket_target.DirName().
-                             Append(chrome::kSingletonCookieFilename);
+                             Append(kSingletonCookieFilename);
     // Verify the cookie before connecting.
     if (!CheckCookie(remote_cookie, cookie))
       return false;
@@ -720,9 +718,9 @@ ProcessSingleton::ProcessSingleton(
     : notification_callback_(notification_callback),
       current_pid_(base::GetCurrentProcId()),
       watcher_(new LinuxWatcher(this)) {
-  socket_path_ = user_data_dir.Append(chrome::kSingletonSocketFilename);
-  lock_path_ = user_data_dir.Append(chrome::kSingletonLockFilename);
-  cookie_path_ = user_data_dir.Append(chrome::kSingletonCookieFilename);
+  socket_path_ = user_data_dir.Append(kSingletonSocketFilename);
+  lock_path_ = user_data_dir.Append(kSingletonLockFilename);
+  cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);
 
   kill_callback_ = base::Bind(&ProcessSingleton::KillProcess,
                               base::Unretained(this));
@@ -962,10 +960,10 @@ bool ProcessSingleton::Create() {
 
   // Setup the socket symlink and the two cookies.
   base::FilePath socket_target_path =
-      socket_dir_.path().Append(chrome::kSingletonSocketFilename);
+      socket_dir_.path().Append(kSingletonSocketFilename);
   base::FilePath cookie(GenerateCookie());
   base::FilePath remote_cookie_path =
-      socket_dir_.path().Append(chrome::kSingletonCookieFilename);
+      socket_dir_.path().Append(kSingletonCookieFilename);
   UnlinkPath(socket_path_);
   UnlinkPath(cookie_path_);
   if (!SymlinkPath(socket_target_path, socket_path_) ||