Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(935)

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 9968053: Refactor ProcessSingleton so that it may be used distinctly from a full browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Include cleanup. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/process_singleton.h » ('j') | chrome/browser/process_singleton.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 97de7c0c1f46bc0231da17fcf72d7a6ee4554932..c4c5b75c9c0ea103f12d0b8c72583133d51ee07d 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -31,6 +31,7 @@
#include "chrome/browser/about_flags.h"
#include "chrome/browser/auto_launch_trial.h"
#include "chrome/browser/autocomplete/autocomplete_field_trial.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
@@ -538,6 +539,52 @@ void AddPreReadHistogramTime(const char* name, base::TimeDelta time) {
counter->AddTime(time);
}
+bool ProcessSingletonNotificationCallback(const CommandLine& command_line,
+ const FilePath& current_directory) {
+ // Drop the request if the browser process is already in shutdown path.
+ if (!g_browser_process || g_browser_process->IsShuttingDown())
+ return false;
+
+ PrefService* prefs = g_browser_process->local_state();
jam 2012/04/04 00:44:44 nit: this isn't used
erikwright (departed) 2012/04/04 02:51:48 This is migrated here from process_singleton_linux
erikwright (departed) 2012/04/04 14:51:28 Actually, it was in both the linux and windows ver
+ DCHECK(prefs);
+
+ // Handle the --uninstall-extension startup action. This needs to done here
+ // in the process that is running with the target profile, otherwise the
+ // uninstall will fail to unload and remove all components.
+ if (command_line.HasSwitch(switches::kUninstallExtension)) {
+ // The uninstall extension switch can't be combined with the profile
+ // directory switch.
+ DCHECK(!command_line.HasSwitch(switches::kProfileDirectory));
+
+ Profile* profile = ProfileManager::GetLastUsedProfile();
+ if (!profile) {
+ // We should only be able to get here if the profile already exists and
+ // has been created.
robertshield 2012/04/04 01:07:15 I'm curious about this comment: does the profile a
erikwright (departed) 2012/04/04 02:51:48 This comment may be misleading. I believe "here" r
+ NOTREACHED();
+ return true;
+ }
+
+ ExtensionsStartupUtil ext_startup_util;
+ ext_startup_util.UninstallExtension(command_line, profile);
+ return true;
+ }
+
+ // Ignore the request if the process was passed the --product-version flag.
+ // Normally we wouldn't get here if that flag had been passed, but it can
+ // happen if it is passed to an older version of chrome. Since newer versions
+ // of chrome do this in the background, we want to avoid spawning extra
+ // windows.
+ if (command_line.HasSwitch(switches::kProductVersion)) {
+ DLOG(WARNING) << "Remote process was passed product version flag, "
+ << "but ignored it. Doing nothing.";
+ return true;
+ }
+
+ BrowserInit::ProcessCommandLineAlreadyRunning(
+ command_line, current_directory);
+ return true;
+}
+
} // namespace
namespace chrome_browser {
@@ -1465,7 +1512,8 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// new one. NotifyOtherProcess will currently give the other process up to
// 20 seconds to respond. Note that this needs to be done before we attempt
// to read the profile.
- notify_result_ = process_singleton_->NotifyOtherProcessOrCreate();
+ notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(
+ base::Bind(&ProcessSingletonNotificationCallback));
switch (notify_result_) {
case ProcessSingleton::PROCESS_NONE:
// No process already running, fall through to starting a new one.
« no previous file with comments | « no previous file | chrome/browser/process_singleton.h » ('j') | chrome/browser/process_singleton.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698