Fix callback handle usage
This commit is contained in:
parent
50fab0733b
commit
4a4b829cfc
4 changed files with 32 additions and 13 deletions
|
@ -269,10 +269,21 @@ v8::Local<v8::Value> App::DefaultSession(v8::Isolate* isolate) {
|
|||
return v8::Local<v8::Value>::New(isolate, default_session_);
|
||||
}
|
||||
|
||||
bool App::MakeSingleInstance(const ProcessSingleton::NotificationCallback& callback) {
|
||||
bool App::OnProcessSingletonNotification(
|
||||
const base::CommandLine& command_line,
|
||||
const base::FilePath& current_directory) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool App::MakeSingleInstance(v8::Local<v8::Function> callback) {
|
||||
single_instance_callback_ = callback;
|
||||
|
||||
auto browser = Browser::Get();
|
||||
browser->SetSingleInstanceCallback(&callback);
|
||||
|
||||
|
||||
auto no_refcount_this = base::Unretained(this);
|
||||
browser->SetSingleInstanceCallback(
|
||||
base::Bind(&App::OnProcessSingletonNotification, no_refcount_this));
|
||||
|
||||
switch(browser->GetSingleInstanceResult()) {
|
||||
case ProcessSingleton::NotifyResult::PROCESS_NONE:
|
||||
return false;
|
||||
|
|
|
@ -70,11 +70,16 @@ class App : public mate::EventEmitter,
|
|||
|
||||
void AllowNTLMCredentialsForAllDomains(bool should_allow);
|
||||
|
||||
bool MakeSingleInstance(const ProcessSingleton::NotificationCallback& callback);
|
||||
bool MakeSingleInstance(v8::Local<v8::Function> callback);
|
||||
|
||||
bool OnProcessSingletonNotification(
|
||||
const base::CommandLine& command_line,
|
||||
const base::FilePath& current_directory);
|
||||
|
||||
std::string GetLocale();
|
||||
v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate);
|
||||
|
||||
v8::Local<v8::Function> single_instance_callback_;
|
||||
v8::Global<v8::Value> default_session_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(App);
|
||||
|
|
|
@ -20,7 +20,7 @@ Browser::Browser()
|
|||
: is_quiting_(false),
|
||||
is_ready_(false),
|
||||
is_shutdown_(false),
|
||||
process_notify_callback_(NULL) {
|
||||
process_notify_callback_set_(false) {
|
||||
WindowList::AddObserver(this);
|
||||
}
|
||||
|
||||
|
@ -169,11 +169,13 @@ bool Browser::HandleBeforeQuit() {
|
|||
}
|
||||
|
||||
ProcessSingleton::NotifyResult Browser::GetSingleInstanceResult() {
|
||||
LOG(ERROR) << "Process Notify Result: " << process_notify_result_;
|
||||
return process_notify_result_;
|
||||
}
|
||||
|
||||
void Browser::SetSingleInstanceCallback(const ProcessSingleton::NotificationCallback* callback) {
|
||||
|
||||
void Browser::SetSingleInstanceCallback(const ProcessSingleton::NotificationCallback& callback) {
|
||||
process_notify_callback_ = callback;
|
||||
process_notify_callback_set_ = true;
|
||||
}
|
||||
|
||||
void Browser::OnWindowCloseCancelled(NativeWindow* window) {
|
||||
|
@ -193,8 +195,8 @@ void Browser::OnWindowAllClosed() {
|
|||
bool Browser::OnProcessSingletonNotification(
|
||||
const base::CommandLine& command_line,
|
||||
const base::FilePath& current_directory) {
|
||||
if (process_notify_callback_) {
|
||||
return (*process_notify_callback_).Run(command_line, current_directory);
|
||||
if (process_notify_callback_set_) {
|
||||
return process_notify_callback_.Run(command_line, current_directory);
|
||||
} else {
|
||||
return true; // We'll handle this, not a different process
|
||||
}
|
||||
|
|
|
@ -65,9 +65,9 @@ class Browser : public WindowListObserver {
|
|||
|
||||
// Clear the recent documents list.
|
||||
void ClearRecentDocuments();
|
||||
|
||||
|
||||
ProcessSingleton::NotifyResult GetSingleInstanceResult();
|
||||
void SetSingleInstanceCallback(const ProcessSingleton::NotificationCallback* callback);
|
||||
void SetSingleInstanceCallback(const ProcessSingleton::NotificationCallback& callback);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Bounce the dock icon.
|
||||
|
@ -173,10 +173,11 @@ class Browser : public WindowListObserver {
|
|||
|
||||
std::string version_override_;
|
||||
std::string name_override_;
|
||||
|
||||
|
||||
scoped_ptr<AtomProcessSingleton> process_singleton_;
|
||||
ProcessSingleton::NotifyResult process_notify_result_;
|
||||
const ProcessSingleton::NotificationCallback* process_notify_callback_;
|
||||
const ProcessSingleton::NotificationCallback process_notify_callback_;
|
||||
bool process_notify_callback_set_;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
base::string16 app_user_model_id_;
|
||||
|
|
Loading…
Reference in a new issue