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

Side by Side Diff: base/test/test_mock_time_task_runner.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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 | « base/test/test_mock_time_task_runner.h ('k') | base/test/test_pending_task.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/test/test_mock_time_task_runner.h" 5 #include "base/test/test_mock_time_task_runner.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h"
9 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
10 #include "base/time/clock.h" 11 #include "base/time/clock.h"
11 #include "base/time/tick_clock.h" 12 #include "base/time/tick_clock.h"
12 13
13 namespace base { 14 namespace base {
14 15
15 namespace { 16 namespace {
16 17
17 // MockTickClock -------------------------------------------------------------- 18 // MockTickClock --------------------------------------------------------------
18 19
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 Time TestMockTimeTaskRunner::Now() const { 156 Time TestMockTimeTaskRunner::Now() const {
156 DCHECK(thread_checker_.CalledOnValidThread()); 157 DCHECK(thread_checker_.CalledOnValidThread());
157 return now_; 158 return now_;
158 } 159 }
159 160
160 TimeTicks TestMockTimeTaskRunner::NowTicks() const { 161 TimeTicks TestMockTimeTaskRunner::NowTicks() const {
161 DCHECK(thread_checker_.CalledOnValidThread()); 162 DCHECK(thread_checker_.CalledOnValidThread());
162 return now_ticks_; 163 return now_ticks_;
163 } 164 }
164 165
165 scoped_ptr<Clock> TestMockTimeTaskRunner::GetMockClock() const { 166 std::unique_ptr<Clock> TestMockTimeTaskRunner::GetMockClock() const {
166 DCHECK(thread_checker_.CalledOnValidThread()); 167 DCHECK(thread_checker_.CalledOnValidThread());
167 return make_scoped_ptr(new MockClock(this)); 168 return WrapUnique(new MockClock(this));
168 } 169 }
169 170
170 scoped_ptr<TickClock> TestMockTimeTaskRunner::GetMockTickClock() const { 171 std::unique_ptr<TickClock> TestMockTimeTaskRunner::GetMockTickClock() const {
171 DCHECK(thread_checker_.CalledOnValidThread()); 172 DCHECK(thread_checker_.CalledOnValidThread());
172 return make_scoped_ptr(new MockTickClock(this)); 173 return WrapUnique(new MockTickClock(this));
173 } 174 }
174 175
175 bool TestMockTimeTaskRunner::HasPendingTask() const { 176 bool TestMockTimeTaskRunner::HasPendingTask() const {
176 DCHECK(thread_checker_.CalledOnValidThread()); 177 DCHECK(thread_checker_.CalledOnValidThread());
177 return !tasks_.empty(); 178 return !tasks_.empty();
178 } 179 }
179 180
180 size_t TestMockTimeTaskRunner::GetPendingTaskCount() const { 181 size_t TestMockTimeTaskRunner::GetPendingTaskCount() const {
181 DCHECK(thread_checker_.CalledOnValidThread()); 182 DCHECK(thread_checker_.CalledOnValidThread());
182 return tasks_.size(); 183 return tasks_.size();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if (!tasks_.empty() && 260 if (!tasks_.empty() &&
260 (tasks_.top().GetTimeToRun() - reference) <= max_delta) { 261 (tasks_.top().GetTimeToRun() - reference) <= max_delta) {
261 *next_task = tasks_.top(); 262 *next_task = tasks_.top();
262 tasks_.pop(); 263 tasks_.pop();
263 return true; 264 return true;
264 } 265 }
265 return false; 266 return false;
266 } 267 }
267 268
268 } // namespace base 269 } // namespace base
OLDNEW
« no previous file with comments | « base/test/test_mock_time_task_runner.h ('k') | base/test/test_pending_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698