diff options
author | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-12 18:31:59 +0000 |
---|---|---|
committer | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-12 18:31:59 +0000 |
commit | 5742fc7ee206d77716571aad6250dffa21624764 (patch) | |
tree | 7a1eff4355b47f47a6d4d47c76e7d16228d782de /chrome/browser | |
parent | 2f70247ef25f754fcc5eff940d960c9d433e7067 (diff) | |
download | chromium_src-5742fc7ee206d77716571aad6250dffa21624764.zip chromium_src-5742fc7ee206d77716571aad6250dffa21624764.tar.gz chromium_src-5742fc7ee206d77716571aad6250dffa21624764.tar.bz2 |
Cache GL strings from GPU process and use them at next browser startup.
So we can make complete GPU blacklist decisions at browser startup time.
BUG=164728
TEST=
Review URL: https://codereview.chromium.org/11446080
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172627 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser_process.h | 3 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 8 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.h | 3 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 6 | ||||
-rw-r--r-- | chrome/browser/gpu/gl_string_manager.cc | 65 | ||||
-rw-r--r-- | chrome/browser/gpu/gl_string_manager.h | 36 |
6 files changed, 121 insertions, 0 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h index 180aa15..8afdb2a 100644 --- a/chrome/browser/browser_process.h +++ b/chrome/browser/browser_process.h @@ -23,6 +23,7 @@ class CRLSetFetcher; class ComponentUpdateService; class DownloadRequestLimiter; class DownloadStatusUpdater; +class GLStringManager; class IconManager; class IntranetRedirectDetector; class IOThread; @@ -133,6 +134,8 @@ class BrowserProcess { virtual IconManager* icon_manager() = 0; + virtual GLStringManager* gl_string_manager() = 0; + virtual RenderWidgetSnapshotTaker* GetRenderWidgetSnapshotTaker() = 0; virtual AutomationProviderList* GetAutomationProviderList() = 0; diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 755c69c..d02897b 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -33,6 +33,7 @@ #include "chrome/browser/extensions/event_router_forwarder.h" #include "chrome/browser/extensions/extension_tab_id_map.h" #include "chrome/browser/first_run/upgrade_util.h" +#include "chrome/browser/gpu/gl_string_manager.h" #include "chrome/browser/icon_manager.h" #include "chrome/browser/intranet_redirect_detector.h" #include "chrome/browser/io_thread.h" @@ -473,6 +474,13 @@ IconManager* BrowserProcessImpl::icon_manager() { return icon_manager_.get(); } +GLStringManager* BrowserProcessImpl::gl_string_manager() { + DCHECK(CalledOnValidThread()); + if (!gl_string_manager_.get()) + gl_string_manager_.reset(new GLStringManager()); + return gl_string_manager_.get(); +} + RenderWidgetSnapshotTaker* BrowserProcessImpl::GetRenderWidgetSnapshotTaker() { return render_widget_snapshot_taker_.get(); } diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index 774a20c..49671ff 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -86,6 +86,7 @@ class BrowserProcessImpl : public BrowserProcess, virtual policy::BrowserPolicyConnector* browser_policy_connector() OVERRIDE; virtual policy::PolicyService* policy_service() OVERRIDE; virtual IconManager* icon_manager() OVERRIDE; + virtual GLStringManager* gl_string_manager() OVERRIDE; virtual RenderWidgetSnapshotTaker* GetRenderWidgetSnapshotTaker() OVERRIDE; virtual AutomationProviderList* GetAutomationProviderList() OVERRIDE; virtual void CreateDevToolsHttpProtocolHandler( @@ -178,6 +179,8 @@ class BrowserProcessImpl : public BrowserProcess, bool created_icon_manager_; scoped_ptr<IconManager> icon_manager_; + scoped_ptr<GLStringManager> gl_string_manager_; + scoped_refptr<extensions::EventRouterForwarder> extension_event_router_forwarder_; diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index f31005f..b5be828 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -48,6 +48,7 @@ #include "chrome/browser/google/google_search_counter.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/gpu/chrome_gpu_util.h" +#include "chrome/browser/gpu/gl_string_manager.h" #include "chrome/browser/jankometer.h" #include "chrome/browser/managed_mode/managed_mode.h" #include "chrome/browser/metrics/field_trial_synchronizer.h" @@ -1174,6 +1175,11 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { // (requires supporting early exit). PostProfileInit(); + // Retrieve cached GL strings from local state and use them for GPU + // blacklist decisions. + if (g_browser_process->gl_string_manager()) + g_browser_process->gl_string_manager()->Initialize(); + #if !defined(OS_ANDROID) // Show the First Run UI if this is the first time Chrome has been run on // this computer, or we're being compelled to do so by a command line flag. diff --git a/chrome/browser/gpu/gl_string_manager.cc b/chrome/browser/gpu/gl_string_manager.cc new file mode 100644 index 0000000..7cc8bc6 --- /dev/null +++ b/chrome/browser/gpu/gl_string_manager.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/gpu/gl_string_manager.h" + +#include "chrome/browser/browser_process.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/common/pref_names.h" +#include "content/public/browser/gpu_data_manager.h" + +GLStringManager::GLStringManager() { +} + +GLStringManager::~GLStringManager() { +} + +void GLStringManager::Initialize() { + // On MacOSX or Windows, preliminary GPUInfo is enough. +#if defined(OS_LINUX) + // We never remove this observer from GpuDataManager. + content::GpuDataManager::GetInstance()->AddObserver(this); + + PrefService* local_state = g_browser_process->local_state(); + if (!local_state) + return; + + local_state->RegisterStringPref(prefs::kGLVendorString, gl_vendor_); + local_state->RegisterStringPref(prefs::kGLRendererString, gl_renderer_); + local_state->RegisterStringPref(prefs::kGLVersionString, gl_version_); + + gl_vendor_ = local_state->GetString(prefs::kGLVendorString); + gl_renderer_ = local_state->GetString(prefs::kGLRendererString); + gl_version_ = local_state->GetString(prefs::kGLVersionString); + + if (!gl_vendor_.empty() || !gl_renderer_.empty() || !gl_version_.empty()) { + content::GpuDataManager::GetInstance()->SetGLStrings( + gl_vendor_, gl_renderer_, gl_version_); + } +#endif +} + +void GLStringManager::OnGpuInfoUpdate() { + std::string gl_vendor, gl_renderer, gl_version; + content::GpuDataManager::GetInstance()->GetGLStrings( + &gl_vendor, &gl_renderer, &gl_version); + + PrefService* local_state = g_browser_process->local_state(); + if (!local_state) + return; + + if (!gl_vendor.empty() && gl_vendor != gl_vendor_) { + gl_vendor_ = gl_vendor; + local_state->SetString(prefs::kGLVendorString, gl_vendor_); + } + if (!gl_renderer.empty() && gl_renderer != gl_renderer_) { + gl_renderer_ = gl_renderer; + local_state->SetString(prefs::kGLRendererString, gl_renderer_); + } + if (!gl_version.empty() && gl_version != gl_version_) { + gl_version_ = gl_version; + local_state->SetString(prefs::kGLVersionString, gl_version_); + } +} + diff --git a/chrome/browser/gpu/gl_string_manager.h b/chrome/browser/gpu/gl_string_manager.h new file mode 100644 index 0000000..bf3b499 --- /dev/null +++ b/chrome/browser/gpu/gl_string_manager.h @@ -0,0 +1,36 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_GPU_GL_STRING_MANAGER_H_ +#define CHROME_BROWSER_GPU_GL_STRING_MANAGER_H_ + +#include <string> + +#include "base/compiler_specific.h" +#include "content/public/browser/gpu_data_manager_observer.h" + +class GLStringManager : public content::GpuDataManagerObserver { + public: + GLStringManager(); + virtual ~GLStringManager(); + + // Get cached GL strings in local state and send them to GpuDataManager. + void Initialize(); + + // content::GpuDataManagerObserver + virtual void OnGpuInfoUpdate() OVERRIDE; + virtual void OnVideoMemoryUsageStatsUpdate( + const content::GPUVideoMemoryUsageStats& video_memory_usage_stats) + OVERRIDE {} + + private: + std::string gl_vendor_; + std::string gl_renderer_; + std::string gl_version_; + + DISALLOW_COPY_AND_ASSIGN(GLStringManager); +}; + +#endif // CHROME_BROWSER_GPU_GL_STRING_MANAGER_H_ + |