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

Unified Diff: chrome/browser/sessions/base_session_service.cc

Issue 9361056: Allow SessionBackend::Init() to occur just-in-time in production builds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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/sessions/base_session_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/base_session_service.cc
diff --git a/chrome/browser/sessions/base_session_service.cc b/chrome/browser/sessions/base_session_service.cc
index 6991e24c4294cd7693bd9d50b3eaa5941650cd1a..a529d31c4026a4d8c830d3e699cbcd2ae52f8064 100644
--- a/chrome/browser/sessions/base_session_service.cc
+++ b/chrome/browser/sessions/base_session_service.cc
@@ -91,8 +91,15 @@ BaseSessionService::BaseSessionService(SessionType type,
profile_ ? profile_->GetPath() : path_);
DCHECK(backend_.get());
- RunTaskOnBackendThread(FROM_HERE,
- base::Bind(&SessionBackend::Init, backend_));
+ if (!RunningInProduction()) {
+ // We seem to be running as part of a test, in which case we need
+ // to explicitly initialize the backend. In production, the
+ // backend will automatically initialize itself just in time.
+ //
+ // Note that it's important not to initialize too early in
+ // production; this can cause e.g. http://crbug.com/110785.
+ backend_->Init();
+ }
}
BaseSessionService::~BaseSessionService() {
@@ -322,10 +329,14 @@ BaseSessionService::Handle BaseSessionService::ScheduleGetLastSessionCommands(
return request->handle();
}
+bool BaseSessionService::RunningInProduction() const {
+ return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE);
+}
+
bool BaseSessionService::RunTaskOnBackendThread(
const tracked_objects::Location& from_here,
const base::Closure& task) {
- if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
+ if (RunningInProduction()) {
return BrowserThread::PostTask(BrowserThread::FILE, from_here, task);
} else {
// Fall back to executing on the main thread if the file thread
« no previous file with comments | « chrome/browser/sessions/base_session_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698