OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // Must be such that |kTasksSize| - |kTasksToBeRemovedSize| is less than | 60 // Must be such that |kTasksSize| - |kTasksToBeRemovedSize| is less than |
61 // |ResourceReporter::kTopConsumerCount|. | 61 // |ResourceReporter::kTopConsumerCount|. |
62 const size_t kTasksToBeRemovedSize = arraysize(kIdsOfTasksToRemove); | 62 const size_t kTasksToBeRemovedSize = arraysize(kIdsOfTasksToRemove); |
63 | 63 |
64 // A test implementation of the task manager that can be used to collect CPU and | 64 // A test implementation of the task manager that can be used to collect CPU and |
65 // memory usage so that they can be tested with the resource reporter. | 65 // memory usage so that they can be tested with the resource reporter. |
66 class DummyTaskManager : public task_management::TestTaskManager { | 66 class DummyTaskManager : public task_management::TestTaskManager { |
67 public: | 67 public: |
68 DummyTaskManager() { | 68 DummyTaskManager() { |
69 set_timer_for_testing( | 69 set_timer_for_testing( |
70 scoped_ptr<base::Timer>(new base::MockTimer(false, false))); | 70 std::unique_ptr<base::Timer>(new base::MockTimer(false, false))); |
71 } | 71 } |
72 ~DummyTaskManager() override {} | 72 ~DummyTaskManager() override {} |
73 | 73 |
74 // task_management::TestTaskManager: | 74 // task_management::TestTaskManager: |
75 double GetCpuUsage(TaskId task_id) const override { | 75 double GetCpuUsage(TaskId task_id) const override { |
76 return tasks_.at(task_id)->cpu_percent; | 76 return tasks_.at(task_id)->cpu_percent; |
77 } | 77 } |
78 int64_t GetPhysicalMemoryUsage(TaskId task_id) const override { | 78 int64_t GetPhysicalMemoryUsage(TaskId task_id) const override { |
79 return tasks_.at(task_id)->memory_bytes; | 79 return tasks_.at(task_id)->memory_bytes; |
80 } | 80 } |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 ResourceReporter::kTopConsumersCount); | 319 ResourceReporter::kTopConsumersCount); |
320 EXPECT_LE(resource_reporter()->task_records_by_memory_.size(), | 320 EXPECT_LE(resource_reporter()->task_records_by_memory_.size(), |
321 ResourceReporter::kTopConsumersCount); | 321 ResourceReporter::kTopConsumersCount); |
322 EXPECT_TRUE(IsCpuRecordsSetSorted()); | 322 EXPECT_TRUE(IsCpuRecordsSetSorted()); |
323 EXPECT_TRUE(IsMemoryRecordsSetSorted()); | 323 EXPECT_TRUE(IsMemoryRecordsSetSorted()); |
324 | 324 |
325 Stop(); | 325 Stop(); |
326 } | 326 } |
327 | 327 |
328 } // namespace chromeos | 328 } // namespace chromeos |
OLD | NEW |