0

Move gpu blacklist data file to content side.

This also fixes the bug that GPU histograms are missing.

BUG=151057
TEST=tree
R=jbauman
Review URL: https://codereview.chromium.org/10911315

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157851 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
zmo@google.com
2012-09-20 21:49:53 +00:00
parent 8d61c07b2b
commit 7e34315e05
23 changed files with 87 additions and 81 deletions

@ -149,7 +149,6 @@ class SingleTestRunner(BaseTestRunner):
test_files = [
'base/data/file_util_unittest',
'base/data/json/bom_feff.json',
'chrome/browser/resources/software_rendering_list.json',
'chrome/test/data/download-test1.lib',
'chrome/test/data/extensions/bad_magic.crx',
'chrome/test/data/extensions/good.crx',
@ -182,6 +181,7 @@ class SingleTestRunner(BaseTestRunner):
'chrome/test/data/webui/',
'chrome/test/data/zip',
'chrome/third_party/mock4js/',
'content/browser/gpu/software_rendering_list.json',
'net/data/cache_tests/insert_load1',
'net/data/cache_tests/dirty_entry5',
'net/data/ssl/certificates/',

@ -112,7 +112,6 @@
<include name="IDR_GAIA_LOGIN_HTML" file="sync\resources\gaia_login.html" flattenhtml="true" type="BINDATA" />
</if>
<include name="IDR_HELP_JS" file="resources\help\help.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_GPU_BLACKLIST" file="resources\software_rendering_list.json" type="BINDATA" />
<include name="IDR_GPU_INTERNALS_HTML" file="resources\gpu_internals\gpu_internals.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_GPU_INTERNALS_JS" file="resources\gpu_internals\gpu_internals.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_HISTORY_HTML" file="resources\history\history.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />

@ -34,7 +34,6 @@
#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"
@ -99,7 +98,6 @@
#include "chrome/common/profiling.h"
#include "chrome/installer/util/google_update_settings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h"
#include "content/public/common/main_function_params.h"
@ -1336,9 +1334,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
CloudPrintProxyServiceFactory::GetForProfile(profile_);
#endif
// Load GPU Blacklist; load preliminary GPU info.
gpu_util::InitializeGpuDataManager(parsed_command_line());
// Start watching all browser threads for responsiveness.
ThreadWatcherList::StartWatchingAll(parsed_command_line());

@ -16,8 +16,6 @@
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "grit/browser_resources.h"
#include "ui/base/resource/resource_bundle.h"
using content::GpuDataManager;
@ -122,27 +120,5 @@ void InitializeCompositingFieldTrial() {
UMA_HISTOGRAM_BOOLEAN("GPU.InCompositorThreadFieldTrial", thread);
}
// Load GPU Blacklist, collect preliminary gpu info, and compute preliminary
// gpu feature flags.
void InitializeGpuDataManager(const CommandLine& command_line) {
if (command_line.HasSwitch(switches::kSkipGpuDataLoading))
return;
std::string chrome_version_string = "0";
std::string gpu_blacklist_json_string;
if (!command_line.HasSwitch(switches::kIgnoreGpuBlacklist)) {
chrome::VersionInfo chrome_version_info;
if (chrome_version_info.is_valid())
chrome_version_string = chrome_version_info.Version();
const base::StringPiece gpu_blacklist_json(
ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE));
gpu_blacklist_json_string = gpu_blacklist_json.as_string();
}
content::GpuDataManager::GetInstance()->Initialize(
chrome_version_string, gpu_blacklist_json_string);
}
} // namespace gpu_util;

@ -5,17 +5,11 @@
#ifndef CHROME_BROWSER_CHROME_GPU_UTIL_H_
#define CHROME_BROWSER_CHROME_GPU_UTIL_H_
class CommandLine;
namespace gpu_util {
// Sets up force-compositing-mode and threaded compositing field trials.
void InitializeCompositingFieldTrial();
// Load GPU Blacklist, collect preliminary gpu info, and compute preliminary
// gpu feature flags.
void InitializeGpuDataManager(const CommandLine& command_line);
} // namespace gpu_util
#endif // CHROME_BROWSER_CHROME_GPU_UTIL_H_

