Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: chrome/browser/memory/tab_manager.cc

Issue 1867343002: [TabManager] [Merge M50] Protect tabs opened in background. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/memory/tab_manager.h ('k') | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 content::WebContents* new_contents, 343 content::WebContents* new_contents,
344 int index, 344 int index,
345 int reason) { 345 int reason) {
346 GetWebContentsData(new_contents)->SetDiscardState(false); 346 GetWebContentsData(new_contents)->SetDiscardState(false);
347 // If |old_contents| is set, that tab has switched from being active to 347 // If |old_contents| is set, that tab has switched from being active to
348 // inactive, so record the time of that transition. 348 // inactive, so record the time of that transition.
349 if (old_contents) 349 if (old_contents)
350 GetWebContentsData(old_contents)->SetLastInactiveTime(NowTicks()); 350 GetWebContentsData(old_contents)->SetLastInactiveTime(NowTicks());
351 } 351 }
352 352
353 void TabManager::TabInsertedAt(content::WebContents* contents,
354 int index,
355 bool foreground) {
356 // Only interested in background tabs, as foreground tabs get taken care of by
357 // ActiveTabChanged.
358 if (foreground)
359 return;
360
361 // A new background tab is similar to having a tab switch from being active to
362 // inactive.
363 GetWebContentsData(contents)->SetLastInactiveTime(NowTicks());
364 }
365
353 /////////////////////////////////////////////////////////////////////////////// 366 ///////////////////////////////////////////////////////////////////////////////
354 // TabManager, private: 367 // TabManager, private:
355 368
356 // static 369 // static
357 void TabManager::PurgeMemoryAndDiscardTab() { 370 void TabManager::PurgeMemoryAndDiscardTab() {
358 if (g_browser_process && g_browser_process->GetTabManager()) { 371 if (g_browser_process && g_browser_process->GetTabManager()) {
359 TabManager* manager = g_browser_process->GetTabManager(); 372 TabManager* manager = g_browser_process->GetTabManager();
360 manager->PurgeBrowserMemory(); 373 manager->PurgeBrowserMemory();
361 manager->DiscardTab(); 374 manager->DiscardTab();
362 } 375 }
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 // Schedule another notification. Use a weak pointer so this doesn't explode 806 // Schedule another notification. Use a weak pointer so this doesn't explode
794 // during tear down. 807 // during tear down.
795 task_runner_->PostDelayedTask( 808 task_runner_->PostDelayedTask(
796 FROM_HERE, 809 FROM_HERE,
797 base::Bind(&TabManager::DoChildProcessDispatch, 810 base::Bind(&TabManager::DoChildProcessDispatch,
798 weak_ptr_factory_.GetWeakPtr()), 811 weak_ptr_factory_.GetWeakPtr()),
799 base::TimeDelta::FromSeconds(kRendererNotificationDelayInSeconds)); 812 base::TimeDelta::FromSeconds(kRendererNotificationDelayInSeconds));
800 } 813 }
801 814
802 } // namespace memory 815 } // namespace memory
OLDNEW
« no previous file with comments | « chrome/browser/memory/tab_manager.h ('k') | chrome/browser/memory/tab_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698