Commit f767462d authored by gab@chromium.org's avatar gab@chromium.org

Phase out BrowserList::empty() and BrowserList::size().

Replace last couple of instances by chrome::GetTotalBrowserCount() as in https://codereview.chromium.org/12212120/.

oom_priority_manager.cc is ChromeOS only and thus only needs to care about the ash browser list.

BUG=129187

Review URL: https://chromiumcodereview.appspot.com/12211139

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182378 0039d316-1c4b-4281-b951-d872f2087c98
parent 069220eb
......@@ -28,7 +28,8 @@
#include "chrome/browser/memory_details.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_impl.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_constants.h"
......@@ -528,8 +529,10 @@ void OomPriorityManager::Observe(int type,
// 2) last time a tab was selected
// 3) is the tab currently selected
void OomPriorityManager::AdjustOomPriorities() {
if (BrowserList::size() == 0)
if (chrome::BrowserListImpl::GetInstance(
chrome::HOST_DESKTOP_TYPE_ASH)->empty()) {
return;
}
// Check for a discontinuity in time caused by the machine being suspended.
if (!last_adjust_time_.is_null()) {
......@@ -556,9 +559,11 @@ OomPriorityManager::TabStatsList OomPriorityManager::GetTabStatsOnUIThread() {
TabStatsList stats_list;
stats_list.reserve(32); // 99% of users have < 30 tabs open
bool browser_active = true;
for (BrowserList::const_reverse_iterator browser_iterator =
BrowserList::begin_last_active();
browser_iterator != BrowserList::end_last_active();
const chrome::BrowserListImpl* ash_browser_list =
chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
for (chrome::BrowserListImpl::const_reverse_iterator browser_iterator =
ash_browser_list->begin_last_active();
browser_iterator != ash_browser_list->end_last_active();
++browser_iterator) {
Browser* browser = *browser_iterator;
bool is_browser_for_app = browser->is_app();
......
......@@ -24,7 +24,7 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/shell_window.h"
......@@ -857,7 +857,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTestNoDefaultBrowser,
WindowedAppDoesNotAddToBrowser) {
// Get the number of items in the browser menu.
size_t items = NumberOfDetectedLauncherBrowsers();
size_t running_browser = BrowserList::size();
size_t running_browser = chrome::GetTotalBrowserCount();
EXPECT_EQ(0u, items);
EXPECT_EQ(0u, running_browser);
......@@ -865,13 +865,13 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTestNoDefaultBrowser,
// No new browser should get detected, even though one more is running.
EXPECT_EQ(0u, NumberOfDetectedLauncherBrowsers());
EXPECT_EQ(++running_browser, BrowserList::size());
EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount());
LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, NEW_WINDOW);
// A new browser should get detected and one more should be running.
EXPECT_GE(NumberOfDetectedLauncherBrowsers(), 1u);
EXPECT_EQ(++running_browser, BrowserList::size());
EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount());
}
......@@ -56,16 +56,6 @@ void BrowserList::CloseAllBrowsersWithProfile(Profile* profile) {
}
}
// static
bool BrowserList::empty() {
return GetNativeList()->empty();
}
// static
size_t BrowserList::size() {
return GetNativeList()->size();
}
// static
void BrowserList::SetLastActive(Browser* browser) {
chrome::BrowserListImpl::GetInstance(browser->host_desktop_type())->
......
......@@ -38,9 +38,6 @@ class BrowserList {
// Closes all browsers for |profile| across all desktops.
static void CloseAllBrowsersWithProfile(Profile* profile);
static bool empty();
static size_t size();
// Returns iterated access to list of open browsers ordered by when
// they were last active. The underlying data structure is a vector
// and we push_back on recent access so a reverse iterator gives the
......
......@@ -5,7 +5,7 @@
#import "chrome/browser/ui/cocoa/one_click_signin_dialog_controller.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_finder.h"
#import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
......@@ -80,9 +80,9 @@ IN_PROC_BROWSER_TEST_F(OneClickSigninDialogControllerTest, Close) {
// Test that clicking the learn more link opens a new window.
IN_PROC_BROWSER_TEST_F(OneClickSigninDialogControllerTest, LearnMore) {
EXPECT_EQ(1u, BrowserList::size());
EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
[controller_->view_controller() textView:nil
clickedOnLink:nil
atIndex:0];
EXPECT_EQ(2u, BrowserList::size());
EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
}
......@@ -21,7 +21,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list_impl.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_tabstrip.h"
......@@ -371,11 +371,11 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
content::RunAllPendingInMessageLoop();
QuitBrowsers();
CHECK(BrowserList::empty());
CHECK(native_browser_list->empty());
}
void InProcessBrowserTest::QuitBrowsers() {
if (BrowserList::empty())
if (chrome::GetTotalBrowserCount() == 0)
return;
// Invoke AttemptExit on a running message loop.
......
......@@ -530,7 +530,7 @@ BrowserAddedObserver::~BrowserAddedObserver() {
Browser* BrowserAddedObserver::WaitForSingleNewBrowser() {
notification_observer_.Wait();
// Ensure that only a single new browser has appeared.
EXPECT_EQ(original_browsers_.size() + 1, BrowserList::size());
EXPECT_EQ(original_browsers_.size() + 1, chrome::GetTotalBrowserCount());
return GetBrowserNotInSet(original_browsers_);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment