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

Side by Side Diff: chrome/browser/sessions/base_session_service.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sessions/base_session_service.h" 5 #include "chrome/browser/sessions/base_session_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 void BaseSessionService::ScheduleCommand(SessionCommand* command) { 109 void BaseSessionService::ScheduleCommand(SessionCommand* command) {
110 DCHECK(command); 110 DCHECK(command);
111 commands_since_reset_++; 111 commands_since_reset_++;
112 pending_commands_.push_back(command); 112 pending_commands_.push_back(command);
113 StartSaveTimer(); 113 StartSaveTimer();
114 } 114 }
115 115
116 void BaseSessionService::StartSaveTimer() { 116 void BaseSessionService::StartSaveTimer() {
117 // Don't start a timer when testing (profile == NULL or 117 // Don't start a timer when testing (profile == NULL or
118 // MessageLoop::current() is NULL). 118 // MessageLoop::current() is NULL).
119 if (MessageLoop::current() && profile() && !weak_factory_.HasWeakPtrs()) { 119 if (base::MessageLoop::current() && profile() &&
120 MessageLoop::current()->PostDelayedTask( 120 !weak_factory_.HasWeakPtrs()) {
121 base::MessageLoop::current()->PostDelayedTask(
121 FROM_HERE, 122 FROM_HERE,
122 base::Bind(&BaseSessionService::Save, weak_factory_.GetWeakPtr()), 123 base::Bind(&BaseSessionService::Save, weak_factory_.GetWeakPtr()),
123 base::TimeDelta::FromMilliseconds(kSaveDelayMS)); 124 base::TimeDelta::FromMilliseconds(kSaveDelayMS));
124 } 125 }
125 } 126 }
126 127
127 void BaseSessionService::Save() { 128 void BaseSessionService::Save() {
128 DCHECK(backend()); 129 DCHECK(backend());
129 130
130 if (pending_commands_.empty()) 131 if (pending_commands_.empty())
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // has gone away (around shutdown time) or if we're running as 307 // has gone away (around shutdown time) or if we're running as
307 // part of a unit test that does not set profile_. 308 // part of a unit test that does not set profile_.
308 task.Run(); 309 task.Run();
309 return true; 310 return true;
310 } 311 }
311 } 312 }
312 313
313 bool BaseSessionService::RunningInProduction() const { 314 bool BaseSessionService::RunningInProduction() const {
314 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); 315 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE);
315 } 316 }
OLDNEW
« no previous file with comments | « chrome/browser/service/service_process_control_browsertest.cc ('k') | chrome/browser/sessions/session_restore.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698