Ditch double-callback, just use mate directly
This commit is contained in:
parent
a2eedcc027
commit
5d4c29a1e3
2 changed files with 7 additions and 20 deletions
|
@ -269,23 +269,14 @@ v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
|
||||||
return v8::Local<v8::Value>::New(isolate, default_session_);
|
return v8::Local<v8::Value>::New(isolate, default_session_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool App::OnProcessSingletonNotification(
|
|
||||||
const base::CommandLine& command_line,
|
|
||||||
const base::FilePath& current_directory) {
|
|
||||||
ProcessSingleton::NotificationCallback cb;
|
|
||||||
mate::Converter<ProcessSingleton::NotificationCallback>::FromV8(isolate(), single_instance_callback_, &cb);
|
|
||||||
|
|
||||||
return cb.Run(command_line, current_directory);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
|
bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
|
||||||
single_instance_callback_ = callback;
|
single_instance_callback_ = callback;
|
||||||
|
|
||||||
auto browser = Browser::Get();
|
ProcessSingleton::NotificationCallback cb;
|
||||||
|
mate::Converter<ProcessSingleton::NotificationCallback>::FromV8(isolate(), single_instance_callback_, &cb);
|
||||||
|
|
||||||
auto no_refcount_this = base::Unretained(this);
|
auto browser = Browser::Get();
|
||||||
browser->SetSingleInstanceCallback(
|
browser->SetSingleInstanceCallback(cb);
|
||||||
base::Bind(&App::OnProcessSingletonNotification, no_refcount_this));
|
|
||||||
|
|
||||||
switch(browser->GetSingleInstanceResult()) {
|
switch(browser->GetSingleInstanceResult()) {
|
||||||
case ProcessSingleton::NotifyResult::PROCESS_NONE:
|
case ProcessSingleton::NotifyResult::PROCESS_NONE:
|
||||||
|
@ -295,7 +286,7 @@ bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
|
||||||
case ProcessSingleton::NotifyResult::PROCESS_NOTIFIED:
|
case ProcessSingleton::NotifyResult::PROCESS_NOTIFIED:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class FilePath;
|
||||||
namespace mate {
|
namespace mate {
|
||||||
class Arguments;
|
class Arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
@ -71,11 +71,7 @@ class App : public mate::EventEmitter,
|
||||||
void AllowNTLMCredentialsForAllDomains(bool should_allow);
|
void AllowNTLMCredentialsForAllDomains(bool should_allow);
|
||||||
|
|
||||||
bool MakeSingleInstance(v8::Local<v8::Function> callback);
|
bool MakeSingleInstance(v8::Local<v8::Function> callback);
|
||||||
|
|
||||||
bool OnProcessSingletonNotification(
|
|
||||||
const base::CommandLine& command_line,
|
|
||||||
const base::FilePath& current_directory);
|
|
||||||
|
|
||||||
std::string GetLocale();
|
std::string GetLocale();
|
||||||
v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate);
|
v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue