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

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

Issue 1644773003: Remove BrowserIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@host-desktop-1
Patch Set: . Created 4 years, 10 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
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 18 matching lines...) Expand all
29 #include "base/threading/thread.h" 29 #include "base/threading/thread.h"
30 #include "base/time/tick_clock.h" 30 #include "base/time/tick_clock.h"
31 #include "build/build_config.h" 31 #include "build/build_config.h"
32 #include "chrome/browser/browser_process.h" 32 #include "chrome/browser/browser_process.h"
33 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 33 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
34 #include "chrome/browser/media/media_stream_capture_indicator.h" 34 #include "chrome/browser/media/media_stream_capture_indicator.h"
35 #include "chrome/browser/memory/oom_memory_details.h" 35 #include "chrome/browser/memory/oom_memory_details.h"
36 #include "chrome/browser/memory/tab_manager_web_contents_data.h" 36 #include "chrome/browser/memory/tab_manager_web_contents_data.h"
37 #include "chrome/browser/profiles/profile.h" 37 #include "chrome/browser/profiles/profile.h"
38 #include "chrome/browser/ui/browser.h" 38 #include "chrome/browser/ui/browser.h"
39 #include "chrome/browser/ui/browser_iterator.h"
40 #include "chrome/browser/ui/browser_list.h" 39 #include "chrome/browser/ui/browser_list.h"
41 #include "chrome/browser/ui/host_desktop.h" 40 #include "chrome/browser/ui/host_desktop.h"
42 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 41 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
43 #include "chrome/browser/ui/tabs/tab_strip_model.h" 42 #include "chrome/browser/ui/tabs/tab_strip_model.h"
44 #include "chrome/browser/ui/tabs/tab_utils.h" 43 #include "chrome/browser/ui/tabs/tab_utils.h"
45 #include "chrome/common/chrome_constants.h" 44 #include "chrome/common/chrome_constants.h"
46 #include "chrome/common/chrome_features.h" 45 #include "chrome/common/chrome_features.h"
47 #include "chrome/common/url_constants.h" 46 #include "chrome/common/url_constants.h"
48 #include "components/metrics/system_memory_stats_recorder.h" 47 #include "components/metrics/system_memory_stats_recorder.h"
49 #include "components/variations/variations_associated_data.h" 48 #include "components/variations/variations_associated_data.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 83
85 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as 84 // Returns a unique ID for a WebContents. Do not cast back to a pointer, as
86 // the WebContents could be deleted if the user closed the tab. 85 // the WebContents could be deleted if the user closed the tab.
87 int64_t IdFromWebContents(WebContents* web_contents) { 86 int64_t IdFromWebContents(WebContents* web_contents) {
88 return reinterpret_cast<int64_t>(web_contents); 87 return reinterpret_cast<int64_t>(web_contents);
89 } 88 }
90 89
91 int FindTabStripModelById(int64_t target_web_contents_id, 90 int FindTabStripModelById(int64_t target_web_contents_id,
92 TabStripModel** model) { 91 TabStripModel** model) {
93 DCHECK(model); 92 DCHECK(model);
94 for (chrome::BrowserIterator it; !it.done(); it.Next()) { 93 for (auto* browser : *BrowserList::GetInstance()) {
95 Browser* browser = *it;
96 TabStripModel* local_model = browser->tab_strip_model(); 94 TabStripModel* local_model = browser->tab_strip_model();
97 for (int idx = 0; idx < local_model->count(); idx++) { 95 for (int idx = 0; idx < local_model->count(); idx++) {
98 WebContents* web_contents = local_model->GetWebContentsAt(idx); 96 WebContents* web_contents = local_model->GetWebContentsAt(idx);
99 int64_t web_contents_id = IdFromWebContents(web_contents); 97 int64_t web_contents_id = IdFromWebContents(web_contents);
100 if (web_contents_id == target_web_contents_id) { 98 if (web_contents_id == target_web_contents_id) {
101 *model = local_model; 99 *model = local_model;
102 return idx; 100 return idx;
103 } 101 }
104 } 102 }
105 } 103 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 for (TabContentsIterator it; !it.done(); it.Next()) { 384 for (TabContentsIterator it; !it.done(); it.Next()) {
387 WebContents* web_contents = *it; 385 WebContents* web_contents = *it;
388 // Screenshots can consume ~5 MB per web contents for platforms that do 386 // Screenshots can consume ~5 MB per web contents for platforms that do
389 // touch back/forward. 387 // touch back/forward.
390 web_contents->GetController().ClearAllScreenshots(); 388 web_contents->GetController().ClearAllScreenshots();
391 } 389 }
392 } 390 }
393 391
394 int TabManager::GetTabCount() const { 392 int TabManager::GetTabCount() const {
395 int tab_count = 0; 393 int tab_count = 0;
396 for (chrome::BrowserIterator it; !it.done(); it.Next()) 394 for (auto* browser : *BrowserList::GetInstance())
397 tab_count += it->tab_strip_model()->count(); 395 tab_count += browser->tab_strip_model()->count();
398 return tab_count; 396 return tab_count;
399 } 397 }
400 398
401 void TabManager::AddTabStats(TabStatsList* stats_list) { 399 void TabManager::AddTabStats(TabStatsList* stats_list) {
402 BrowserList* browser_list = BrowserList::GetInstance(); 400 BrowserList* browser_list = BrowserList::GetInstance();
403 // The first window will be the active one. 401 // The first window will be the active one.
404 bool browser_active = true; 402 bool browser_active = true;
405 for (BrowserList::const_reverse_iterator browser_iterator = 403 for (BrowserList::const_reverse_iterator browser_iterator =
406 browser_list->begin_last_active(); 404 browser_list->begin_last_active();
407 browser_iterator != browser_list->end_last_active(); 405 browser_iterator != browser_list->end_last_active();
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 } 646 }
649 647
650 TimeTicks TabManager::NowTicks() const { 648 TimeTicks TabManager::NowTicks() const {
651 if (!test_tick_clock_) 649 if (!test_tick_clock_)
652 return TimeTicks::Now(); 650 return TimeTicks::Now();
653 651
654 return test_tick_clock_->NowTicks(); 652 return test_tick_clock_->NowTicks();
655 } 653 }
656 654
657 } // namespace memory 655 } // namespace memory
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/browser_close_manager_browsertest.cc ('k') | chrome/browser/metrics/first_web_contents_profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698