Move initialization of Single Instance into MakeSingleInstance call
This commit is contained in:
parent
5d4c29a1e3
commit
b6f1729acd
3 changed files with 18 additions and 14 deletions
|
@ -270,12 +270,14 @@ v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
|
bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
|
||||||
|
auto browser = Browser::Get();
|
||||||
single_instance_callback_ = callback;
|
single_instance_callback_ = callback;
|
||||||
|
|
||||||
|
browser->InitializeSingleInstance();
|
||||||
|
|
||||||
ProcessSingleton::NotificationCallback cb;
|
ProcessSingleton::NotificationCallback cb;
|
||||||
mate::Converter<ProcessSingleton::NotificationCallback>::FromV8(isolate(), single_instance_callback_, &cb);
|
mate::Converter<ProcessSingleton::NotificationCallback>::FromV8(isolate(), single_instance_callback_, &cb);
|
||||||
|
|
||||||
auto browser = Browser::Get();
|
|
||||||
browser->SetSingleInstanceCallback(cb);
|
browser->SetSingleInstanceCallback(cb);
|
||||||
|
|
||||||
switch(browser->GetSingleInstanceResult()) {
|
switch(browser->GetSingleInstanceResult()) {
|
||||||
|
|
|
@ -112,17 +112,6 @@ void Browser::Activate(bool has_visible_windows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::WillFinishLaunching() {
|
void Browser::WillFinishLaunching() {
|
||||||
base::FilePath userDir;
|
|
||||||
PathService::Get(brightray::DIR_USER_DATA, &userDir);
|
|
||||||
|
|
||||||
auto no_refcount_this = base::Unretained(this);
|
|
||||||
process_singleton_.reset(new AtomProcessSingleton(
|
|
||||||
userDir,
|
|
||||||
base::Bind(&Browser::OnProcessSingletonNotification, no_refcount_this)));
|
|
||||||
|
|
||||||
LOG(ERROR) << "Setting up Process Singleton: " << userDir.value();
|
|
||||||
process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
|
|
||||||
|
|
||||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
|
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnWillFinishLaunching());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +157,18 @@ bool Browser::HandleBeforeQuit() {
|
||||||
return !prevent_default;
|
return !prevent_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Browser::InitializeSingleInstance() {
|
||||||
|
base::FilePath userDir;
|
||||||
|
PathService::Get(brightray::DIR_USER_DATA, &userDir);
|
||||||
|
|
||||||
|
auto no_refcount_this = base::Unretained(this);
|
||||||
|
process_singleton_.reset(new AtomProcessSingleton(
|
||||||
|
userDir,
|
||||||
|
base::Bind(&Browser::OnProcessSingletonNotification, no_refcount_this)));
|
||||||
|
|
||||||
|
process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
|
||||||
|
}
|
||||||
|
|
||||||
ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() {
|
ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() {
|
||||||
LOG(ERROR) << "Process Notify Result: " << process_notify_result_;
|
LOG(ERROR) << "Process Notify Result: " << process_notify_result_;
|
||||||
return process_notify_result_;
|
return process_notify_result_;
|
||||||
|
|
|
@ -66,6 +66,7 @@ class Browser : public WindowListObserver {
|
||||||
// Clear the recent documents list.
|
// Clear the recent documents list.
|
||||||
void ClearRecentDocuments();
|
void ClearRecentDocuments();
|
||||||
|
|
||||||
|
void InitializeSingleInstance();
|
||||||
ProcessSingleton::NotifyResult GetSingleInstanceResult();
|
ProcessSingleton::NotifyResult GetSingleInstanceResult();
|
||||||
void SetSingleInstanceCallback(ProcessSingleton::NotificationCallback callback);
|
void SetSingleInstanceCallback(ProcessSingleton::NotificationCallback callback);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue