Create user_data_dir before creating singleton lock

This commit is contained in:
Cheng Zhao 2016-04-27 21:46:44 +09:00
parent 302a6e42bd
commit 4435cdc576
2 changed files with 6 additions and 0 deletions

View file

@ -717,6 +717,9 @@ ProcessSingleton::ProcessSingleton(
const NotificationCallback& notification_callback) const NotificationCallback& notification_callback)
: notification_callback_(notification_callback), : notification_callback_(notification_callback),
current_pid_(base::GetCurrentProcId()) { 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); socket_path_ = user_data_dir.Append(kSingletonSocketFilename);
lock_path_ = user_data_dir.Append(kSingletonLockFilename); lock_path_ = user_data_dir.Append(kSingletonLockFilename);
cookie_path_ = user_data_dir.Append(kSingletonCookieFilename); cookie_path_ = user_data_dir.Append(kSingletonCookieFilename);

View file

@ -10,6 +10,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/process/process.h" #include "base/process/process.h"
#include "base/process/process_info.h" #include "base/process/process_info.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
@ -190,6 +191,8 @@ ProcessSingleton::ProcessSingleton(
user_data_dir_(user_data_dir), user_data_dir_(user_data_dir),
should_kill_remote_process_callback_( should_kill_remote_process_callback_(
base::Bind(&TerminateAppWithError)) { base::Bind(&TerminateAppWithError)) {
// The user_data_dir may have not been created yet.
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
} }
ProcessSingleton::~ProcessSingleton() { ProcessSingleton::~ProcessSingleton() {