Singleton must be created on request
The creation of singleton relies on the `userData` dir, which can be changed by user, we have to ensure singleton uses the `userData` dir set by user.
This commit is contained in:
parent
0cce6b3d21
commit
952928dc79
7 changed files with 41 additions and 46 deletions
|
@ -62,7 +62,8 @@ class ProcessSingleton {
|
|||
base::Callback<bool(const base::CommandLine::StringVector& command_line,
|
||||
const base::FilePath& current_directory)>;
|
||||
|
||||
explicit ProcessSingleton(const base::FilePath& user_data_dir);
|
||||
ProcessSingleton(const base::FilePath& user_data_dir,
|
||||
const NotificationCallback& notification_callback);
|
||||
~ProcessSingleton();
|
||||
|
||||
// Notify another process, if available. Otherwise sets ourselves as the
|
||||
|
@ -98,11 +99,6 @@ class ProcessSingleton {
|
|||
const ShouldKillRemoteProcessCallback& display_dialog_callback);
|
||||
#endif
|
||||
|
||||
void RegisterSingletonNotificationCallback(
|
||||
const NotificationCallback& callback) {
|
||||
notification_callback_ = callback;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Notify another process, if available.
|
||||
// Returns true if another process was found and notified, false if we should
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/platform_thread.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/timer/timer.h"
|
||||
|
@ -716,9 +717,13 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ProcessSingleton
|
||||
//
|
||||
ProcessSingleton::ProcessSingleton(const base::FilePath& user_data_dir)
|
||||
: current_pid_(base::GetCurrentProcId()) {
|
||||
ProcessSingleton::ProcessSingleton(
|
||||
const base::FilePath& user_data_dir,
|
||||
const NotificationCallback& notification_callback)
|
||||
: notification_callback_(notification_callback),
|
||||
current_pid_(base::GetCurrentProcId()) {
|
||||
// The user_data_dir may have not been created yet.
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
||||
|
||||
socket_path_ = user_data_dir.Append(kSingletonSocketFilename);
|
||||
|
@ -957,6 +962,7 @@ void ProcessSingleton::DisablePromptForTesting() {
|
|||
}
|
||||
|
||||
bool ProcessSingleton::Create() {
|
||||
base::ThreadRestrictions::ScopedAllowIO allow_io;
|
||||
int sock;
|
||||
sockaddr_un addr;
|
||||
|
||||
|
|
|
@ -182,8 +182,11 @@ bool TerminateAppWithError() {
|
|||
|
||||
} // namespace
|
||||
|
||||
ProcessSingleton::ProcessSingleton(const base::FilePath& user_data_dir)
|
||||
: is_virtualized_(false),
|
||||
ProcessSingleton::ProcessSingleton(
|
||||
const base::FilePath& user_data_dir,
|
||||
const NotificationCallback& notification_callback)
|
||||
: notification_callback_(notification_callback),
|
||||
is_virtualized_(false),
|
||||
lock_file_(INVALID_HANDLE_VALUE),
|
||||
user_data_dir_(user_data_dir),
|
||||
should_kill_remote_process_callback_(base::Bind(&TerminateAppWithError)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue