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/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 BrowserMonitor() : num_browsers_(0) { | |
33 BrowserList::AddObserver(this); | |
34 } | |
35 | |
36 ~BrowserMonitor() { | |
37 BrowserList::RemoveObserver(this); | |
38 } | |
39 | |
40 private: | |
41 // BrowserListObserver implementation. | |
42 virtual void OnBrowserAdded(Browser* browser) OVERRIDE { | |
43 if (browser->type() == Browser::TYPE_TABBED) | |
44 content::GpuDataManager::GetInstance()->SetWindowCount(++num_browsers_); | |
45 } | |
46 | |
47 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE { | |
48 if (browser->type() == Browser::TYPE_TABBED) | |
49 content::GpuDataManager::GetInstance()->SetWindowCount(--num_browsers_); | |
50 } | |
51 | |
52 uint32 num_browsers_; | |
53 }; | |
54 | |
24 bool ShouldRunStage3DFieldTrial() { | 55 bool ShouldRunStage3DFieldTrial() { |
25 #if !defined(OS_WIN) | 56 #if !defined(OS_WIN) |
26 return false; | 57 return false; |
27 #else | 58 #else |
28 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 59 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
29 return false; | 60 return false; |
30 return true; | 61 return true; |
31 #endif | 62 #endif |
32 } | 63 } |
33 | 64 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 content::kGpuCompositingFieldTrialThreadEnabledName, | 181 content::kGpuCompositingFieldTrialThreadEnabledName, |
151 threaded_compositing_probability); | 182 threaded_compositing_probability); |
152 | 183 |
153 bool force_compositing = (trial->group() == force_compositing_group); | 184 bool force_compositing = (trial->group() == force_compositing_group); |
154 bool thread = (trial->group() == thread_group); | 185 bool thread = (trial->group() == thread_group); |
155 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", | 186 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", |
156 force_compositing); | 187 force_compositing); |
157 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); | 188 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); |
158 } | 189 } |
159 | 190 |
191 void InitializeBrowserMonitor() { | |
ccameron
2012/10/02 02:06:43
Will leak detection complain about this? If there
DaveMoore
2012/10/03 20:06:55
Changed it to a singleton that won't trigger leak
| |
192 BrowserList::AddObserver(new BrowserMonitor); | |
193 } | |
194 | |
160 } // namespace gpu_util; | 195 } // namespace gpu_util; |
161 | 196 |
OLD | NEW |