Add IsEmpty helper and remove GetInstance public usage
This commit is contained in:
parent
da5d7d72b0
commit
e7b679ead6
4 changed files with 14 additions and 13 deletions
|
@ -87,14 +87,13 @@ void AutoUpdater::SetFeedURL(const std::string& url, mate::Arguments* args) {
|
||||||
|
|
||||||
void AutoUpdater::QuitAndInstall() {
|
void AutoUpdater::QuitAndInstall() {
|
||||||
// If we don't have any window then quitAndInstall immediately.
|
// If we don't have any window then quitAndInstall immediately.
|
||||||
WindowList* window_list = WindowList::GetInstance();
|
if (WindowList::IsEmpty()) {
|
||||||
if (window_list->empty()) {
|
|
||||||
auto_updater::AutoUpdater::QuitAndInstall();
|
auto_updater::AutoUpdater::QuitAndInstall();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise do the restart after all windows have been closed.
|
// Otherwise do the restart after all windows have been closed.
|
||||||
window_list->AddObserver(this);
|
WindowList::AddObserver(this);
|
||||||
WindowList::CloseAllWindows();
|
WindowList::CloseAllWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,10 @@ void Browser::Quit() {
|
||||||
if (!is_quiting_)
|
if (!is_quiting_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
atom::WindowList* window_list = atom::WindowList::GetInstance();
|
if (atom::WindowList::IsEmpty())
|
||||||
if (window_list->empty())
|
|
||||||
NotifyAndShutdown();
|
NotifyAndShutdown();
|
||||||
|
else
|
||||||
window_list->CloseAllWindows();
|
atom::WindowList::CloseAllWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::Exit(mate::Arguments* args) {
|
void Browser::Exit(mate::Arguments* args) {
|
||||||
|
@ -65,8 +64,7 @@ void Browser::Exit(mate::Arguments* args) {
|
||||||
is_exiting_ = true;
|
is_exiting_ = true;
|
||||||
|
|
||||||
// Must destroy windows before quitting, otherwise bad things can happen.
|
// Must destroy windows before quitting, otherwise bad things can happen.
|
||||||
atom::WindowList* window_list = atom::WindowList::GetInstance();
|
if (atom::WindowList::IsEmpty()) {
|
||||||
if (window_list->empty()) {
|
|
||||||
Shutdown();
|
Shutdown();
|
||||||
} else {
|
} else {
|
||||||
// Unlike Quit(), we do not ask to close window, but destroy the window
|
// Unlike Quit(), we do not ask to close window, but destroy the window
|
||||||
|
|
|
@ -31,6 +31,11 @@ WindowList::WindowVector WindowList::GetWindows() {
|
||||||
return GetInstance()->windows_;
|
return GetInstance()->windows_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
bool WindowList::IsEmpty() {
|
||||||
|
return GetInstance()->windows_.empty();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void WindowList::AddWindow(NativeWindow* window) {
|
void WindowList::AddWindow(NativeWindow* window) {
|
||||||
DCHECK(window);
|
DCHECK(window);
|
||||||
|
|
|
@ -20,11 +20,8 @@ class WindowList {
|
||||||
public:
|
public:
|
||||||
typedef std::vector<NativeWindow*> WindowVector;
|
typedef std::vector<NativeWindow*> WindowVector;
|
||||||
|
|
||||||
bool empty() const { return windows_.empty(); }
|
|
||||||
|
|
||||||
static WindowList* GetInstance();
|
|
||||||
|
|
||||||
static WindowVector GetWindows();
|
static WindowVector GetWindows();
|
||||||
|
static bool IsEmpty();
|
||||||
|
|
||||||
// Adds or removes |window| from the list it is associated with.
|
// Adds or removes |window| from the list it is associated with.
|
||||||
static void AddWindow(NativeWindow* window);
|
static void AddWindow(NativeWindow* window);
|
||||||
|
@ -44,6 +41,8 @@ class WindowList {
|
||||||
static void DestroyAllWindows();
|
static void DestroyAllWindows();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static WindowList* GetInstance();
|
||||||
|
|
||||||
WindowList();
|
WindowList();
|
||||||
~WindowList();
|
~WindowList();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue