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

Side by Side Diff: cc/test/ordered_simple_task_runner.cc

Issue 1717283003: tracing: Make ConvertableToTraceFormat move-only scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/test/ordered_simple_task_runner.h" 5 #include "cc/test/ordered_simple_task_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const TestOrderablePendingTask& other) const { 57 const TestOrderablePendingTask& other) const {
58 if (*this == other) 58 if (*this == other)
59 return false; 59 return false;
60 60
61 if (GetTimeToRun() == other.GetTimeToRun()) { 61 if (GetTimeToRun() == other.GetTimeToRun()) {
62 return task_id_ < other.task_id_; 62 return task_id_ < other.task_id_;
63 } 63 }
64 return ShouldRunBefore(other); 64 return ShouldRunBefore(other);
65 } 65 }
66 66
67 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 67 scoped_ptr<base::trace_event::ConvertableToTraceFormat>
68 TestOrderablePendingTask::AsValue() const { 68 TestOrderablePendingTask::AsValue() const {
69 scoped_refptr<base::trace_event::TracedValue> state = 69 auto state = make_scoped_ptr(new base::trace_event::TracedValue);
70 new base::trace_event::TracedValue();
71 AsValueInto(state.get()); 70 AsValueInto(state.get());
72 return state; 71 return std::move(state);
73 } 72 }
74 73
75 void TestOrderablePendingTask::AsValueInto( 74 void TestOrderablePendingTask::AsValueInto(
76 base::trace_event::TracedValue* state) const { 75 base::trace_event::TracedValue* state) const {
77 state->SetInteger("id", base::saturated_cast<int>(task_id_)); 76 state->SetInteger("id", base::saturated_cast<int>(task_id_));
78 state->SetInteger("run_at", GetTimeToRun().ToInternalValue()); 77 state->SetInteger("run_at", GetTimeToRun().ToInternalValue());
79 state->SetString("posted_from", location.ToString()); 78 state->SetString("posted_from", location.ToString());
80 } 79 }
81 80
82 OrderedSimpleTaskRunner::OrderedSimpleTaskRunner( 81 OrderedSimpleTaskRunner::OrderedSimpleTaskRunner(
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 253 }
255 254
256 return result; 255 return result;
257 } 256 }
258 257
259 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) { 258 bool OrderedSimpleTaskRunner::RunForPeriod(base::TimeDelta period) {
260 return RunUntilTime(now_src_->NowTicks() + period); 259 return RunUntilTime(now_src_->NowTicks() + period);
261 } 260 }
262 261
263 // base::trace_event tracing functionality 262 // base::trace_event tracing functionality
264 scoped_refptr<base::trace_event::ConvertableToTraceFormat> 263 scoped_ptr<base::trace_event::ConvertableToTraceFormat>
265 OrderedSimpleTaskRunner::AsValue() const { 264 OrderedSimpleTaskRunner::AsValue() const {
266 scoped_refptr<base::trace_event::TracedValue> state = 265 auto state = make_scoped_ptr(new base::trace_event::TracedValue);
267 new base::trace_event::TracedValue();
268 AsValueInto(state.get()); 266 AsValueInto(state.get());
269 return state; 267 return std::move(state);
270 } 268 }
271 269
272 void OrderedSimpleTaskRunner::AsValueInto( 270 void OrderedSimpleTaskRunner::AsValueInto(
273 base::trace_event::TracedValue* state) const { 271 base::trace_event::TracedValue* state) const {
274 state->SetInteger("pending_tasks", 272 state->SetInteger("pending_tasks",
275 base::saturated_cast<int>(pending_tasks_.size())); 273 base::saturated_cast<int>(pending_tasks_.size()));
276 274
277 state->BeginArray("tasks"); 275 state->BeginArray("tasks");
278 for (std::set<TestOrderablePendingTask>::const_iterator it = 276 for (std::set<TestOrderablePendingTask>::const_iterator it =
279 pending_tasks_.begin(); 277 pending_tasks_.begin();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 334
337 bool OrderedSimpleTaskRunner::AdvanceNowCallback() { 335 bool OrderedSimpleTaskRunner::AdvanceNowCallback() {
338 base::TimeTicks next_task_time = NextTaskTime(); 336 base::TimeTicks next_task_time = NextTaskTime();
339 if (now_src_->NowTicks() < next_task_time) { 337 if (now_src_->NowTicks() < next_task_time) {
340 now_src_->Advance(next_task_time - now_src_->NowTicks()); 338 now_src_->Advance(next_task_time - now_src_->NowTicks());
341 } 339 }
342 return true; 340 return true;
343 } 341 }
344 342
345 } // namespace cc 343 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698