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 |
| 31 // There's no BrowserList on Android/ |
| 32 #if !defined(OS_ANDROID) |
| 33 class BrowserMonitor : public chrome::BrowserListObserver { |
| 34 public: |
| 35 static BrowserMonitor* GetInstance() { |
| 36 static BrowserMonitor* instance = NULL; |
| 37 if (!instance) |
| 38 instance = new BrowserMonitor; |
| 39 return instance; |
| 40 } |
| 41 |
| 42 void Install() { |
| 43 if (!installed_) { |
| 44 BrowserList::AddObserver(this); |
| 45 installed_ = true; |
| 46 } |
| 47 } |
| 48 |
| 49 void Uninstall() { |
| 50 if (installed_) { |
| 51 BrowserList::RemoveObserver(this); |
| 52 installed_ = false; |
| 53 } |
| 54 } |
| 55 |
| 56 private: |
| 57 BrowserMonitor() : num_browsers_(0), installed_(false) { |
| 58 } |
| 59 |
| 60 ~BrowserMonitor() { |
| 61 } |
| 62 |
| 63 // BrowserListObserver implementation. |
| 64 virtual void OnBrowserAdded(Browser* browser) OVERRIDE { |
| 65 if (browser->type() == Browser::TYPE_TABBED) |
| 66 content::GpuDataManager::GetInstance()->SetWindowCount(++num_browsers_); |
| 67 } |
| 68 |
| 69 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE { |
| 70 if (browser->type() == Browser::TYPE_TABBED) |
| 71 content::GpuDataManager::GetInstance()->SetWindowCount(--num_browsers_); |
| 72 } |
| 73 |
| 74 uint32 num_browsers_; |
| 75 bool installed_; |
| 76 }; |
| 77 |
| 78 void InstallBrowserMonitor() { |
| 79 BrowserMonitor::GetInstance()->Install(); |
| 80 } |
| 81 |
| 82 void UninstallBrowserMonitor() { |
| 83 BrowserMonitor::GetInstance()->Uninstall(); |
| 84 } |
| 85 |
| 86 #endif // !defined(OS_ANDROID) |
| 87 |
24 bool ShouldRunStage3DFieldTrial() { | 88 bool ShouldRunStage3DFieldTrial() { |
25 #if !defined(OS_WIN) | 89 #if !defined(OS_WIN) |
26 return false; | 90 return false; |
27 #else | 91 #else |
28 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 92 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
29 return false; | 93 return false; |
30 return true; | 94 return true; |
31 #endif | 95 #endif |
32 } | 96 } |
33 | 97 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 216 |
153 bool force_compositing = (trial->group() == force_compositing_group); | 217 bool force_compositing = (trial->group() == force_compositing_group); |
154 bool thread = (trial->group() == thread_group); | 218 bool thread = (trial->group() == thread_group); |
155 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", | 219 UMA_HISTOGRAM_BOOLEAN("GPU.InForceCompositingModeFieldTrial", |
156 force_compositing); | 220 force_compositing); |
157 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); | 221 UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread); |
158 } | 222 } |
159 | 223 |
160 } // namespace gpu_util; | 224 } // namespace gpu_util; |
161 | 225 |
OLD | NEW |