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

Side by Side Diff: components/sessions/core/base_session_service.cc

Issue 2404353002: Remove MessageLoop::current() from base_session_service.cc. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/sessions/core/base_session_service.h" 5 #include "components/sessions/core/base_session_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 *it = new_command.release(); 110 *it = new_command.release();
111 delete old_command; 111 delete old_command;
112 } 112 }
113 113
114 void BaseSessionService::ClearPendingCommands() { 114 void BaseSessionService::ClearPendingCommands() {
115 pending_commands_.clear(); 115 pending_commands_.clear();
116 } 116 }
117 117
118 void BaseSessionService::StartSaveTimer() { 118 void BaseSessionService::StartSaveTimer() {
119 // Don't start a timer when testing. 119 // Don't start a timer when testing.
120 if (delegate_->ShouldUseDelayedSave() && base::MessageLoop::current() && 120 if (delegate_->ShouldUseDelayedSave() &&
121 !weak_factory_.HasWeakPtrs()) { 121 base::ThreadTaskRunnerHandle::IsSet() && !weak_factory_.HasWeakPtrs()) {
122 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 122 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
123 FROM_HERE, 123 FROM_HERE,
124 base::Bind(&BaseSessionService::Save, weak_factory_.GetWeakPtr()), 124 base::Bind(&BaseSessionService::Save, weak_factory_.GetWeakPtr()),
125 base::TimeDelta::FromMilliseconds(kSaveDelayMS)); 125 base::TimeDelta::FromMilliseconds(kSaveDelayMS));
126 } 126 }
127 } 127 }
128 128
129 void BaseSessionService::Save() { 129 void BaseSessionService::Save() {
130 // Inform the delegate that we will save the commands now, giving it the 130 // Inform the delegate that we will save the commands now, giving it the
131 // opportunity to append more commands. 131 // opportunity to append more commands.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 pool->PostSequencedWorkerTask(sequence_token_, from_here, task); 181 pool->PostSequencedWorkerTask(sequence_token_, from_here, task);
182 } else { 182 } else {
183 // Fall back to executing on the main thread if the sequence 183 // Fall back to executing on the main thread if the sequence
184 // worker pool has been requested to shutdown (around shutdown 184 // worker pool has been requested to shutdown (around shutdown
185 // time). 185 // time).
186 task.Run(); 186 task.Run();
187 } 187 }
188 } 188 }
189 189
190 } // namespace sessions 190 } // namespace sessions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698