summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-04 16:27:45 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-04 16:27:45 +0000
commitdf09645fa6786c9ce6d753c798f20328394e74b9 (patch)
treed5fa089764a02d2dbfe0c2139c4ee40c5f1fd32f
parentd633575ba8c9d1a48b9a1f9cb931f04ffc215e84 (diff)
downloadchromium_src-df09645fa6786c9ce6d753c798f20328394e74b9.zip
chromium_src-df09645fa6786c9ce6d753c798f20328394e74b9.tar.gz
chromium_src-df09645fa6786c9ce6d753c798f20328394e74b9.tar.bz2
Add calls to inform gpu of browser window count
BUG=146448 TEST=None Review URL: https://codereview.chromium.org/11026015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160144 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_browser_main.cc5
-rw-r--r--chrome/browser/chrome_gpu_util.cc59
-rw-r--r--chrome/browser/chrome_gpu_util.h5
-rw-r--r--content/browser/gpu/gpu_data_manager_impl.cc19
-rw-r--r--content/browser/gpu/gpu_data_manager_impl.h5
-rw-r--r--content/browser/gpu/gpu_process_host.cc6
-rw-r--r--content/public/browser/gpu_data_manager.h5
7 files changed, 102 insertions, 2 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index e504234..f467e00 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -34,6 +34,7 @@
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
+#include "chrome/browser/chrome_gpu_util.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/extensions/extension_protocols.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -929,6 +930,7 @@ void ChromeBrowserMainParts::PostProfileInit() {
void ChromeBrowserMainParts::PreBrowserStart() {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreBrowserStart();
+ gpu_util::InstallBrowserMonitor();
}
void ChromeBrowserMainParts::PostBrowserStart() {
@@ -1394,6 +1396,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
std::vector<Profile*> last_opened_profiles =
g_browser_process->profile_manager()->GetLastOpenedProfiles();
#endif
+
if (browser_creator_->Start(parsed_command_line(), FilePath(),
profile_, last_opened_profiles, &result_code)) {
#if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
@@ -1526,6 +1529,8 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() {
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopRun();
+ gpu_util::UninstallBrowserMonitor();
+
#if defined(OS_WIN)
// Log the search engine chosen on first run. Do this at shutdown, after any
// changes are made from the first run bubble link, etc.
diff --git a/chrome/browser/chrome_gpu_util.cc b/chrome/browser/chrome_gpu_util.cc
index b4221ec..09cfb2f 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,54 @@ 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:
+ static BrowserMonitor* GetInstance() {
+ static BrowserMonitor* instance = NULL;
+ if (!instance)
+ instance = new BrowserMonitor;
+ return instance;
+ }
+
+ void Install() {
+ if (!installed_) {
+ BrowserList::AddObserver(this);
+ installed_ = true;
+ }
+ }
+
+ void Uninstall() {
+ if (installed_) {
+ BrowserList::RemoveObserver(this);
+ installed_ = false;
+ }
+ }
+
+ private:
+ BrowserMonitor() : num_browsers_(0), installed_(false) {
+ }
+
+ ~BrowserMonitor() {
+ }
+
+ // 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 installed_;
+};
+
bool ShouldRunStage3DFieldTrial() {
#if !defined(OS_WIN)
return false;
@@ -157,5 +208,13 @@ void InitializeCompositingFieldTrial() {
UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread);
}
+void InstallBrowserMonitor() {
+ BrowserMonitor::GetInstance()->Install();
+}
+
+void UninstallBrowserMonitor() {
+ BrowserMonitor::GetInstance()->Uninstall();
+}
+
} // namespace gpu_util;
diff --git a/chrome/browser/chrome_gpu_util.h b/chrome/browser/chrome_gpu_util.h
index a4f9efc..def8fcb 100644
--- a/chrome/browser/chrome_gpu_util.h
+++ b/chrome/browser/chrome_gpu_util.h
@@ -13,6 +13,11 @@ void InitializeStage3DFieldTrial();
// Sets up force-compositing-mode and threaded compositing field trials.
void InitializeCompositingFieldTrial();
+// Sets up a monitor for browser windows, to be used to determine gpu
+// managed memory allocation.
+void InstallBrowserMonitor();
+void UninstallBrowserMonitor();
+
} // namespace gpu_util
#endif // CHROME_BROWSER_CHROME_GPU_UTIL_H_
diff --git a/content/browser/gpu/gpu_data_manager_impl.cc b/content/browser/gpu/gpu_data_manager_impl.cc
index 07a5953..923aecd 100644
--- a/content/browser/gpu/gpu_data_manager_impl.cc
+++ b/content/browser/gpu/gpu_data_manager_impl.cc
@@ -76,7 +76,8 @@ GpuDataManagerImpl::GpuDataManagerImpl()
observer_list_(new GpuDataManagerObserverList),
software_rendering_(false),
card_blacklisted_(false),
- update_histograms_(true) {
+ update_histograms_(true),
+ window_count_(0) {
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
command_line->AppendSwitch(switches::kDisableAccelerated2dCanvas);
@@ -285,6 +286,22 @@ void GpuDataManagerImpl::RemoveObserver(GpuDataManagerObserver* observer) {
observer_list_->RemoveObserver(observer);
}
+void GpuDataManagerImpl::SetWindowCount(uint32 count) {
+ {
+ base::AutoLock auto_lock(gpu_info_lock_);
+ window_count_ = count;
+ }
+ GpuProcessHost::SendOnIO(
+ GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED,
+ content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH,
+ new GpuMsg_SetVideoMemoryWindowCount(count));
+}
+
+uint32 GpuDataManagerImpl::GetWindowCount() const {
+ base::AutoLock auto_lock(gpu_info_lock_);
+ return window_count_;
+}
+
void GpuDataManagerImpl::AppendRendererCommandLine(
CommandLine* command_line) const {
DCHECK(command_line);
diff --git a/content/browser/gpu/gpu_data_manager_impl.h b/content/browser/gpu/gpu_data_manager_impl.h
index 118fcb0..d66380d 100644
--- a/content/browser/gpu/gpu_data_manager_impl.h
+++ b/content/browser/gpu/gpu_data_manager_impl.h
@@ -50,6 +50,8 @@ class CONTENT_EXPORT GpuDataManagerImpl
virtual void AddObserver(content::GpuDataManagerObserver* observer) OVERRIDE;
virtual void RemoveObserver(
content::GpuDataManagerObserver* observer) OVERRIDE;
+ virtual void SetWindowCount(uint32 count) OVERRIDE;
+ virtual uint32 GetWindowCount() const OVERRIDE;
// This collects preliminary GPU info, load GpuBlacklist, and compute the
// preliminary blacklisted features; it should only be called at browser
@@ -155,6 +157,9 @@ class CONTENT_EXPORT GpuDataManagerImpl
// they cause random failures.
bool update_histograms_;
+ // Number of currently open windows, to be used in gpu memory allocation.
+ int window_count_;
+
DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImpl);
};
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 481be2d..0515fae 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -446,7 +446,11 @@ bool GpuProcessHost::Init() {
return false;
}
- return Send(new GpuMsg_Initialize());
+ if (!Send(new GpuMsg_Initialize()))
+ return false;
+
+ return Send(new GpuMsg_SetVideoMemoryWindowCount(
+ GpuDataManagerImpl::GetInstance()->GetWindowCount()));
}
void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) {
diff --git a/content/public/browser/gpu_data_manager.h b/content/public/browser/gpu_data_manager.h
index 3a61e23..8bcea35 100644
--- a/content/public/browser/gpu_data_manager.h
+++ b/content/public/browser/gpu_data_manager.h
@@ -79,6 +79,11 @@ class GpuDataManager {
virtual void AddObserver(GpuDataManagerObserver* observer) = 0;
virtual void RemoveObserver(GpuDataManagerObserver* observer) = 0;
+ // Notifies the gpu process about the number of browser windows, so
+ // they can be used to determine managed memory allocation.
+ virtual void SetWindowCount(uint32 count) = 0;
+ virtual uint32 GetWindowCount() const = 0;
+
protected:
virtual ~GpuDataManager() {}
};