@ -27,6 +27,7 @@
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/common/gpu_info.h"
#include "content/public/test/browser_test_utils.h"
#include "net/base/mock_host_resolver.h"
#include "ui/gl/gl_switches.h"
@ -447,7 +448,9 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebstoreGetWebGLStatusTest, Blocked) {
" }\n"
" ]\n"
"}";
content::GpuDataManager::GetInstance()->Initialize("0", json_blacklist);
content::GPUInfo gpu_info;
content::GpuDataManager::GetInstance()->InitializeForTesting(
json_blacklist, gpu_info);
GpuFeatureType type =
content::GpuDataManager::GetInstance()->GetBlacklistedFeatures();
EXPECT_EQ(type, content::GPU_FEATURE_TYPE_WEBGL);

@ -74,6 +74,7 @@
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/gpu_info.h"
#include "content/public/test/test_browser_thread.h"
#include "googleurl/src/gurl.h"
#include "grit/browser_resources.h"
@ -731,7 +732,9 @@ class ExtensionServiceTest
" }\n"
" ]\n"
"}";
content::GpuDataManager::GetInstance()->Initialize("0", json_blacklist);
content::GPUInfo gpu_info;
content::GpuDataManager::GetInstance()->InitializeForTesting(
json_blacklist, gpu_info);
}
void UpdateExtension(const std::string& id, const FilePath& in_path,

@ -20,6 +20,7 @@
#include "chrome/test/base/test_launcher_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/common/gpu_info.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gl/gl_switches.h"
@ -73,7 +74,9 @@ class RequirementsCheckerBrowserTest : public ExtensionBrowserTest {
" }\n"
" ]\n"
"}";
content::GpuDataManager::GetInstance()->Initialize("0", json_blacklist);
content::GPUInfo gpu_info;
content::GpuDataManager::GetInstance()->InitializeForTesting(
json_blacklist, gpu_info);
}
protected:

@ -778,9 +778,6 @@ const char kHostResolverRules[] = "host-resolver-rules";
// <profile_dir>/Default/TransportSecurity
const char kHstsHosts[] = "hsts-hosts";
// Ignores GPU blacklist.
const char kIgnoreGpuBlacklist[] = "ignore-gpu-blacklist";
// Performs importing from another browser. The value associated with this
// setting encodes the target browser and what items to import.
const char kImport[] = "import";

@ -210,7 +210,6 @@ extern const char kHostResolverParallelism[];
extern const char kHostResolverRetryAttempts[];
extern const char kHostResolverRules[];
extern const char kHstsHosts[];
extern const char kIgnoreGpuBlacklist[];
extern const char kImport[];
extern const char kImportFromFile[];
extern const char kIncognito[];

@ -70,8 +70,8 @@ class GpuFeatureTest : public InProcessBrowserTest {
void SetupBlacklist(const std::string& json_blacklist) {
content::GPUInfo gpu_info;
GpuDataManager::GetInstance()->Initialize(
"0", json_blacklist, gpu_info);
GpuDataManager::GetInstance()->InitializeForTesting(
json_blacklist, gpu_info);
}
// If expected_reply is NULL, we don't check the reply content.

@ -106,7 +106,6 @@
'<(PRODUCT_DIR)/resources.pak',
'<(PRODUCT_DIR)/test_data/chrome/browser/resources/print_preview/print_preview_utils.js',
'<(PRODUCT_DIR)/unit_tests<(EXECUTABLE_SUFFIX)',
'browser/resources/software_rendering_list.json',
'test/data/History/ArchivedNoDuration',
'test/data/History/HistoryNoDuration',
'test/data/History/HistoryNoSource',

@ -20,6 +20,7 @@
#include "content/browser/download/save_file_manager.h"
#include "content/browser/gamepad/gamepad_service.h"
#include "content/browser/gpu/browser_gpu_channel_host_factory.h"
#include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/histogram_synchronizer.h"
@ -33,7 +34,6 @@
#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/browser_shutdown.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/gpu_data_manager.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
@ -454,8 +454,7 @@ void BrowserMainLoop::CreateThreads() {
// When running the GPU thread in-process, avoid optimistically starting it
// since creating the GPU thread races against creation of the one-and-only
// ChildProcess instance which is created by the renderer thread.
GpuDataManager* gpu_data_manager = content::GpuDataManager::GetInstance();
if (gpu_data_manager->GpuAccessAllowed() &&
if (GpuDataManagerImpl::GetInstance()->GpuAccessAllowed() &&
!parsed_command_line_.HasSwitch(switches::kDisableGpuProcessPrelaunch) &&
!parsed_command_line_.HasSwitch(switches::kSingleProcess) &&
!parsed_command_line_.HasSwitch(switches::kInProcessGPU)) {
@ -657,9 +656,9 @@ void BrowserMainLoop::BrowserThreadsStarted() {
// RDH needs the IO thread to be created.
resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl());
// Start the GpuDataManager before we set up the MessageLoops because
// Initialize the GpuDataManager before we set up the MessageLoops because
// otherwise we'll trigger the assertion about doing IO on the UI thread.
content::GpuDataManager::GetInstance();
GpuDataManagerImpl::GetInstance()->Initialize();
#endif // !OS_IOS
#if defined(ENABLE_INPUT_SPEECH)

@ -56,9 +56,9 @@ TEST_F(GpuBlacklistTest, CurrentBlacklistValidation) {
FilePath data_file;
ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_file));
data_file =
data_file.Append(FILE_PATH_LITERAL("chrome"))
data_file.Append(FILE_PATH_LITERAL("content"))
.Append(FILE_PATH_LITERAL("browser"))
.Append(FILE_PATH_LITERAL("resources"))
.Append(FILE_PATH_LITERAL("gpu"))
.Append(FILE_PATH_LITERAL("software_rendering_list.json"));
ASSERT_TRUE(file_util::PathExists(data_file));
int64 data_file_size64 = 0;

@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/string_piece.h"
#include "base/stringprintf.h"
#include "base/sys_info.h"
#include "base/values.h"
@ -20,6 +21,7 @@
#include "content/public/browser/gpu_data_manager_observer.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "grit/content_resources.h"
#include "ui/base/ui_base_switches.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_switches.h"
@ -34,6 +36,25 @@ using content::GpuDataManagerObserver;
using content::GpuFeatureType;
using content::GpuSwitchingOption;
namespace {
// Strip out the non-digital info; if after that, we get an empty string,
// return "0".
std::string ProcessVersionString(const std::string& raw_string) {
const std::string valid_set = "0123456789.";
size_t start_pos = raw_string.find_first_of(valid_set);
if (start_pos == std::string::npos)
return "0";
size_t end_pos = raw_string.find_first_not_of(raw_string, start_pos);
std::string version_string = raw_string.substr(
start_pos, end_pos - start_pos);
if (version_string.empty())
return "0";
return version_string;
}
} // namespace anonymous
// static
content::GpuDataManager* content::GpuDataManager::GetInstance() {
return GpuDataManagerImpl::GetInstance();
@ -62,9 +83,11 @@ GpuDataManagerImpl::GpuDataManagerImpl()
BlacklistCard();
}
void GpuDataManagerImpl::Initialize(
const std::string& browser_version_string,
const std::string& gpu_blacklist_json) {
void GpuDataManagerImpl::Initialize() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kSkipGpuDataLoading))
return;
content::GPUInfo gpu_info;
gpu_info_collector::CollectPreliminaryGraphicsInfo(&gpu_info);
#if defined(ARCH_CPU_X86_FAMILY)
@ -72,11 +95,27 @@ void GpuDataManagerImpl::Initialize(
gpu_info.finalized = true;
#endif
Initialize(browser_version_string, gpu_blacklist_json, gpu_info);
std::string gpu_blacklist_string;
if (!command_line->HasSwitch(switches::kIgnoreGpuBlacklist)) {
const base::StringPiece gpu_blacklist_json =
content::GetContentClient()->GetDataResource(
IDR_GPU_BLACKLIST, ui::SCALE_FACTOR_NONE);
gpu_blacklist_string = gpu_blacklist_json.as_string();
}
InitializeImpl(gpu_blacklist_string, gpu_info);
}
void GpuDataManagerImpl::Initialize(
const std::string& browser_version_string,
void GpuDataManagerImpl::InitializeForTesting(
const std::string& gpu_blacklist_json,
const content::GPUInfo& gpu_info) {
// This function is for testing only, so disable histograms.
update_histograms_ = false;
InitializeImpl(gpu_blacklist_json, gpu_info);
}
void GpuDataManagerImpl::InitializeImpl(
const std::string& gpu_blacklist_json,
const content::GPUInfo& gpu_info) {
{
@ -87,10 +126,9 @@ void GpuDataManagerImpl::Initialize(
gpu_info_ = empty_gpu_info;
}
// This function is for testing only, so disable histograms.
update_histograms_ = false;
if (!gpu_blacklist_json.empty()) {
std::string browser_version_string = ProcessVersionString(
content::GetContentClient()->GetProduct());
CHECK(!browser_version_string.empty());
gpu_blacklist_.reset(new GpuBlacklist());
bool succeed = gpu_blacklist_->LoadGpuBlacklist(

@ -30,11 +30,7 @@ class CONTENT_EXPORT GpuDataManagerImpl
static GpuDataManagerImpl* GetInstance();
// GpuDataManager implementation.
virtual void Initialize(
const std::string& browser_version_string,
const std::string& gpu_blacklist_json) OVERRIDE;
virtual void Initialize(
const std::string& browser_version_string,
virtual void InitializeForTesting(
const std::string& gpu_blacklist_json,
const content::GPUInfo& gpu_info) OVERRIDE;
virtual content::GpuFeatureType GetBlacklistedFeatures() const OVERRIDE;
@ -55,6 +51,11 @@ class CONTENT_EXPORT GpuDataManagerImpl
virtual void RemoveObserver(
content::GpuDataManagerObserver* observer) OVERRIDE;
// This collects preliminary GPU info, load GpuBlacklist, and compute the
// preliminary blacklisted features; it should only be called at browser
// startup time in UI thread before the IO restriction is turned on.
void Initialize();
// Only update if the current GPUInfo is not finalized. If blacklist is
// loaded, run through blacklist and update blacklisted features.
void UpdateGpuInfo(const content::GPUInfo& gpu_info);
@ -101,6 +102,9 @@ class CONTENT_EXPORT GpuDataManagerImpl
GpuDataManagerImpl();
virtual ~GpuDataManagerImpl();
void InitializeImpl(const std::string& gpu_blacklist_json,
const content::GPUInfo& gpu_info);
void UpdateBlacklistedFeatures(content::GpuFeatureType features);
// This should only be called once at initialization time, when preliminary

@ -96,7 +96,7 @@ TEST_F(GpuDataManagerImplTest, GpuSideBlacklisting) {
content::GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x10de;
gpu_info.gpu.device_id = 0x0640;
manager->Initialize("0", blacklist_json, gpu_info);
manager->InitializeForTesting(blacklist_json, gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed());
EXPECT_EQ(content::GPU_FEATURE_TYPE_WEBGL,
@ -143,7 +143,7 @@ TEST_F(GpuDataManagerImplTest, GpuSideExceptions) {
content::GPUInfo gpu_info;
gpu_info.gpu.vendor_id = 0x10de;
gpu_info.gpu.device_id = 0x0640;
manager->Initialize("0", blacklist_json, gpu_info);
manager->InitializeForTesting(blacklist_json, gpu_info);
EXPECT_TRUE(manager->GpuAccessAllowed());
EXPECT_EQ(content::GPU_FEATURE_TYPE_WEBGL,

@ -87,7 +87,7 @@
'content_browser.gypi',
],
'dependencies': [
'content_common',
'content_common', 'content_resources.gyp:content_resources',
],
},
{

@ -12,6 +12,7 @@
<release seq="1">
<includes>
<include name="IDR_DOM_AUTOMATION_JS" file="renderer/dom_automation.js" type="BINDATA" />
<include name="IDR_GPU_BLACKLIST" file="browser/gpu/software_rendering_list.json" type="BINDATA" />
<if expr="is_macosx">
<include name="IDR_GPU_SANDBOX_PROFILE" file="browser/gpu.sb" type="BINDATA" />
<include name="IDR_WORKER_SANDBOX_PROFILE" file="browser/worker.sb" type="BINDATA" />

@ -27,16 +27,8 @@ class GpuDataManager {
// Getter for the singleton.
CONTENT_EXPORT static GpuDataManager* GetInstance();
// This collects preliminary GPU info, load GpuBlacklist, and compute the
// preliminary blacklisted features; it should only be called at browser
// startup time in UI thread before the IO restriction is turned on.
virtual void Initialize(const std::string& browser_version_string,
const std::string& gpu_blacklist_json) = 0;
// The same as above, except that the GPUInfo is provided.
// For testing only.
virtual void Initialize(const std::string& browser_version_string,
const std::string& gpu_blacklist_json,
const content::GPUInfo& gpu_info) = 0;
virtual void InitializeForTesting(const std::string& gpu_blacklist_json,
const content::GPUInfo& gpu_info) = 0;
virtual std::string GetBlacklistVersion() const = 0;

@ -427,6 +427,9 @@ const char kGpuVendorID[] = "gpu-vendor-id";
// to run as a guest renderer instead of a regular renderer.
const char kGuestRenderer[] = "guest-renderer";
// Ignores GPU blacklist.
const char kIgnoreGpuBlacklist[] = "ignore-gpu-blacklist";
// Run the GPU process as a thread in the browser process.
const char kInProcessGPU[] = "in-process-gpu";

@ -136,6 +136,7 @@ CONTENT_EXPORT extern const char kGpuProcess[];
extern const char kGpuStartupDialog[];
extern const char kGpuVendorID[];
CONTENT_EXPORT extern const char kGuestRenderer[];
CONTENT_EXPORT extern const char kIgnoreGpuBlacklist[];
extern const char kInProcessGPU[];
extern const char kInProcessPlugins[];
CONTENT_EXPORT extern const char kInProcessWebGL[];