summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_resource
diff options
context:
space:
mode:
authorzmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-25 18:58:11 +0000
committerzmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-25 18:58:11 +0000
commit07c0b6d39b5b44ddcaec214248638b1aa9bb8c16 (patch)
tree1b691ee23676b1f6f5bc442f0c32e0e497405846 /chrome/browser/web_resource
parent242c4bd36b82138f6ab7b2dea12b7d31830b0560 (diff)
downloadchromium_src-07c0b6d39b5b44ddcaec214248638b1aa9bb8c16.zip
chromium_src-07c0b6d39b5b44ddcaec214248638b1aa9bb8c16.tar.gz
chromium_src-07c0b6d39b5b44ddcaec214248638b1aa9bb8c16.tar.bz2
With this CL, GPU blacklist auto update from the web (before it ships together with chrome) is implemented. This allows us to blacklist bad GPU/drivers as soon as we discover them.
Note that this patch does not turn the auto update on. We will turn it on in a separate CL. BUG=68802 TEST=build bots all green Review URL: http://codereview.chromium.org/6469094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76075 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_resource')
-rw-r--r--chrome/browser/web_resource/gpu_blacklist_updater.cc51
-rw-r--r--chrome/browser/web_resource/gpu_blacklist_updater.h28
-rw-r--r--chrome/browser/web_resource/promo_resource_service.cc2
-rw-r--r--chrome/browser/web_resource/web_resource_service.cc9
-rw-r--r--chrome/browser/web_resource/web_resource_service.h3
5 files changed, 90 insertions, 3 deletions
diff --git a/chrome/browser/web_resource/gpu_blacklist_updater.cc b/chrome/browser/web_resource/gpu_blacklist_updater.cc
new file mode 100644
index 0000000..ca297a1
--- /dev/null
+++ b/chrome/browser/web_resource/gpu_blacklist_updater.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2011 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/web_resource/gpu_blacklist_updater.h"
+
+#include "base/values.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/notification_type.h"
+#include "chrome/common/pref_names.h"
+
+namespace {
+
+// Delay on first fetch so we don't interfere with startup.
+static const int kStartGpuBlacklistFetchDelay = 6000;
+
+// Delay between calls to update the gpu blacklist (48 hours).
+static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000;
+
+} // namespace
+
+const char* GpuBlacklistUpdater::kDefaultGpuBlacklistURL =
+ "http://cache.pack.google.com/edgedl/chrome/gpu/"
+ "software_rendering_list.json";
+
+GpuBlacklistUpdater::GpuBlacklistUpdater()
+ : WebResourceService(ProfileManager::GetDefaultProfile(),
+ g_browser_process->local_state(),
+ GpuBlacklistUpdater::kDefaultGpuBlacklistURL,
+ false, // don't append locale to URL
+ NotificationType::NOTIFICATION_TYPE_COUNT,
+ prefs::kGpuBlacklistUpdate,
+ kStartGpuBlacklistFetchDelay,
+ kCacheUpdateDelay) {
+}
+
+GpuBlacklistUpdater::~GpuBlacklistUpdater() { }
+
+void GpuBlacklistUpdater::Unpack(const DictionaryValue& parsed_json) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DictionaryValue* gpu_blacklist_cache =
+ prefs_->GetMutableDictionary(prefs::kGpuBlacklist);
+ DCHECK(gpu_blacklist_cache);
+ gpu_blacklist_cache->Clear();
+ gpu_blacklist_cache->MergeDictionary(&parsed_json);
+}
+
diff --git a/chrome/browser/web_resource/gpu_blacklist_updater.h b/chrome/browser/web_resource/gpu_blacklist_updater.h
new file mode 100644
index 0000000..136fd72
--- /dev/null
+++ b/chrome/browser/web_resource/gpu_blacklist_updater.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2011 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_WEB_RESOURCE_GPU_BLACKLIST_UPDATER_H_
+#define CHROME_BROWSER_WEB_RESOURCE_GPU_BLACKLIST_UPDATER_H_
+#pragma once
+
+#include "chrome/browser/web_resource/web_resource_service.h"
+
+class GpuBlacklistUpdater
+ : public WebResourceService {
+ public:
+ explicit GpuBlacklistUpdater();
+
+ // URL of the up-to-date gpu_blacklist.json file.
+ static const char* kDefaultGpuBlacklistURL;
+
+ private:
+ virtual ~GpuBlacklistUpdater();
+
+ virtual void Unpack(const DictionaryValue& parsed_json);
+
+ DISALLOW_COPY_AND_ASSIGN(GpuBlacklistUpdater);
+};
+
+#endif // CHROME_BROWSER_WEB_RESOURCE_GPU_BLACKLIST_UPDATER_H_
+
diff --git a/chrome/browser/web_resource/promo_resource_service.cc b/chrome/browser/web_resource/promo_resource_service.cc
index f694563..30a2c74 100644
--- a/chrome/browser/web_resource/promo_resource_service.cc
+++ b/chrome/browser/web_resource/promo_resource_service.cc
@@ -53,6 +53,7 @@ const char* PromoResourceService::kDefaultPromoResourceServer =
PromoResourceService::PromoResourceService(Profile* profile)
: WebResourceService(profile,
+ profile->GetPrefs(),
PromoResourceService::kDefaultPromoResourceServer,
true, // append locale to URL
NotificationType::PROMO_RESOURCE_STATE_CHANGED,
@@ -66,7 +67,6 @@ PromoResourceService::PromoResourceService(Profile* profile)
PromoResourceService::~PromoResourceService() { }
void PromoResourceService::Init() {
- prefs_->RegisterStringPref(prefs::kNTPPromoResourceCacheUpdate, "0");
prefs_->RegisterDoublePref(prefs::kNTPCustomLogoStart, 0);
prefs_->RegisterDoublePref(prefs::kNTPCustomLogoEnd, 0);
prefs_->RegisterDoublePref(prefs::kNTPPromoStart, 0);
diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc
index daddae7..1026651 100644
--- a/chrome/browser/web_resource/web_resource_service.cc
+++ b/chrome/browser/web_resource/web_resource_service.cc
@@ -198,13 +198,15 @@ class WebResourceService::UnpackerClient
WebResourceService::WebResourceService(
Profile* profile,
+ PrefService* prefs,
const char* web_resource_server,
bool apply_locale_to_url,
NotificationType::Type notification_type,
const char* last_update_time_pref_name,
int start_fetch_delay,
int cache_update_delay)
- : profile_(profile),
+ : prefs_(prefs),
+ profile_(profile),
ALLOW_THIS_IN_INITIALIZER_LIST(service_factory_(this)),
in_fetch_(false),
web_resource_server_(web_resource_server),
@@ -214,8 +216,9 @@ WebResourceService::WebResourceService(
start_fetch_delay_(start_fetch_delay),
cache_update_delay_(cache_update_delay),
web_resource_update_scheduled_(false) {
+ DCHECK(prefs);
DCHECK(profile);
- prefs_ = profile_->GetPrefs();
+ prefs_->RegisterStringPref(last_update_time_pref_name, "0");
resource_dispatcher_host_ = g_browser_process->resource_dispatcher_host();
web_resource_fetcher_.reset(new WebResourceFetcher(this));
}
@@ -247,6 +250,8 @@ void WebResourceService::OnWebResourceUnpacked(
void WebResourceService::WebResourceStateChange() {
web_resource_update_scheduled_ = false;
+ if (notification_type_ == NotificationType::NOTIFICATION_TYPE_COUNT)
+ return;
NotificationService* service = NotificationService::current();
service->Notify(notification_type_,
Source<WebResourceService>(this),
diff --git a/chrome/browser/web_resource/web_resource_service.h b/chrome/browser/web_resource/web_resource_service.h
index 1b4b680..64c37e6 100644
--- a/chrome/browser/web_resource/web_resource_service.h
+++ b/chrome/browser/web_resource/web_resource_service.h
@@ -19,7 +19,10 @@ class Profile;
class WebResourceService
: public UtilityProcessHost::Client {
public:
+ // Pass notification_type = NOTIFICATION_TYPE_COUNT if notification is not
+ // required.
WebResourceService(Profile* profile,
+ PrefService* prefs,
const char* web_resource_server,
bool apply_locale_to_url_,
NotificationType::Type notification_type,