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

Unified Diff: chrome/browser/process_singleton_posix.cc

Issue 218883008: Use process_singleton_linux on Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CreateUniqueTempDir is fine. DCHECK socket path length. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/process_singleton_posix.cc
diff --git a/chrome/browser/process_singleton_linux.cc b/chrome/browser/process_singleton_posix.cc
similarity index 98%
rename from chrome/browser/process_singleton_linux.cc
rename to chrome/browser/process_singleton_posix.cc
index 54d7db296f329d29016c8f5ba35d64bbefadd778..0fff4d61484127477565007b0d80e96ca51a75cc 100644
--- a/chrome/browser/process_singleton_linux.cc
+++ b/chrome/browser/process_singleton_posix.cc
@@ -74,7 +74,6 @@
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
-#include "chrome/browser/ui/process_singleton_dialog_linux.h"
#include "chrome/common/chrome_constants.h"
#include "content/public/browser/browser_thread.h"
#include "grit/chromium_strings.h"
@@ -82,6 +81,10 @@
#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
+#if defined(OS_LINUX)
+#include "chrome/browser/ui/process_singleton_dialog_linux.h"
+#endif
+
#if defined(TOOLKIT_VIEWS) && !defined(OS_CHROMEOS)
#include "ui/views/linux_ui/linux_ui.h"
#endif
@@ -298,14 +301,21 @@ bool DisplayProfileInUseError(const base::FilePath& lock_path,
const std::string& hostname,
int pid) {
base::string16 error = l10n_util::GetStringFUTF16(
- IDS_PROFILE_IN_USE_LINUX,
+ IDS_PROFILE_IN_USE_POSIX,
base::IntToString16(pid),
base::ASCIIToUTF16(hostname));
+ LOG(ERROR) << base::SysWideToNativeMB(base::UTF16ToWide(error)).c_str();
+ if (!g_disable_prompt) {
+#if defined(OS_LINUX)
base::string16 relaunch_button_text = l10n_util::GetStringUTF16(
IDS_PROFILE_IN_USE_LINUX_RELAUNCH);
- LOG(ERROR) << base::SysWideToNativeMB(base::UTF16ToWide(error)).c_str();
- if (!g_disable_prompt)
- return ShowProcessSingletonDialog(error, relaunch_button_text);
+ return ShowProcessSingletonDialog(error, relaunch_button_text);
Scott Hess - ex-Googler 2014/04/18 20:51:33 Indentation is wrong in here. I think having the
jackhou1 2014/04/24 02:34:54 Done.
+#endif
+#if defined(OS_MACOSX)
Scott Hess - ex-Googler 2014/04/18 20:51:33 I think #elif defined(OS_MACOSX) would make sense,
jackhou1 2014/04/24 02:34:54 Done.
+ // On Mac, always usurp the lock.
+ return true;
+#endif
+ }
tapted 2014/04/17 08:36:14 should this closing paren be before the #if?
jackhou1 2014/04/24 02:34:54 It matches with the "if (!g_disable_prompt) {", bu
return false;
}
@@ -895,9 +905,21 @@ bool ProcessSingleton::Create() {
LOG(ERROR) << "Failed to create socket directory.";
return false;
}
+
+ // Check that the directory was created with the correct permissions.
+ int dir_mode = 0;
+ if (!base::GetPosixFilePermissions(socket_dir_.path(), &dir_mode) ||
+ dir_mode != base::FILE_PERMISSION_USER_MASK) {
mattm 2014/04/17 21:44:55 Should log an error here?
Scott Hess - ex-Googler 2014/04/18 20:51:33 As long as it doesn't cruft up buildbot or other l
jackhou1 2014/04/24 02:34:54 We don't want to create a socket in an unsafe dire
+ NOTREACHED();
+ return false;
+ }
+
// Setup the socket symlink and the two cookies.
base::FilePath socket_target_path =
socket_dir_.path().Append(chrome::kSingletonSocketFilename);
+ // Check that socket_target_path is short enough for a Unix domain socket.
+ DCHECK_GT(104u, socket_target_path.value().length());
tapted 2014/04/17 08:36:14 This might only make sense on Mac, where the strin
mattm 2014/04/17 21:44:55 SetupSocket already has a CHECK() of the path leng
Scott Hess - ex-Googler 2014/04/18 20:51:33 I would think that would be why you'd want the che
jackhou1 2014/04/24 02:34:54 You're right, the check in SetupSocketAddr does th
+
base::FilePath cookie(GenerateCookie());
base::FilePath remote_cookie_path =
socket_dir_.path().Append(chrome::kSingletonCookieFilename);

Powered by Google App Engine
This is Rietveld 408576698