| 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 "chrome/browser/memory/tab_manager.h" | 5 #include "chrome/browser/memory/tab_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 111 } |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 // A TaskRunner implementation that delegates to a MockTaskRunner for asserting | 114 // A TaskRunner implementation that delegates to a MockTaskRunner for asserting |
| 115 // on task insertion order, and which stores tasks for actual later execution. | 115 // on task insertion order, and which stores tasks for actual later execution. |
| 116 class TaskRunnerProxy : public base::TaskRunner { | 116 class TaskRunnerProxy : public base::TaskRunner { |
| 117 public: | 117 public: |
| 118 TaskRunnerProxy(MockTaskRunner* mock, | 118 TaskRunnerProxy(MockTaskRunner* mock, |
| 119 base::SimpleTestTickClock* clock) | 119 base::SimpleTestTickClock* clock) |
| 120 : mock_(mock), clock_(clock) {} | 120 : mock_(mock), clock_(clock) {} |
| 121 bool RunsTasksOnCurrentThread() const override { return true; } | 121 bool RunsTasksInCurrentSequence() const override { return true; } |
| 122 bool PostDelayedTask(const tracked_objects::Location& location, | 122 bool PostDelayedTask(const tracked_objects::Location& location, |
| 123 base::OnceClosure closure, | 123 base::OnceClosure closure, |
| 124 base::TimeDelta delta) override { | 124 base::TimeDelta delta) override { |
| 125 mock_->PostDelayedTask(location, delta); | 125 mock_->PostDelayedTask(location, delta); |
| 126 base::TimeTicks when = clock_->NowTicks() + delta; | 126 base::TimeTicks when = clock_->NowTicks() + delta; |
| 127 tasks_.push_back(Task(when, std::move(closure))); | 127 tasks_.push_back(Task(when, std::move(closure))); |
| 128 // Use 'greater' comparator to make this a min heap. | 128 // Use 'greater' comparator to make this a min heap. |
| 129 std::push_heap(tasks_.begin(), tasks_.end(), TaskComparator()); | 129 std::push_heap(tasks_.begin(), tasks_.end(), TaskComparator()); |
| 130 return true; | 130 return true; |
| 131 } | 131 } |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 // Since tab2 is kept inactive and background for more than time-to-purge, | 744 // Since tab2 is kept inactive and background for more than time-to-purge, |
| 745 // tab2 should be purged. | 745 // tab2 should be purged. |
| 746 EXPECT_TRUE(tab_manager.GetWebContentsData(tab2)->is_purged()); | 746 EXPECT_TRUE(tab_manager.GetWebContentsData(tab2)->is_purged()); |
| 747 | 747 |
| 748 // Activate tab2. Tab2's PurgeAndSuspend state should be NOT_PURGED. | 748 // Activate tab2. Tab2's PurgeAndSuspend state should be NOT_PURGED. |
| 749 tabstrip.ActivateTabAt(1, true /* user_gesture */); | 749 tabstrip.ActivateTabAt(1, true /* user_gesture */); |
| 750 EXPECT_FALSE(tab_manager.GetWebContentsData(tab2)->is_purged()); | 750 EXPECT_FALSE(tab_manager.GetWebContentsData(tab2)->is_purged()); |
| 751 } | 751 } |
| 752 | 752 |
| 753 } // namespace memory | 753 } // namespace memory |
| OLD | NEW |