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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chrome_gpu_util.h ('k') | content/browser/gpu/gpu_data_manager_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_gpu_util.cc
diff --git a/chrome/browser/chrome_gpu_util.cc b/chrome/browser/chrome_gpu_util.cc
index b4221eca6e88addc629eef7120cd5ce02686f87c..af2c57e4d1270b504b4f429cf03856728bcd6f4b 100644
--- a/chrome/browser/chrome_gpu_util.cc
+++ b/chrome/browser/chrome_gpu_util.cc
@@ -11,6 +11,9 @@
#if defined(OS_WIN)
#include "base/win/windows_version.h"
#endif
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "content/public/browser/gpu_data_manager.h"
@@ -21,6 +24,34 @@ using content::GpuDataManager;
namespace gpu_util {
+// The BrowserMonitor class is used to track the number of currently open
+// browser windows, so that the gpu can be notified when they are created or
+// destroyed. We only count tabbed windows for this purpose.
+class BrowserMonitor : public chrome::BrowserListObserver {
+ public:
+ BrowserMonitor() : num_browsers_(0) {
+ BrowserList::AddObserver(this);
+ }
+
+ ~BrowserMonitor() {
+ BrowserList::RemoveObserver(this);
+ }
+
+ private:
+ // BrowserListObserver implementation.
+ virtual void OnBrowserAdded(Browser* browser) OVERRIDE {
+ if (browser->type() == Browser::TYPE_TABBED)
+ content::GpuDataManager::GetInstance()->SetWindowCount(++num_browsers_);
+ }
+
+ virtual void OnBrowserRemoved(Browser* browser) OVERRIDE {
+ if (browser->type() == Browser::TYPE_TABBED)
+ content::GpuDataManager::GetInstance()->SetWindowCount(--num_browsers_);
+ }
+
+ uint32 num_browsers_;
+};
+
bool ShouldRunStage3DFieldTrial() {
#if !defined(OS_WIN)
return false;
@@ -157,5 +188,9 @@ void InitializeCompositingFieldTrial() {
UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread);
}
+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
+ BrowserList::AddObserver(new BrowserMonitor);
+}
+
} // namespace gpu_util;
« no previous file with comments | « chrome/browser/chrome_gpu_util.h ('k') | content/browser/gpu/gpu_data_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698