Create user_data_dir before creating singleton lock
authorCheng Zhao <zcbenz@gmail.com>
Wed, 27 Apr 2016 12:46:44 +0000 (21:46 +0900)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 27 Apr 2016 12:52:50 +0000 (21:52 +0900)
chromium_src/chrome/browser/process_singleton_posix.cc
chromium_src/chrome/browser/process_singleton_win.cc

index c583db0..5c26d7b 100644 (file)
@@ -717,6 +717,9 @@ ProcessSingleton::ProcessSingleton(
     const NotificationCallback& notification_callback)
     : notification_callback_(notification_callback),
       current_pid_(base::GetCurrentProcId()) {
+  // The user_data_dir may have not been created yet.
+  base::CreateDirectoryAndGetError(user_data_dir, nullptr);
+
   socket_path_ = user_data_dir.Append(kSingletonSocketFilename);
   lock_path_ = user_data_dir.Append(kSingletonLockFilename);
   cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);
index fd4c22e..b488ad4 100644 (file)
@@ -10,6 +10,7 @@
 #include "base/bind.h"
 #include "base/command_line.h"
 #include "base/files/file_path.h"
+#include "base/files/file_util.h"
 #include "base/process/process.h"
 #include "base/process/process_info.h"
 #include "base/strings/string_number_conversions.h"
@@ -190,6 +191,8 @@ ProcessSingleton::ProcessSingleton(
       user_data_dir_(user_data_dir),
       should_kill_remote_process_callback_(
           base::Bind(&TerminateAppWithError)) {
+  // The user_data_dir may have not been created yet.
+  base::CreateDirectoryAndGetError(user_data_dir, nullptr);
 }
 
 ProcessSingleton::~ProcessSingleton() {