Correctly handle notification callback when shutting down
When returning false in the notification callback the ProcessSingleton will assume current process is quitting, we should met its expectation.
This commit is contained in:
parent
ca876e424b
commit
e14fd62f46
3 changed files with 16 additions and 6 deletions
|
@ -112,6 +112,15 @@ int GetPathConstant(const std::string& name) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run the NotificationCallback and returns whether browser is shuting down.
|
||||||
|
bool NotificationCallbackWrapper(
|
||||||
|
const ProcessSingleton::NotificationCallback& callback,
|
||||||
|
const base::CommandLine& command_line,
|
||||||
|
const base::FilePath& current_directory) {
|
||||||
|
callback.Run(command_line, current_directory);
|
||||||
|
return !Browser::Get()->is_shutting_down();
|
||||||
|
}
|
||||||
|
|
||||||
void OnClientCertificateSelected(
|
void OnClientCertificateSelected(
|
||||||
v8::Isolate* isolate,
|
v8::Isolate* isolate,
|
||||||
std::shared_ptr<content::ClientCertificateDelegate> delegate,
|
std::shared_ptr<content::ClientCertificateDelegate> delegate,
|
||||||
|
@ -277,7 +286,8 @@ 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::MakeSingleInstance(ProcessSingleton::NotificationCallback callback) {
|
bool App::MakeSingleInstance(
|
||||||
|
const ProcessSingleton::NotificationCallback& callback) {
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
LOG(ERROR) << "MakeSingleInstance is not implemnted on OS X";
|
LOG(ERROR) << "MakeSingleInstance is not implemnted on OS X";
|
||||||
return false;
|
return false;
|
||||||
|
@ -289,7 +299,8 @@ bool App::MakeSingleInstance(ProcessSingleton::NotificationCallback callback) {
|
||||||
PathService::Get(brightray::DIR_USER_DATA, &user_dir);
|
PathService::Get(brightray::DIR_USER_DATA, &user_dir);
|
||||||
|
|
||||||
process_singleton_startup_lock_.reset(
|
process_singleton_startup_lock_.reset(
|
||||||
new ProcessSingletonStartupLock(callback));
|
new ProcessSingletonStartupLock(
|
||||||
|
base::Bind(NotificationCallbackWrapper, callback)));
|
||||||
process_singleton_.reset(
|
process_singleton_.reset(
|
||||||
new ProcessSingleton(
|
new ProcessSingleton(
|
||||||
user_dir,
|
user_dir,
|
||||||
|
|
|
@ -68,11 +68,9 @@ class App : public mate::EventEmitter,
|
||||||
|
|
||||||
void SetDesktopName(const std::string& desktop_name);
|
void SetDesktopName(const std::string& desktop_name);
|
||||||
void SetAppUserModelId(const std::string& app_id);
|
void SetAppUserModelId(const std::string& app_id);
|
||||||
|
|
||||||
void AllowNTLMCredentialsForAllDomains(bool should_allow);
|
void AllowNTLMCredentialsForAllDomains(bool should_allow);
|
||||||
|
bool MakeSingleInstance(
|
||||||
bool MakeSingleInstance(ProcessSingleton::NotificationCallback callback);
|
const ProcessSingleton::NotificationCallback& callback);
|
||||||
|
|
||||||
std::string GetLocale();
|
std::string GetLocale();
|
||||||
v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate);
|
v8::Local<v8::Value> DefaultSession(v8::Isolate* isolate);
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,7 @@ class Browser : public WindowListObserver {
|
||||||
observers_.RemoveObserver(obs);
|
observers_.RemoveObserver(obs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_shutting_down() const { return is_shutdown_; }
|
||||||
bool is_quiting() const { return is_quiting_; }
|
bool is_quiting() const { return is_quiting_; }
|
||||||
bool is_ready() const { return is_ready_; }
|
bool is_ready() const { return is_ready_; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue