| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/web_resource/gpu_blacklist_updater.h" | 5 #include "chrome/browser/web_resource/gpu_blacklist_updater.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 11 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/chrome_version_info.h" | 15 #include "chrome/common/chrome_version_info.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "content/browser/browser_thread.h" | 17 #include "content/browser/browser_thread.h" |
| 17 #include "content/browser/gpu/gpu_blacklist.h" | 18 #include "content/browser/gpu/gpu_blacklist.h" |
| 18 #include "content/browser/gpu/gpu_data_manager.h" | 19 #include "content/browser/gpu/gpu_data_manager.h" |
| 19 #include "content/common/notification_type.h" | |
| 20 #include "grit/browser_resources.h" | 20 #include "grit/browser_resources.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Delay on first fetch so we don't interfere with startup. | 25 // Delay on first fetch so we don't interfere with startup. |
| 26 static const int kStartGpuBlacklistFetchDelay = 6000; | 26 static const int kStartGpuBlacklistFetchDelay = 6000; |
| 27 | 27 |
| 28 // Delay between calls to update the gpu blacklist (48 hours). | 28 // Delay between calls to update the gpu blacklist (48 hours). |
| 29 static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000; | 29 static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000; |
| 30 | 30 |
| 31 std::string GetChromeVersionString() { | 31 std::string GetChromeVersionString() { |
| 32 chrome::VersionInfo version_info; | 32 chrome::VersionInfo version_info; |
| 33 return version_info.is_valid() ? version_info.Version() : "0"; | 33 return version_info.is_valid() ? version_info.Version() : "0"; |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace anonymous | 36 } // namespace anonymous |
| 37 | 37 |
| 38 const char* GpuBlacklistUpdater::kDefaultGpuBlacklistURL = | 38 const char* GpuBlacklistUpdater::kDefaultGpuBlacklistURL = |
| 39 "https://dl.google.com/dl/edgedl/chrome/gpu/software_rendering_list.json"; | 39 "https://dl.google.com/dl/edgedl/chrome/gpu/software_rendering_list.json"; |
| 40 | 40 |
| 41 GpuBlacklistUpdater::GpuBlacklistUpdater() | 41 GpuBlacklistUpdater::GpuBlacklistUpdater() |
| 42 : WebResourceService(g_browser_process->local_state(), | 42 : WebResourceService(g_browser_process->local_state(), |
| 43 GpuBlacklistUpdater::kDefaultGpuBlacklistURL, | 43 GpuBlacklistUpdater::kDefaultGpuBlacklistURL, |
| 44 false, // don't append locale to URL | 44 false, // don't append locale to URL |
| 45 NotificationType::NOTIFICATION_TYPE_COUNT, | 45 chrome::NOTIFICATION_CHROME_END, |
| 46 prefs::kGpuBlacklistUpdate, | 46 prefs::kGpuBlacklistUpdate, |
| 47 kStartGpuBlacklistFetchDelay, | 47 kStartGpuBlacklistFetchDelay, |
| 48 kCacheUpdateDelay) { | 48 kCacheUpdateDelay) { |
| 49 prefs_->RegisterDictionaryPref(prefs::kGpuBlacklist); | 49 prefs_->RegisterDictionaryPref(prefs::kGpuBlacklist); |
| 50 InitializeGpuBlacklist(); | 50 InitializeGpuBlacklist(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 GpuBlacklistUpdater::~GpuBlacklistUpdater() { } | 53 GpuBlacklistUpdater::~GpuBlacklistUpdater() { } |
| 54 | 54 |
| 55 void GpuBlacklistUpdater::Unpack(const DictionaryValue& parsed_json) { | 55 void GpuBlacklistUpdater::Unpack(const DictionaryValue& parsed_json) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 82 const DictionaryValue& gpu_blacklist_cache, bool preliminary) { | 82 const DictionaryValue& gpu_blacklist_cache, bool preliminary) { |
| 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 84 | 84 |
| 85 scoped_ptr<GpuBlacklist> gpu_blacklist( | 85 scoped_ptr<GpuBlacklist> gpu_blacklist( |
| 86 new GpuBlacklist(GetChromeVersionString())); | 86 new GpuBlacklist(GetChromeVersionString())); |
| 87 if (gpu_blacklist->LoadGpuBlacklist(gpu_blacklist_cache, true)) { | 87 if (gpu_blacklist->LoadGpuBlacklist(gpu_blacklist_cache, true)) { |
| 88 GpuDataManager::GetInstance()->UpdateGpuBlacklist( | 88 GpuDataManager::GetInstance()->UpdateGpuBlacklist( |
| 89 gpu_blacklist.release(), preliminary); | 89 gpu_blacklist.release(), preliminary); |
| 90 } | 90 } |
| 91 } | 91 } |
| OLD | NEW |