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

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 949293002: Implement a poor man's PostAfterStartupTask() function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 5c7cbfc51bfed0b30ef5ba880e05deac750f8b38..0c5e5ae14be47994bd0200ba17537e11f264f3e3 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -31,6 +31,7 @@
#include "base/strings/string_split.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/synchronization/cancellation_flag.h"
#include "base/sys_info.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
@@ -222,6 +223,25 @@
using content::BrowserThread;
+
+
+namespace {
+using StartupCompleteFlag = base::CancellationFlag;
gab 2015/03/10 15:00:32 Feels weird to use "CancellationFlag" here althoug
michaeln 2015/03/10 19:46:26 ^^^ this
gab 2015/03/10 19:55:27 One simple way to do this would be to rename the c
+base::LazyInstance<StartupCompleteFlag>::Leaky g_startup_complete_flag;
+}
+
+namespace chrome {
+
+bool IsBrowserStartupComplete() {
+ return g_startup_complete_flag.Get().IsSet();
+}
+
+void SetBrowserStartupIsComplete() {
+ g_startup_complete_flag.Get().Set();
+}
+
+}
+
namespace {
// This function provides some ways to test crash and assertion handling
@@ -588,6 +608,8 @@ ChromeBrowserMainParts::ChromeBrowserMainParts(
// cookies need to go through one of Chrome's URLRequestContexts which have
// a ChromeNetworkDelegate attached that selectively allows cookies again.
net::URLRequest::SetDefaultCookiePolicyToBlock();
+
+ g_startup_complete_flag.Get();
}
ChromeBrowserMainParts::~ChromeBrowserMainParts() {
@@ -1109,6 +1131,13 @@ void ChromeBrowserMainParts::PostBrowserStart() {
base::Bind(&WebRtcLogUtil::DeleteOldWebRtcLogFilesForAllProfiles),
michaeln 2015/03/10 19:46:26 This might be a good candidate for PostAfterStartu
base::TimeDelta::FromMinutes(1));
#endif // defined(ENABLE_WEBRTC)
+
+ // Failsafe for signaling startup completion.
jam 2015/03/10 23:04:34 why do we need a failsafe? under what circumstanc
michaeln 2015/03/10 23:54:54 The first page is closed prior to getting to the l
+ BrowserThread::PostDelayedTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&chrome::SetBrowserStartupIsComplete),
+ base::TimeDelta::FromMinutes(3));
gab 2015/03/10 15:00:32 Is PostBrowserStart() called in background mode la
michaeln 2015/03/10 19:46:26 I'm really not sure about which of these methods g
gab 2015/03/10 19:55:27 Makes sense to post it in a safe and early spot IM
}
int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {

Powered by Google App Engine
This is Rietveld 408576698