| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 // A min-heap of outstanding tasks. | 168 // A min-heap of outstanding tasks. |
| 169 using Task = std::pair<base::TimeTicks, base::Closure>; | 169 using Task = std::pair<base::TimeTicks, base::Closure>; |
| 170 std::vector<Task> tasks_; | 170 std::vector<Task> tasks_; |
| 171 | 171 |
| 172 DISALLOW_COPY_AND_ASSIGN(TaskRunnerProxy); | 172 DISALLOW_COPY_AND_ASSIGN(TaskRunnerProxy); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 enum TestIndicies { | 175 enum TestIndicies { |
| 176 kSelected, | 176 kSelected, |
| 177 kAutoDiscardable, |
| 177 kPinned, | 178 kPinned, |
| 178 kApp, | 179 kApp, |
| 179 kPlayingAudio, | 180 kPlayingAudio, |
| 180 kFormEntry, | 181 kFormEntry, |
| 181 kRecent, | 182 kRecent, |
| 182 kOld, | 183 kOld, |
| 183 kReallyOld, | 184 kReallyOld, |
| 184 kOldButPinned, | 185 kOldButPinned, |
| 185 kInternalPage, | 186 kInternalPage, |
| 186 }; | 187 }; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 271 } |
| 271 | 272 |
| 272 { | 273 { |
| 273 TabStats stats; | 274 TabStats stats; |
| 274 stats.last_active = now; | 275 stats.last_active = now; |
| 275 stats.is_internal_page = true; | 276 stats.is_internal_page = true; |
| 276 stats.child_process_host_id = kInternalPage; | 277 stats.child_process_host_id = kInternalPage; |
| 277 test_list.push_back(stats); | 278 test_list.push_back(stats); |
| 278 } | 279 } |
| 279 | 280 |
| 281 { |
| 282 TabStats stats; |
| 283 stats.last_active = now; |
| 284 stats.is_auto_discardable = false; |
| 285 stats.child_process_host_id = kAutoDiscardable; |
| 286 test_list.push_back(stats); |
| 287 } |
| 288 |
| 280 // This entry sorts to the front, so by adding it last, it verifies that the | 289 // This entry sorts to the front, so by adding it last, it verifies that the |
| 281 // array is being sorted. | 290 // array is being sorted. |
| 282 { | 291 { |
| 283 TabStats stats; | 292 TabStats stats; |
| 284 stats.last_active = now; | 293 stats.last_active = now; |
| 285 stats.is_selected = true; | 294 stats.is_selected = true; |
| 286 stats.child_process_host_id = kSelected; | 295 stats.child_process_host_id = kSelected; |
| 287 test_list.push_back(stats); | 296 test_list.push_back(stats); |
| 288 } | 297 } |
| 289 | 298 |
| 290 std::sort(test_list.begin(), test_list.end(), TabManager::CompareTabStats); | 299 std::sort(test_list.begin(), test_list.end(), TabManager::CompareTabStats); |
| 291 | 300 |
| 292 int index = 0; | 301 int index = 0; |
| 293 EXPECT_EQ(kSelected, test_list[index++].child_process_host_id); | 302 EXPECT_EQ(kSelected, test_list[index++].child_process_host_id); |
| 303 EXPECT_EQ(kAutoDiscardable, test_list[index++].child_process_host_id); |
| 294 EXPECT_EQ(kFormEntry, test_list[index++].child_process_host_id); | 304 EXPECT_EQ(kFormEntry, test_list[index++].child_process_host_id); |
| 295 EXPECT_EQ(kPlayingAudio, test_list[index++].child_process_host_id); | 305 EXPECT_EQ(kPlayingAudio, test_list[index++].child_process_host_id); |
| 296 EXPECT_EQ(kPinned, test_list[index++].child_process_host_id); | 306 EXPECT_EQ(kPinned, test_list[index++].child_process_host_id); |
| 297 EXPECT_EQ(kOldButPinned, test_list[index++].child_process_host_id); | 307 EXPECT_EQ(kOldButPinned, test_list[index++].child_process_host_id); |
| 298 EXPECT_EQ(kApp, test_list[index++].child_process_host_id); | 308 EXPECT_EQ(kApp, test_list[index++].child_process_host_id); |
| 299 EXPECT_EQ(kRecent, test_list[index++].child_process_host_id); | 309 EXPECT_EQ(kRecent, test_list[index++].child_process_host_id); |
| 300 EXPECT_EQ(kOld, test_list[index++].child_process_host_id); | 310 EXPECT_EQ(kOld, test_list[index++].child_process_host_id); |
| 301 EXPECT_EQ(kReallyOld, test_list[index++].child_process_host_id); | 311 EXPECT_EQ(kReallyOld, test_list[index++].child_process_host_id); |
| 302 EXPECT_EQ(kInternalPage, test_list[index++].child_process_host_id); | 312 EXPECT_EQ(kInternalPage, test_list[index++].child_process_host_id); |
| 303 } | 313 } |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 EXPECT_EQ(0u, task_runner->size()); | 661 EXPECT_EQ(0u, task_runner->size()); |
| 652 EXPECT_EQ(0u, tm.notified_renderers_.size()); | 662 EXPECT_EQ(0u, tm.notified_renderers_.size()); |
| 653 | 663 |
| 654 | 664 |
| 655 // Clean up the tabstrip. | 665 // Clean up the tabstrip. |
| 656 tabstrip.CloseAllTabs(); | 666 tabstrip.CloseAllTabs(); |
| 657 ASSERT_TRUE(tabstrip.empty()); | 667 ASSERT_TRUE(tabstrip.empty()); |
| 658 } | 668 } |
| 659 | 669 |
| 660 } // namespace memory | 670 } // namespace memory |
| OLD | NEW |