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

Side by Side Diff: chrome/browser/chrome_gpu_util.cc

Issue 11026015: Add calls to inform gpu of browser window count (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Send correct window count Created 8 years, 2 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 | Annotate | Revision Log
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/chrome_gpu_util.h" 5 #include "chrome/browser/chrome_gpu_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/version.h" 10 #include "base/version.h"
11 #if defined(OS_WIN) 11 #if defined(OS_WIN)
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #endif 13 #endif
14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_list.h"
16 #include "chrome/browser/ui/browser_list_observer.h"
14 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/chrome_version_info.h" 18 #include "chrome/common/chrome_version_info.h"
16 #include "content/public/browser/gpu_data_manager.h" 19 #include "content/public/browser/gpu_data_manager.h"
17 #include "content/public/common/content_constants.h" 20 #include "content/public/common/content_constants.h"
18 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
19 22
20 using content::GpuDataManager; 23 using content::GpuDataManager;
21 24
22 namespace gpu_util { 25 namespace gpu_util {
23 26
27 // The BrowserMonitor class is used to track the number of currently open
28 // browser windows, so that the gpu can be notified when they are created or
29 // destroyed. We only count tabbed windows for this purpose.
30 class BrowserMonitor : public chrome::BrowserListObserver {
31 public:
32 static BrowserMonitor* GetInstance() {
33 static BrowserMonitor* instance = NULL;
34 if (!instance)
35 instance = new BrowserMonitor;
36 return instance;
37 }
38
39 void Install() {
40 if (!installed_) {
41 BrowserList::AddObserver(this);
42 installed_ = true;
43 }
44 }
45
46 void Uninstall() {
47 if (installed_) {
48 BrowserList::RemoveObserver(this);
49 installed_ = false;
50 }
51 }
52
53 private:
54 BrowserMonitor() : num_browsers_(0), installed_(false) {
55 }
56
57 ~BrowserMonitor() {
58 }
59
60 // BrowserListObserver implementation.
61 virtual void OnBrowserAdded(Browser* browser) OVERRIDE {
62 if (browser->type() == Browser::TYPE_TABBED)
63 content::GpuDataManager::GetInstance()->SetWindowCount(++num_browsers_);
64 }
65
66 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE {
67 if (browser->type() == Browser::TYPE_TABBED)
68 content::GpuDataManager::GetInstance()->SetWindowCount(--num_browsers_);
69 }
70
71 uint32 num_browsers_;
72 bool installed_;
73 };
74
24 bool ShouldRunStage3DFieldTrial() { 75 bool ShouldRunStage3DFieldTrial() {
25 #if !defined(OS_WIN) 76 #if !defined(OS_WIN)
26 return false; 77 return false;
27 #else 78 #else
28 if (base::win::GetVersion() >= base::win::VERSION_VISTA) 79 if (base::win::GetVersion() >= base::win::VERSION_VISTA)
29 return false; 80 return false;
30 return true; 81 return true;
31 #endif 82 #endif
32 } 83 }
33 84
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 content::kGpuCompositingFieldTrialThreadEnabledName, 201 content::kGpuCompositingFieldTrialThreadEnabledName,
151 threaded_compositing_probability); 202 threaded_compositing_probability);
152 203
153 bool force_compositing = (trial->group() == force_compositing_group); 204 bool force_compositing = (trial->group() == force_compositing_group);
154 bool thread = (trial->group() == thread_group); 205 bool thread = (trial->group() == thread_group);
155 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", 206 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial",
156 force_compositing); 207 force_compositing);
157 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); 208 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread);
158 } 209 }
159 210
211 void InstallBrowserMonitor() {
212 BrowserMonitor::GetInstance()->Install();
213 }
214
215 void UninstallBrowserMonitor() {
216 BrowserMonitor::GetInstance()->Uninstall();
217 }
218
160 } // namespace gpu_util; 219 } // namespace gpu_util;
161 220
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698