REVIEW: destroy process singleton on sequence where IO is allowed
This commit is contained in:
parent
c3154d86e0
commit
88e53b1b5e
13 changed files with 90 additions and 110 deletions
|
@ -529,6 +529,8 @@ void OnIconDataAvailable(v8::Isolate* isolate,
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
App::App(v8::Isolate* isolate) {
|
App::App(v8::Isolate* isolate) {
|
||||||
|
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||||
|
|
||||||
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->set_delegate(this);
|
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->set_delegate(this);
|
||||||
Browser::Get()->AddObserver(this);
|
Browser::Get()->AddObserver(this);
|
||||||
content::GpuDataManager::GetInstance()->AddObserver(this);
|
content::GpuDataManager::GetInstance()->AddObserver(this);
|
||||||
|
@ -566,11 +568,6 @@ void App::OnWindowAllClosed() {
|
||||||
void App::OnQuit() {
|
void App::OnQuit() {
|
||||||
int exitCode = AtomBrowserMainParts::Get()->GetExitCode();
|
int exitCode = AtomBrowserMainParts::Get()->GetExitCode();
|
||||||
Emit("quit", exitCode);
|
Emit("quit", exitCode);
|
||||||
|
|
||||||
if (process_singleton_) {
|
|
||||||
process_singleton_->Cleanup();
|
|
||||||
process_singleton_.reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnOpenFile(bool* prevent_default, const std::string& file_path) {
|
void App::OnOpenFile(bool* prevent_default, const std::string& file_path) {
|
||||||
|
@ -598,12 +595,6 @@ void App::OnFinishLaunching(const base::DictionaryValue& launch_info) {
|
||||||
Emit("ready", launch_info);
|
Emit("ready", launch_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnPreMainMessageLoopRun() {
|
|
||||||
if (process_singleton_) {
|
|
||||||
process_singleton_->OnBrowserReady();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::OnAccessibilitySupportChanged() {
|
void App::OnAccessibilitySupportChanged() {
|
||||||
Emit("accessibility-support-changed", IsAccessibilitySupportEnabled());
|
Emit("accessibility-support-changed", IsAccessibilitySupportEnabled());
|
||||||
}
|
}
|
||||||
|
@ -856,20 +847,20 @@ std::string App::GetLocale() {
|
||||||
|
|
||||||
bool App::MakeSingleInstance(
|
bool App::MakeSingleInstance(
|
||||||
const ProcessSingleton::NotificationCallback& callback) {
|
const ProcessSingleton::NotificationCallback& callback) {
|
||||||
if (process_singleton_)
|
auto process_singleton = AtomBrowserMainParts::Get()->process_singleton();
|
||||||
|
if (process_singleton_created_)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
base::FilePath user_dir;
|
process_singleton->RegisterSingletonNotificationCallback(
|
||||||
PathService::Get(brightray::DIR_USER_DATA, &user_dir);
|
base::Bind(NotificationCallbackWrapper, callback));
|
||||||
process_singleton_.reset(new ProcessSingleton(
|
|
||||||
user_dir, base::Bind(NotificationCallbackWrapper, callback)));
|
|
||||||
|
|
||||||
switch (process_singleton_->NotifyOtherProcessOrCreate()) {
|
switch (process_singleton->NotifyOtherProcessOrCreate()) {
|
||||||
case ProcessSingleton::NotifyResult::LOCK_ERROR:
|
case ProcessSingleton::NotifyResult::LOCK_ERROR:
|
||||||
case ProcessSingleton::NotifyResult::PROFILE_IN_USE:
|
case ProcessSingleton::NotifyResult::PROFILE_IN_USE:
|
||||||
case ProcessSingleton::NotifyResult::PROCESS_NOTIFIED:
|
case ProcessSingleton::NotifyResult::PROCESS_NOTIFIED: {
|
||||||
process_singleton_.reset();
|
process_singleton_created_ = true;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
case ProcessSingleton::NotifyResult::PROCESS_NONE:
|
case ProcessSingleton::NotifyResult::PROCESS_NONE:
|
||||||
default: // Shouldn't be needed, but VS warns if it is not there.
|
default: // Shouldn't be needed, but VS warns if it is not there.
|
||||||
return false;
|
return false;
|
||||||
|
@ -877,9 +868,9 @@ bool App::MakeSingleInstance(
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::ReleaseSingleInstance() {
|
void App::ReleaseSingleInstance() {
|
||||||
if (process_singleton_) {
|
auto process_singleton = AtomBrowserMainParts::Get()->process_singleton();
|
||||||
process_singleton_->Cleanup();
|
if (process_singleton) {
|
||||||
process_singleton_.reset();
|
process_singleton->Cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,6 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
void OnLogin(LoginHandler* login_handler,
|
void OnLogin(LoginHandler* login_handler,
|
||||||
const base::DictionaryValue& request_details) override;
|
const base::DictionaryValue& request_details) override;
|
||||||
void OnAccessibilitySupportChanged() override;
|
void OnAccessibilitySupportChanged() override;
|
||||||
void OnPreMainMessageLoopRun() override;
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void OnWillContinueUserActivity(
|
void OnWillContinueUserActivity(
|
||||||
bool* prevent_default,
|
bool* prevent_default,
|
||||||
|
@ -218,8 +217,6 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
JumpListResult SetJumpList(v8::Local<v8::Value> val, mate::Arguments* args);
|
JumpListResult SetJumpList(v8::Local<v8::Value> val, mate::Arguments* args);
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
|
|
||||||
std::unique_ptr<ProcessSingleton> process_singleton_;
|
|
||||||
|
|
||||||
#if defined(USE_NSS_CERTS)
|
#if defined(USE_NSS_CERTS)
|
||||||
std::unique_ptr<CertificateManagerModel> certificate_manager_model_;
|
std::unique_ptr<CertificateManagerModel> certificate_manager_model_;
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,6 +231,8 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
std::unique_ptr<atom::ProcessMetric>>;
|
std::unique_ptr<atom::ProcessMetric>>;
|
||||||
ProcessMetricMap app_metrics_;
|
ProcessMetricMap app_metrics_;
|
||||||
|
|
||||||
|
bool process_singleton_created_ = false;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(App);
|
DISALLOW_COPY_AND_ASSIGN(App);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -126,27 +126,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
||||||
|
|
||||||
// The ProxyResolverV8 has setup a complete V8 environment, in order to
|
// The ProxyResolverV8 has setup a complete V8 environment, in order to
|
||||||
// avoid conflicts we only initialize our V8 environment after that.
|
// avoid conflicts we only initialize our V8 environment after that.
|
||||||
js_env_.reset(new JavascriptEnvironment);
|
JavascriptEnvironment::Initialize();
|
||||||
|
|
||||||
node_bindings_->Initialize();
|
|
||||||
|
|
||||||
// Create the global environment.
|
|
||||||
node::Environment* env =
|
|
||||||
node_bindings_->CreateEnvironment(js_env_->context());
|
|
||||||
node_env_.reset(new NodeEnvironment(env));
|
|
||||||
|
|
||||||
// Enable support for v8 inspector
|
|
||||||
node_debugger_.reset(new NodeDebugger(env));
|
|
||||||
node_debugger_->Start(js_env_->platform());
|
|
||||||
|
|
||||||
// Add Electron extended APIs.
|
|
||||||
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
|
||||||
|
|
||||||
// Load everything.
|
|
||||||
node_bindings_->LoadEnvironment(env);
|
|
||||||
|
|
||||||
// Wrap the uv loop with global env.
|
|
||||||
node_bindings_->set_uv_env(env);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
|
@ -185,7 +165,8 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
Browser::Get()->DidFinishLaunching(*empty_info);
|
Browser::Get()->DidFinishLaunching(*empty_info);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Browser::Get()->PreMainMessageLoopRun();
|
if (process_singleton_)
|
||||||
|
process_singleton_->OnBrowserReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
bool AtomBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
||||||
|
@ -200,6 +181,32 @@ void AtomBrowserMainParts::PostMainMessageLoopStart() {
|
||||||
#endif
|
#endif
|
||||||
device::GeolocationProvider::SetGeolocationDelegate(
|
device::GeolocationProvider::SetGeolocationDelegate(
|
||||||
new AtomGeolocationDelegate());
|
new AtomGeolocationDelegate());
|
||||||
|
|
||||||
|
base::FilePath user_dir;
|
||||||
|
PathService::Get(brightray::DIR_USER_DATA, &user_dir);
|
||||||
|
process_singleton_.reset(new ProcessSingleton(user_dir));
|
||||||
|
|
||||||
|
js_env_.reset(new JavascriptEnvironment);
|
||||||
|
|
||||||
|
node_bindings_->Initialize();
|
||||||
|
|
||||||
|
// Create the global environment.
|
||||||
|
node::Environment* env =
|
||||||
|
node_bindings_->CreateEnvironment(js_env_->context());
|
||||||
|
node_env_.reset(new NodeEnvironment(env));
|
||||||
|
|
||||||
|
// Enable support for v8 inspector
|
||||||
|
node_debugger_.reset(new NodeDebugger(env));
|
||||||
|
node_debugger_->Start();
|
||||||
|
|
||||||
|
// Add Electron extended APIs.
|
||||||
|
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||||
|
|
||||||
|
// Load everything.
|
||||||
|
node_bindings_->LoadEnvironment(env);
|
||||||
|
|
||||||
|
// Wrap the uv loop with global env.
|
||||||
|
node_bindings_->set_uv_env(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
||||||
|
@ -223,4 +230,12 @@ void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AtomBrowserMainParts::PostDestroyThreads() {
|
||||||
|
brightray::BrowserMainParts::PostDestroyThreads();
|
||||||
|
if (process_singleton_) {
|
||||||
|
process_singleton_->Cleanup();
|
||||||
|
process_singleton_.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/timer/timer.h"
|
#include "base/timer/timer.h"
|
||||||
#include "brightray/browser/browser_main_parts.h"
|
#include "brightray/browser/browser_main_parts.h"
|
||||||
|
#include "chrome/browser/process_singleton.h"
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
|
|
||||||
class BrowserProcess;
|
class BrowserProcess;
|
||||||
|
@ -44,6 +45,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||||
base::Closure RegisterDestructionCallback(const base::Closure& callback);
|
base::Closure RegisterDestructionCallback(const base::Closure& callback);
|
||||||
|
|
||||||
Browser* browser() { return browser_.get(); }
|
Browser* browser() { return browser_.get(); }
|
||||||
|
ProcessSingleton* process_singleton() { return process_singleton_.get(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// content::BrowserMainParts:
|
// content::BrowserMainParts:
|
||||||
|
@ -56,6 +58,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void PreMainMessageLoopStart() override;
|
void PreMainMessageLoopStart() override;
|
||||||
#endif
|
#endif
|
||||||
|
void PostDestroyThreads() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(OS_POSIX)
|
#if defined(OS_POSIX)
|
||||||
|
@ -84,6 +87,7 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
|
||||||
std::unique_ptr<AtomBindings> atom_bindings_;
|
std::unique_ptr<AtomBindings> atom_bindings_;
|
||||||
std::unique_ptr<NodeEnvironment> node_env_;
|
std::unique_ptr<NodeEnvironment> node_env_;
|
||||||
std::unique_ptr<NodeDebugger> node_debugger_;
|
std::unique_ptr<NodeDebugger> node_debugger_;
|
||||||
|
std::unique_ptr<ProcessSingleton> process_singleton_;
|
||||||
|
|
||||||
base::Timer gc_timer_;
|
base::Timer gc_timer_;
|
||||||
|
|
||||||
|
|
|
@ -203,12 +203,6 @@ void Browser::RequestLogin(
|
||||||
observer.OnLogin(login_handler, *(request_details.get()));
|
observer.OnLogin(login_handler, *(request_details.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::PreMainMessageLoopRun() {
|
|
||||||
for (BrowserObserver& observer : observers_) {
|
|
||||||
observer.OnPreMainMessageLoopRun();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Browser::NotifyAndShutdown() {
|
void Browser::NotifyAndShutdown() {
|
||||||
if (is_shutdown_)
|
if (is_shutdown_)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -224,8 +224,6 @@ class Browser : public WindowListObserver {
|
||||||
void RequestLogin(LoginHandler* login_handler,
|
void RequestLogin(LoginHandler* login_handler,
|
||||||
std::unique_ptr<base::DictionaryValue> request_details);
|
std::unique_ptr<base::DictionaryValue> request_details);
|
||||||
|
|
||||||
void PreMainMessageLoopRun();
|
|
||||||
|
|
||||||
void AddObserver(BrowserObserver* obs) {
|
void AddObserver(BrowserObserver* obs) {
|
||||||
observers_.AddObserver(obs);
|
observers_.AddObserver(obs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,6 @@ class BrowserObserver {
|
||||||
// The browser's accessibility suppport has changed.
|
// The browser's accessibility suppport has changed.
|
||||||
virtual void OnAccessibilitySupportChanged() {}
|
virtual void OnAccessibilitySupportChanged() {}
|
||||||
|
|
||||||
// The app message loop is ready
|
|
||||||
virtual void OnPreMainMessageLoopRun() {}
|
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
// The browser wants to report that an user activity will resume. (macOS only)
|
// The browser wants to report that an user activity will resume. (macOS only)
|
||||||
virtual void OnWillContinueUserActivity(
|
virtual void OnWillContinueUserActivity(
|
||||||
|
|
|
@ -18,26 +18,8 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
JavascriptEnvironment::JavascriptEnvironment()
|
// static
|
||||||
: initialized_(Initialize()),
|
void JavascriptEnvironment::Initialize() {
|
||||||
isolate_holder_(base::ThreadTaskRunnerHandle::Get()),
|
|
||||||
isolate_(isolate_holder_.isolate()),
|
|
||||||
isolate_scope_(isolate_),
|
|
||||||
locker_(isolate_),
|
|
||||||
handle_scope_(isolate_),
|
|
||||||
context_(isolate_, v8::Context::New(isolate_)),
|
|
||||||
context_scope_(v8::Local<v8::Context>::New(isolate_, context_)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void JavascriptEnvironment::OnMessageLoopCreated() {
|
|
||||||
isolate_holder_.AddRunMicrotasksObserver();
|
|
||||||
}
|
|
||||||
|
|
||||||
void JavascriptEnvironment::OnMessageLoopDestroying() {
|
|
||||||
isolate_holder_.RemoveRunMicrotasksObserver();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool JavascriptEnvironment::Initialize() {
|
|
||||||
auto cmd = base::CommandLine::ForCurrentProcess();
|
auto cmd = base::CommandLine::ForCurrentProcess();
|
||||||
|
|
||||||
// --js-flags.
|
// --js-flags.
|
||||||
|
@ -45,18 +27,26 @@ bool JavascriptEnvironment::Initialize() {
|
||||||
if (!js_flags.empty())
|
if (!js_flags.empty())
|
||||||
v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size());
|
v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size());
|
||||||
|
|
||||||
// The V8Platform of gin relies on Chromium's task schedule, which has not
|
|
||||||
// been started at this point, so we have to rely on Node's V8Platform.
|
|
||||||
platform_ = node::CreatePlatform(
|
|
||||||
base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0),
|
|
||||||
uv_default_loop(), nullptr);
|
|
||||||
v8::V8::InitializePlatform(platform_);
|
|
||||||
|
|
||||||
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
||||||
gin::IsolateHolder::kStableV8Extras,
|
gin::IsolateHolder::kStableV8Extras,
|
||||||
gin::ArrayBufferAllocator::SharedInstance(),
|
gin::ArrayBufferAllocator::SharedInstance());
|
||||||
false);
|
}
|
||||||
return true;
|
|
||||||
|
JavascriptEnvironment::JavascriptEnvironment()
|
||||||
|
: isolate_holder_(base::ThreadTaskRunnerHandle::Get()),
|
||||||
|
isolate_(isolate_holder_.isolate()),
|
||||||
|
isolate_scope_(isolate_),
|
||||||
|
locker_(isolate_),
|
||||||
|
handle_scope_(isolate_),
|
||||||
|
context_(isolate_, v8::Context::New(isolate_)),
|
||||||
|
context_scope_(v8::Local<v8::Context>::New(isolate_, context_)) {}
|
||||||
|
|
||||||
|
void JavascriptEnvironment::OnMessageLoopCreated() {
|
||||||
|
isolate_holder_.AddRunMicrotasksObserver();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JavascriptEnvironment::OnMessageLoopDestroying() {
|
||||||
|
isolate_holder_.RemoveRunMicrotasksObserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) {
|
NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) {
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace atom {
|
||||||
// Manage the V8 isolate and context automatically.
|
// Manage the V8 isolate and context automatically.
|
||||||
class JavascriptEnvironment {
|
class JavascriptEnvironment {
|
||||||
public:
|
public:
|
||||||
|
static void Initialize();
|
||||||
|
|
||||||
JavascriptEnvironment();
|
JavascriptEnvironment();
|
||||||
|
|
||||||
void OnMessageLoopCreated();
|
void OnMessageLoopCreated();
|
||||||
|
@ -30,12 +32,6 @@ class JavascriptEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Initialize();
|
|
||||||
|
|
||||||
// Leaked on exit.
|
|
||||||
node::NodePlatform* platform_;
|
|
||||||
|
|
||||||
bool initialized_;
|
|
||||||
gin::IsolateHolder isolate_holder_;
|
gin::IsolateHolder isolate_holder_;
|
||||||
v8::Isolate* isolate_;
|
v8::Isolate* isolate_;
|
||||||
v8::Isolate::Scope isolate_scope_;
|
v8::Isolate::Scope isolate_scope_;
|
||||||
|
|
|
@ -62,8 +62,7 @@ class ProcessSingleton {
|
||||||
base::Callback<bool(const base::CommandLine::StringVector& command_line,
|
base::Callback<bool(const base::CommandLine::StringVector& command_line,
|
||||||
const base::FilePath& current_directory)>;
|
const base::FilePath& current_directory)>;
|
||||||
|
|
||||||
ProcessSingleton(const base::FilePath& user_data_dir,
|
explicit ProcessSingleton(const base::FilePath& user_data_dir);
|
||||||
const NotificationCallback& notification_callback);
|
|
||||||
~ProcessSingleton();
|
~ProcessSingleton();
|
||||||
|
|
||||||
// Notify another process, if available. Otherwise sets ourselves as the
|
// Notify another process, if available. Otherwise sets ourselves as the
|
||||||
|
@ -99,6 +98,11 @@ class ProcessSingleton {
|
||||||
const ShouldKillRemoteProcessCallback& display_dialog_callback);
|
const ShouldKillRemoteProcessCallback& display_dialog_callback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void RegisterSingletonNotificationCallback(
|
||||||
|
const NotificationCallback& callback) {
|
||||||
|
notification_callback_ = callback;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Notify another process, if available.
|
// Notify another process, if available.
|
||||||
// Returns true if another process was found and notified, false if we should
|
// Returns true if another process was found and notified, false if we should
|
||||||
|
|
|
@ -716,11 +716,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// ProcessSingleton
|
// ProcessSingleton
|
||||||
//
|
//
|
||||||
ProcessSingleton::ProcessSingleton(
|
ProcessSingleton::ProcessSingleton(const base::FilePath& user_data_dir)
|
||||||
const base::FilePath& user_data_dir,
|
: current_pid_(base::GetCurrentProcId()) {
|
||||||
const NotificationCallback& notification_callback)
|
|
||||||
: notification_callback_(notification_callback),
|
|
||||||
current_pid_(base::GetCurrentProcId()) {
|
|
||||||
// The user_data_dir may have not been created yet.
|
// The user_data_dir may have not been created yet.
|
||||||
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
||||||
|
|
||||||
|
|
|
@ -182,15 +182,11 @@ bool TerminateAppWithError() {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ProcessSingleton::ProcessSingleton(
|
ProcessSingleton::ProcessSingleton(const base::FilePath& user_data_dir)
|
||||||
const base::FilePath& user_data_dir,
|
: is_virtualized_(false),
|
||||||
const NotificationCallback& notification_callback)
|
|
||||||
: notification_callback_(notification_callback),
|
|
||||||
is_virtualized_(false),
|
|
||||||
lock_file_(INVALID_HANDLE_VALUE),
|
lock_file_(INVALID_HANDLE_VALUE),
|
||||||
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.
|
// The user_data_dir may have not been created yet.
|
||||||
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,8 +159,7 @@ describe('app module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO(deepak1556): Fix and enable for base dchecks.
|
describe('app.makeSingleInstance', () => {
|
||||||
xdescribe('app.makeSingleInstance', () => {
|
|
||||||
it('prevents the second launch of app', function (done) {
|
it('prevents the second launch of app', function (done) {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
const appPath = path.join(__dirname, 'fixtures', 'api', 'singleton')
|
const appPath = path.join(__dirname, 'fixtures', 'api', 'singleton')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue