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

Unified Diff: chrome/browser/process_singleton.h

Issue 11415237: Move many ProcessSingleton methods to "protected" visibility as an upcoming refactoring of ProcessS… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux compile Created 8 years 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_linux_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/process_singleton.h
diff --git a/chrome/browser/process_singleton.h b/chrome/browser/process_singleton.h
index 2b03b2d0bcfaa496f5a5ec3284ff36ef34009d84..961a51f7ecf66df0b8b7bb1c0fb4c0ad928fbb7d 100644
--- a/chrome/browser/process_singleton.h
+++ b/chrome/browser/process_singleton.h
@@ -67,16 +67,6 @@ class ProcessSingleton : public base::NonThreadSafe {
explicit ProcessSingleton(const FilePath& user_data_dir);
~ProcessSingleton();
- // Notify another process, if available.
- // Returns true if another process was found and notified, false if we
- // should continue with this process.
- // Windows code roughly based on Mozilla.
- //
- // TODO(brettw): this will not handle all cases. If two process start up too
- // close to each other, the Create() might not yet have happened for the
- // first one, so this function won't find it.
- NotifyResult NotifyOtherProcess();
-
// Notify another process, if available. Otherwise sets ourselves as the
// singleton instance and stores the provided callback for notification from
// future processes. Returns PROCESS_NONE if we became the singleton
@@ -84,20 +74,14 @@ class ProcessSingleton : public base::NonThreadSafe {
NotifyResult NotifyOtherProcessOrCreate(
const NotificationCallback& notification_callback);
-#if defined(OS_LINUX) || defined(OS_OPENBSD)
- // Exposed for testing. We use a timeout on Linux, and in tests we want
- // this timeout to be short.
- NotifyResult NotifyOtherProcessWithTimeout(const CommandLine& command_line,
- int timeout_seconds,
- bool kill_unresponsive);
- NotifyResult NotifyOtherProcessWithTimeoutOrCreate(
- const CommandLine& command_line,
- const NotificationCallback& notification_callback,
- int timeout_seconds);
- void OverrideCurrentPidForTesting(base::ProcessId pid);
- void OverrideKillCallbackForTesting(const base::Callback<void(int)>& callback);
- static void DisablePromptForTesting();
-#endif // defined(OS_LINUX) || defined(OS_OPENBSD)
+ // Sets ourself up as the singleton instance. Returns true on success. If
+ // false is returned, we are not the singleton instance and the caller must
+ // exit. Otherwise, stores the provided callback for notification from
+ // future processes.
+ // NOTE: Most callers should generally prefer NotifyOtherProcessOrCreate() to
+ // this method, only callers for whom failure is prefered to notifying another
+ // process should call this directly.
+ bool Create(const NotificationCallback& notification_callback);
#if defined(OS_WIN)
// Used in specific cases to let us know that there is an existing instance
@@ -110,13 +94,6 @@ class ProcessSingleton : public base::NonThreadSafe {
}
#endif // defined(OS_WIN)
- // Sets ourself up as the singleton instance. Returns true on success. If
- // false is returned, we are not the singleton instance and the caller must
- // exit. Otherwise, stores the provided callback for notification from
- // future processes.
- bool Create(
- const NotificationCallback& notification_callback);
-
// Clear any lock state during shutdown.
void Cleanup();
@@ -148,6 +125,36 @@ class ProcessSingleton : public base::NonThreadSafe {
LRESULT WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
#endif
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
+ static void DisablePromptForTesting();
+#endif // defined(OS_LINUX) || defined(OS_OPENBSD)
+
+ protected:
+ // Notify another process, if available.
+ // Returns true if another process was found and notified, false if we
+ // should continue with this process.
+ // Windows code roughly based on Mozilla.
+ //
+ // TODO(brettw): this will not handle all cases. If two processes start up too
+ // close to each other, the Create() might not yet have happened for the
+ // first one, so this function won't find it.
+ NotifyResult NotifyOtherProcess();
+
+#if defined(OS_LINUX) || defined(OS_OPENBSD)
+ // Exposed for testing. We use a timeout on Linux, and in tests we want
+ // this timeout to be short.
+ NotifyResult NotifyOtherProcessWithTimeout(const CommandLine& command_line,
+ int timeout_seconds,
+ bool kill_unresponsive);
+ NotifyResult NotifyOtherProcessWithTimeoutOrCreate(
+ const CommandLine& command_line,
+ const NotificationCallback& notification_callback,
+ int timeout_seconds);
+ void OverrideCurrentPidForTesting(base::ProcessId pid);
+ void OverrideKillCallbackForTesting(
+ const base::Callback<void(int)>& callback);
+#endif // defined(OS_LINUX) || defined(OS_OPENBSD)
+
private:
typedef std::pair<CommandLine::StringVector, FilePath> DelayedStartupMessage;
« no previous file with comments | « no previous file | chrome/browser/process_singleton_linux_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698