Add assertions for ChromeProcessSingleton
This CL is adding checks to ensure the process singleton
is owned while running upgrade tasks.
Bug: 1340599
Change-Id: I38888d3b65169b7199fef90996a779994c404d8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4859060
Reviewed-by: Scott Violet <[email protected]>
Commit-Queue: Etienne Bergeron <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1197272}
diff --git a/chrome/browser/chrome_process_singleton.h b/chrome/browser/chrome_process_singleton.h
index f5cb830..69ebffe 100644
--- a/chrome/browser/chrome_process_singleton.h
+++ b/chrome/browser/chrome_process_singleton.h
@@ -59,6 +59,8 @@
void Unlock(
const ProcessSingleton::NotificationCallback& notification_callback);
+ bool IsSingletonInstanceForTesting() const { return is_singleton_instance_; }
+
// Create the chrome process singleton instance for the current process.
static void CreateInstance(const base::FilePath& user_data_dir);
// Delete the chrome process singleton instance.
@@ -66,6 +68,11 @@
// Retrieve the chrome process singleton instance for the current process.
static ChromeProcessSingleton* GetInstance();
+ // Returns true if this process is the singleton instance (i.e., a
+ // ProcessSingleton has been created and NotifyOtherProcessOrCreate() has
+ // returned PROCESS_NONE).
+ static bool IsSingletonInstance();
+
// Setup the experiment for the early process singleton. Remove this code
// when the experiment is over (http://www.crbug.com/1340599).
static void SetupEarlySingletonFeature(const base::CommandLine& command_line);
@@ -77,6 +84,9 @@
bool NotificationCallback(const base::CommandLine& command_line,
const base::FilePath& current_directory);
+ // Whether or not this instance is the running single instance.
+ bool is_singleton_instance_ = false;
+
// 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