From de668880518525fd2430f00278516681a7b746fa Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Wed, 21 Oct 2015 13:38:32 -0700 Subject: [PATCH] Remove atom_process_singleton, just use the Chrome classes directly --- atom/browser/api/atom_api_app.cc | 12 ++++-- atom/browser/api/atom_api_app.h | 5 ++- atom/browser/atom_process_singleton.cc | 29 -------------- atom/browser/atom_process_singleton.h | 52 -------------------------- filenames.gypi | 1 - 5 files changed, 12 insertions(+), 87 deletions(-) delete mode 100644 atom/browser/atom_process_singleton.cc delete mode 100644 atom/browser/atom_process_singleton.h diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 6906608f..c46f0748 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -197,7 +197,7 @@ void App::OnFinishLaunching() { default_session_.Reset(isolate(), handle.ToV8()); if (process_singleton_.get()) { - process_singleton_->Unlock(); + process_singleton_startup_lock_->Unlock(); } Emit("ready"); @@ -287,10 +287,16 @@ bool App::MakeSingleInstance(ProcessSingleton::NotificationCallback callback) { if (!process_singleton_.get()) { auto browser = Browser::Get(); - process_singleton_.reset(new AtomProcessSingleton(userDir, callback)); + process_singleton_startup_lock_.reset( + new ProcessSingletonStartupLock(callback)); + + process_singleton_.reset( + new ProcessSingleton( + userDir, + process_singleton_startup_lock_->AsNotificationCallback())); if (browser->is_ready()) { - process_singleton_->Unlock(); + process_singleton_startup_lock_->Unlock(); } process_notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index 77944d34..314eeea8 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -8,10 +8,10 @@ #include #include "atom/browser/api/event_emitter.h" -#include "atom/browser/atom_process_singleton.h" #include "atom/browser/browser_observer.h" #include "atom/common/native_mate_converters/callback.h" #include "chrome/browser/process_singleton.h" +#include "chrome/browser/process_singleton_startup_lock.h" #include "content/public/browser/gpu_data_manager_observer.h" #include "native_mate/handle.h" @@ -78,7 +78,8 @@ class App : public mate::EventEmitter, v8::Global default_session_; - scoped_ptr process_singleton_; + scoped_ptr process_singleton_; + scoped_ptr process_singleton_startup_lock_; ProcessSingleton::NotifyResult process_notify_result_; DISALLOW_COPY_AND_ASSIGN(App); diff --git a/atom/browser/atom_process_singleton.cc b/atom/browser/atom_process_singleton.cc deleted file mode 100644 index e9e4dc72..00000000 --- a/atom/browser/atom_process_singleton.cc +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "atom/browser/atom_process_singleton.h" - -AtomProcessSingleton::AtomProcessSingleton( - const base::FilePath& user_data_dir, - const ProcessSingleton::NotificationCallback& notification_callback) - : startup_lock_(notification_callback), - process_singleton_(user_data_dir, - startup_lock_.AsNotificationCallback()) { -} - -AtomProcessSingleton::~AtomProcessSingleton() { -} - -ProcessSingleton::NotifyResult - AtomProcessSingleton::NotifyOtherProcessOrCreate() { - return process_singleton_.NotifyOtherProcessOrCreate(); -} - -void AtomProcessSingleton::Cleanup() { - process_singleton_.Cleanup(); -} - -void AtomProcessSingleton::Unlock() { - startup_lock_.Unlock(); -} diff --git a/atom/browser/atom_process_singleton.h b/atom/browser/atom_process_singleton.h deleted file mode 100644 index 89feeaec..00000000 --- a/atom/browser/atom_process_singleton.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ATOM_BROWSER_ATOM_PROCESS_SINGLETON_H_ -#define ATOM_BROWSER_ATOM_PROCESS_SINGLETON_H_ - -#include "base/basictypes.h" -#include "base/files/file_path.h" -#include "chrome/browser/process_singleton.h" -#include "chrome/browser/process_singleton_startup_lock.h" - -// Composes a basic ProcessSingleton with ProcessSingletonStartupLock -class AtomProcessSingleton { - public: - AtomProcessSingleton( - const base::FilePath& user_data_dir, - const ProcessSingleton::NotificationCallback& notification_callback); - - ~AtomProcessSingleton(); - - // Notify another process, if available. Otherwise sets ourselves as the - // singleton instance. Returns PROCESS_NONE if we became the singleton - // instance. Callers are guaranteed to either have notified an existing - // process or have grabbed the singleton (unless the profile is locked by an - // unreachable process). - ProcessSingleton::NotifyResult NotifyOtherProcessOrCreate(); - - // Clear any lock state during shutdown. - void Cleanup(); - - // Executes previously queued command-line invocations and allows future - // invocations to be executed immediately. - // This only has an effect the first time it is called. - void Unlock(); - - private: - // We compose these two locks with the client-supplied notification callback. - // First |modal_dialog_lock_| will discard any notifications that arrive while - // a modal dialog is active. Otherwise, it will pass the notification to - // |startup_lock_|, which will queue notifications until |Unlock()| is called. - // Notifications passing through both locks are finally delivered to our - // client. - ProcessSingletonStartupLock startup_lock_; - - // The basic ProcessSingleton - ProcessSingleton process_singleton_; - - DISALLOW_COPY_AND_ASSIGN(AtomProcessSingleton); -}; - -#endif // ATOM_BROWSER_ATOM_PROCESS_SINGLETON_H_ diff --git a/filenames.gypi b/filenames.gypi index 3f3d1019..ec7ab329 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -130,7 +130,6 @@ 'atom/browser/atom_browser_main_parts_posix.cc', 'atom/browser/atom_javascript_dialog_manager.cc', 'atom/browser/atom_javascript_dialog_manager.h', - 'atom/browser/atom_process_singleton.cc', 'atom/browser/atom_quota_permission_context.cc', 'atom/browser/atom_quota_permission_context.h', 'atom/browser/atom_resource_dispatcher_host_delegate.cc', -- 2.43.0