OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/test/test_pending_task.h" | 7 #include "base/test/test_pending_task.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 bool TestPendingTask::ShouldRunBefore(const TestPendingTask& other) const { | 29 bool TestPendingTask::ShouldRunBefore(const TestPendingTask& other) const { |
30 if (nestability != other.nestability) | 30 if (nestability != other.nestability) |
31 return (nestability == NESTABLE); | 31 return (nestability == NESTABLE); |
32 return GetTimeToRun() < other.GetTimeToRun(); | 32 return GetTimeToRun() < other.GetTimeToRun(); |
33 } | 33 } |
34 | 34 |
35 TestPendingTask::~TestPendingTask() {} | 35 TestPendingTask::~TestPendingTask() {} |
36 | 36 |
37 void TestPendingTask::AsValueInto(base::debug::TracedValue* state) const { | 37 void TestPendingTask::AsValueInto(base::trace_event::TracedValue* state) const { |
38 state->SetInteger("run_at", GetTimeToRun().ToInternalValue()); | 38 state->SetInteger("run_at", GetTimeToRun().ToInternalValue()); |
39 state->SetString("posting_function", location.ToString()); | 39 state->SetString("posting_function", location.ToString()); |
40 state->SetInteger("post_time", post_time.ToInternalValue()); | 40 state->SetInteger("post_time", post_time.ToInternalValue()); |
41 state->SetInteger("delay", delay.ToInternalValue()); | 41 state->SetInteger("delay", delay.ToInternalValue()); |
42 switch (nestability) { | 42 switch (nestability) { |
43 case NESTABLE: | 43 case NESTABLE: |
44 state->SetString("nestability", "NESTABLE"); | 44 state->SetString("nestability", "NESTABLE"); |
45 break; | 45 break; |
46 case NON_NESTABLE: | 46 case NON_NESTABLE: |
47 state->SetString("nestability", "NON_NESTABLE"); | 47 state->SetString("nestability", "NON_NESTABLE"); |
48 break; | 48 break; |
49 } | 49 } |
50 state->SetInteger("delay", delay.ToInternalValue()); | 50 state->SetInteger("delay", delay.ToInternalValue()); |
51 } | 51 } |
52 | 52 |
53 scoped_refptr<base::debug::ConvertableToTraceFormat> TestPendingTask::AsValue() | 53 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
54 const { | 54 TestPendingTask::AsValue() const { |
55 scoped_refptr<base::debug::TracedValue> state = | 55 scoped_refptr<base::trace_event::TracedValue> state = |
56 new base::debug::TracedValue(); | 56 new base::trace_event::TracedValue(); |
57 AsValueInto(state.get()); | 57 AsValueInto(state.get()); |
58 return state; | 58 return state; |
59 } | 59 } |
60 | 60 |
61 std::string TestPendingTask::ToString() const { | 61 std::string TestPendingTask::ToString() const { |
62 std::string output("TestPendingTask("); | 62 std::string output("TestPendingTask("); |
63 AsValue()->AppendAsTraceFormat(&output); | 63 AsValue()->AppendAsTraceFormat(&output); |
64 output += ")"; | 64 output += ")"; |
65 return output; | 65 return output; |
66 } | 66 } |
67 | 67 |
68 std::ostream& operator<<(std::ostream& os, const TestPendingTask& task) { | 68 std::ostream& operator<<(std::ostream& os, const TestPendingTask& task) { |
69 PrintTo(task, &os); | 69 PrintTo(task, &os); |
70 return os; | 70 return os; |
71 } | 71 } |
72 | 72 |
73 void PrintTo(const TestPendingTask& task, std::ostream* os) { | 73 void PrintTo(const TestPendingTask& task, std::ostream* os) { |
74 *os << task.ToString(); | 74 *os << task.ToString(); |
75 } | 75 } |
76 | 76 |
77 } // namespace base | 77 } // namespace base |
OLD | NEW |