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

Unified Diff: chrome/browser/first_run/first_run.cc

Issue 20743002: Do not CreateSentinel until after the process singleton has been grabbed by the current process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge latest version of https://codereview.chromium.org/20483002/ Created 7 years, 5 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 | « chrome/browser/first_run/first_run.h ('k') | chrome/browser/first_run/first_run_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/first_run/first_run.cc
diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc
index 585ba2ca6ae7b16f4b1868044294da7d97663882..29c443b63fb46941dffdd0a09c6253f6323c0104 100644
--- a/chrome/browser/first_run/first_run.cc
+++ b/chrome/browser/first_run/first_run.cc
@@ -442,6 +442,13 @@ void SetDefaultBrowser(installer::MasterPreferences* install_prefs){
}
}
+bool CreateSentinel() {
+ base::FilePath first_run_sentinel;
+ if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel))
+ return false;
+ return file_util::WriteFile(first_run_sentinel, "", 0) != -1;
+}
+
// -- Platform-specific functions --
#if !defined(OS_LINUX) && !defined(OS_BSD)
@@ -469,42 +476,27 @@ bool IsChromeFirstRun() {
if (internal::first_run_ != internal::FIRST_RUN_UNKNOWN)
return internal::first_run_ == internal::FIRST_RUN_TRUE;
- enum FirstRunState {
- CANCEL_FIRST_RUN,
- NOT_FIRST_RUN,
- IS_FIRST_RUN,
- };
-
- FirstRunState first_run_state = NOT_FIRST_RUN;
+ internal::first_run_ = internal::FIRST_RUN_FALSE;
base::FilePath first_run_sentinel;
const CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kForceFirstRun)) {
- first_run_state = IS_FIRST_RUN;
+ internal::first_run_ = internal::FIRST_RUN_TRUE;
} else if (command_line->HasSwitch(switches::kNoFirstRun)) {
- first_run_state = CANCEL_FIRST_RUN;
+ internal::first_run_ = internal::FIRST_RUN_CANCEL;
} else if (internal::GetFirstRunSentinelFilePath(&first_run_sentinel) &&
!base::PathExists(first_run_sentinel)) {
- first_run_state = IS_FIRST_RUN;
- }
-
- if (first_run_state == IS_FIRST_RUN || first_run_state == CANCEL_FIRST_RUN)
- CreateSentinel();
-
- if (first_run_state == IS_FIRST_RUN) {
internal::first_run_ = internal::FIRST_RUN_TRUE;
- return true;
- } else {
- internal::first_run_ = internal::FIRST_RUN_FALSE;
- return false;
}
+
+ return internal::first_run_ == internal::FIRST_RUN_TRUE;
}
-bool CreateSentinel() {
- base::FilePath first_run_sentinel;
- if (!internal::GetFirstRunSentinelFilePath(&first_run_sentinel))
- return false;
- return file_util::WriteFile(first_run_sentinel, "", 0) != -1;
+void CreateSentinelIfNeeded() {
+ if (IsChromeFirstRun() ||
+ internal::first_run_ == internal::FIRST_RUN_CANCEL) {
+ internal::CreateSentinel();
+ }
}
std::string GetPingDelayPrefName() {
« no previous file with comments | « chrome/browser/first_run/first_run.h ('k') | chrome/browser/first_run/first_run_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698