summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_resource
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 06:41:16 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 06:41:16 +0000
commitf0170325dafb6b27b4e0dd4491b6ff78cf9eb6ae (patch)
tree1b14bac06d71243993635f2b2f4aac0a4781176e /chrome/browser/web_resource
parent57391d0577690634db7c973f2df0ae60c8e5721d (diff)
downloadchromium_src-f0170325dafb6b27b4e0dd4491b6ff78cf9eb6ae.zip
chromium_src-f0170325dafb6b27b4e0dd4491b6ff78cf9eb6ae.tar.gz
chromium_src-f0170325dafb6b27b4e0dd4491b6ff78cf9eb6ae.tar.bz2
Move the synchronous GPU messages to the IO thread to avoid deadlock.
I patched in Jonathan's change from http://codereview.chromium.org/6881105/ for the CreateViewCommandBuffer message, and also added the Synchronize and EstablishChannel. The latter required making GpuDataManager callable from the IO thread. I moved the code that loads the blacklist from the prefs and web to Chrome code, since I wanted to do that anyways so that GpuProcessHostUIShim and GpuDataManager can move to content (I'll do that later). Since the messages are filtered on the IO thread, it's now GpuProcessHost that creates GpuProcessHostUIShim. Accordingly, all the code that used to call GpuProcessHostUIShim to send a message now has to call GpuProcessHost, since the logic of when to create a process is there. Also, since there's no IO thread object for the in-process case, I've had to break that in the meantime. Al will take a look at that later. BUG=77536 Review URL: http://codereview.chromium.org/6902021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82990 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_resource')
-rw-r--r--chrome/browser/web_resource/gpu_blacklist_updater.cc76
-rw-r--r--chrome/browser/web_resource/gpu_blacklist_updater.h9
2 files changed, 84 insertions, 1 deletions
diff --git a/chrome/browser/web_resource/gpu_blacklist_updater.cc b/chrome/browser/web_resource/gpu_blacklist_updater.cc
index 3c5897be..800bb38 100644
--- a/chrome/browser/web_resource/gpu_blacklist_updater.cc
+++ b/chrome/browser/web_resource/gpu_blacklist_updater.cc
@@ -4,15 +4,21 @@
#include "chrome/browser/web_resource/gpu_blacklist_updater.h"
+#include "base/logging.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/gpu_data_manager.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
#include "content/browser/browser_thread.h"
+#include "content/browser/gpu_blacklist.h"
#include "content/common/notification_type.h"
+#include "grit/browser_resources.h"
+#include "ui/base/resource/resource_bundle.h"
namespace {
@@ -35,7 +41,18 @@ GpuBlacklistUpdater::GpuBlacklistUpdater()
NotificationType::NOTIFICATION_TYPE_COUNT,
prefs::kGpuBlacklistUpdate,
kStartGpuBlacklistFetchDelay,
- kCacheUpdateDelay) {
+ kCacheUpdateDelay),
+ gpu_blacklist_cache_(NULL) {
+ PrefService* local_state = g_browser_process->local_state();
+ // If we bring up chrome normally, prefs should never be NULL; however, we
+ // we handle the case where local_state == NULL for certain tests.
+ if (local_state) {
+ local_state->RegisterDictionaryPref(prefs::kGpuBlacklist);
+ gpu_blacklist_cache_ = local_state->GetDictionary(prefs::kGpuBlacklist);
+ DCHECK(gpu_blacklist_cache_);
+ }
+
+ LoadGpuBlacklist();
}
GpuBlacklistUpdater::~GpuBlacklistUpdater() { }
@@ -47,5 +64,62 @@ void GpuBlacklistUpdater::Unpack(const DictionaryValue& parsed_json) {
DCHECK(gpu_blacklist_cache);
gpu_blacklist_cache->Clear();
gpu_blacklist_cache->MergeDictionary(&parsed_json);
+
+ LoadGpuBlacklist();
}
+void GpuBlacklistUpdater::LoadGpuBlacklist() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ scoped_ptr<GpuBlacklist> gpu_blacklist;
+ // We first load it from the browser resources, and then check if the cached
+ // version is more up-to-date.
+ static const base::StringPiece gpu_blacklist_json(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_GPU_BLACKLIST));
+ chrome::VersionInfo version_info;
+ std::string chrome_version_string =
+ version_info.is_valid() ? version_info.Version() : "0";
+ gpu_blacklist.reset(new GpuBlacklist(chrome_version_string));
+ if (!gpu_blacklist->LoadGpuBlacklist(gpu_blacklist_json.as_string(), true))
+ return;
+
+ uint16 version_major, version_minor;
+ bool succeed = gpu_blacklist->GetVersion(&version_major, &version_minor);
+ DCHECK(succeed);
+ VLOG(1) << "Using software rendering list version "
+ << version_major << "." << version_minor;
+
+ if (gpu_blacklist_cache_) {
+ uint16 cached_version_major, cached_version_minor;
+ if (GpuBlacklist::GetVersion(*gpu_blacklist_cache_,
+ &cached_version_major,
+ &cached_version_minor)) {
+ if (gpu_blacklist.get() != NULL) {
+ uint16 current_version_major, current_version_minor;
+ if (gpu_blacklist->GetVersion(&current_version_major,
+ &current_version_minor) &&
+ (cached_version_major > current_version_major ||
+ (cached_version_major == current_version_major &&
+ cached_version_minor > current_version_minor))) {
+ chrome::VersionInfo version_info;
+ std::string chrome_version_string =
+ version_info.is_valid() ? version_info.Version() : "0";
+ GpuBlacklist* updated_list = new GpuBlacklist(chrome_version_string);
+ if (updated_list->LoadGpuBlacklist(*gpu_blacklist_cache_, true)) {
+ gpu_blacklist.reset(updated_list);
+ VLOG(1) << "Using software rendering list version "
+ << cached_version_major << "." << cached_version_minor;
+ } else {
+ delete updated_list;
+ }
+ }
+ }
+ }
+ }
+
+ // Need to initialize GpuDataManager to load the current GPU blacklist,
+ // collect preliminary GPU info, and run through GPU blacklist.
+ GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance();
+ gpu_data_manager->UpdateGpuBlacklist(gpu_blacklist.release());
+}
diff --git a/chrome/browser/web_resource/gpu_blacklist_updater.h b/chrome/browser/web_resource/gpu_blacklist_updater.h
index 136fd72..21ccdf9 100644
--- a/chrome/browser/web_resource/gpu_blacklist_updater.h
+++ b/chrome/browser/web_resource/gpu_blacklist_updater.h
@@ -8,6 +8,9 @@
#include "chrome/browser/web_resource/web_resource_service.h"
+class DictionaryValue;
+class GpuBlacklist;
+
class GpuBlacklistUpdater
: public WebResourceService {
public:
@@ -21,6 +24,12 @@ class GpuBlacklistUpdater
virtual void Unpack(const DictionaryValue& parsed_json);
+ void LoadGpuBlacklist();
+
+ // This is the version cached in local state that's automatically updated
+ // from the web.
+ const DictionaryValue* gpu_blacklist_cache_;
+
DISALLOW_COPY_AND_ASSIGN(GpuBlacklistUpdater);
};