| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 content::WebContents* new_contents, | 354 content::WebContents* new_contents, |
| 355 int index, | 355 int index, |
| 356 int reason) { | 356 int reason) { |
| 357 GetWebContentsData(new_contents)->SetDiscardState(false); | 357 GetWebContentsData(new_contents)->SetDiscardState(false); |
| 358 // If |old_contents| is set, that tab has switched from being active to | 358 // If |old_contents| is set, that tab has switched from being active to |
| 359 // inactive, so record the time of that transition. | 359 // inactive, so record the time of that transition. |
| 360 if (old_contents) | 360 if (old_contents) |
| 361 GetWebContentsData(old_contents)->SetLastInactiveTime(NowTicks()); | 361 GetWebContentsData(old_contents)->SetLastInactiveTime(NowTicks()); |
| 362 } | 362 } |
| 363 | 363 |
| 364 void TabManager::TabInsertedAt(content::WebContents* contents, |
| 365 int index, |
| 366 bool foreground) { |
| 367 // Only interested in background tabs, as foreground tabs get taken care of by |
| 368 // ActiveTabChanged. |
| 369 if (foreground) |
| 370 return; |
| 371 |
| 372 // A new background tab is similar to having a tab switch from being active to |
| 373 // inactive. |
| 374 GetWebContentsData(contents)->SetLastInactiveTime(NowTicks()); |
| 375 } |
| 376 |
| 364 /////////////////////////////////////////////////////////////////////////////// | 377 /////////////////////////////////////////////////////////////////////////////// |
| 365 // TabManager, private: | 378 // TabManager, private: |
| 366 | 379 |
| 367 // static | 380 // static |
| 368 void TabManager::PurgeMemoryAndDiscardTab() { | 381 void TabManager::PurgeMemoryAndDiscardTab() { |
| 369 if (g_browser_process && g_browser_process->GetTabManager()) { | 382 if (g_browser_process && g_browser_process->GetTabManager()) { |
| 370 TabManager* manager = g_browser_process->GetTabManager(); | 383 TabManager* manager = g_browser_process->GetTabManager(); |
| 371 manager->PurgeBrowserMemory(); | 384 manager->PurgeBrowserMemory(); |
| 372 manager->DiscardTab(); | 385 manager->DiscardTab(); |
| 373 } | 386 } |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 // Schedule another notification. Use a weak pointer so this doesn't explode | 813 // Schedule another notification. Use a weak pointer so this doesn't explode |
| 801 // during tear down. | 814 // during tear down. |
| 802 task_runner_->PostDelayedTask( | 815 task_runner_->PostDelayedTask( |
| 803 FROM_HERE, | 816 FROM_HERE, |
| 804 base::Bind(&TabManager::DoChildProcessDispatch, | 817 base::Bind(&TabManager::DoChildProcessDispatch, |
| 805 weak_ptr_factory_.GetWeakPtr()), | 818 weak_ptr_factory_.GetWeakPtr()), |
| 806 base::TimeDelta::FromSeconds(kRendererNotificationDelayInSeconds)); | 819 base::TimeDelta::FromSeconds(kRendererNotificationDelayInSeconds)); |
| 807 } | 820 } |
| 808 | 821 |
| 809 } // namespace memory | 822 } // namespace memory |
| OLD | NEW |