Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1073)

Side by Side Diff: chrome/browser/gpu_process_host.cc

Issue 6352011: Improve blacklist logic: use more fields (driver_vendor, gl_renderer, ect) fo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Added histogram improvement. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/gpu_process_host.h" 5 #include "chrome/browser/gpu_process_host.h"
6 6
7 #include "app/app_switches.h" 7 #include "app/app_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 21 matching lines...) Expand all
32 // These two #includes need to come after render_messages.h. 32 // These two #includes need to come after render_messages.h.
33 #include <gdk/gdkwindow.h> // NOLINT 33 #include <gdk/gdkwindow.h> // NOLINT
34 #include <gdk/gdkx.h> // NOLINT 34 #include <gdk/gdkx.h> // NOLINT
35 #include "gfx/gtk_native_view_id_manager.h" 35 #include "gfx/gtk_native_view_id_manager.h"
36 #include "gfx/size.h" 36 #include "gfx/size.h"
37 #include "ui/base/x/x11_util.h" 37 #include "ui/base/x/x11_util.h"
38 #endif // defined(OS_LINUX) 38 #endif // defined(OS_LINUX)
39 39
40 namespace { 40 namespace {
41 41
42 enum GPUBlacklistTestResult {
43 BLOCKED,
44 ALLOWED,
45 BLACKLIST_TEST_RESULT_MAX
46 };
47
48 enum GPUProcessLifetimeEvent { 42 enum GPUProcessLifetimeEvent {
49 LAUNCED, 43 LAUNCED,
50 CRASHED, 44 CRASHED,
51 GPU_PROCESS_LIFETIME_EVENT_MAX 45 GPU_PROCESS_LIFETIME_EVENT_MAX
52 }; 46 };
53 47
54 // Tasks used by this file 48 // Tasks used by this file
55 class RouteOnUIThreadTask : public Task { 49 class RouteOnUIThreadTask : public Task {
56 public: 50 public:
57 explicit RouteOnUIThreadTask(const IPC::Message& msg) : msg_(msg) { 51 explicit RouteOnUIThreadTask(const IPC::Message& msg) : msg_(msg) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 private: 104 private:
111 scoped_ptr<GpuThread> gpu_thread_; 105 scoped_ptr<GpuThread> gpu_thread_;
112 std::string channel_id_; 106 std::string channel_id_;
113 DISALLOW_COPY_AND_ASSIGN(GpuMainThread); 107 DISALLOW_COPY_AND_ASSIGN(GpuMainThread);
114 }; 108 };
115 109
116 GpuProcessHost::GpuProcessHost() 110 GpuProcessHost::GpuProcessHost()
117 : BrowserChildProcessHost(GPU_PROCESS, NULL), 111 : BrowserChildProcessHost(GPU_PROCESS, NULL),
118 initialized_(false), 112 initialized_(false),
119 initialized_successfully_(false), 113 initialized_successfully_(false),
120 blacklist_result_recorded_(false) { 114 gpu_feature_flags_set_(false) {
121 DCHECK_EQ(sole_instance_, static_cast<GpuProcessHost*>(NULL)); 115 DCHECK_EQ(sole_instance_, static_cast<GpuProcessHost*>(NULL));
122 } 116 }
123 117
124 GpuProcessHost::~GpuProcessHost() { 118 GpuProcessHost::~GpuProcessHost() {
125 while (!queued_synchronization_replies_.empty()) { 119 while (!queued_synchronization_replies_.empty()) {
126 delete queued_synchronization_replies_.front().reply; 120 delete queued_synchronization_replies_.front().reply;
127 queued_synchronization_replies_.pop(); 121 queued_synchronization_replies_.pop();
128 } 122 }
129 DCHECK_EQ(sole_instance_, this); 123 DCHECK_EQ(sole_instance_, this);
130 sole_instance_ = NULL; 124 sole_instance_ = NULL;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // handle it. 237 // handle it.
244 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) 238 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message))
245 IPC_END_MESSAGE_MAP() 239 IPC_END_MESSAGE_MAP()
246 240
247 return true; 241 return true;
248 } 242 }
249 243
250 void GpuProcessHost::OnChannelEstablished( 244 void GpuProcessHost::OnChannelEstablished(
251 const IPC::ChannelHandle& channel_handle, 245 const IPC::ChannelHandle& channel_handle,
252 const GPUInfo& gpu_info) { 246 const GPUInfo& gpu_info) {
253 GpuFeatureFlags gpu_feature_flags; 247 if (channel_handle.name.size() != 0 && !gpu_feature_flags_set_) {
254 if (channel_handle.name.size() != 0) { 248 gpu_feature_flags_ = gpu_blacklist_->DetermineGpuFeatureFlags(
255 gpu_feature_flags = gpu_blacklist_->DetermineGpuFeatureFlags(
256 GpuBlacklist::kOsAny, NULL, gpu_info); 249 GpuBlacklist::kOsAny, NULL, gpu_info);
250 gpu_feature_flags_set_ = true;
251 uint32 max_entry_id = gpu_blacklist_->max_entry_id();
252 if (gpu_feature_flags_.flags() != 0) {
253 std::vector<uint32> flag_entries;
254 gpu_blacklist_->GetGpuFeatureFlagEntries(GpuFeatureFlags::kGpuFeatureAll,
255 flag_entries);
256 DCHECK(flag_entries.size() > 0);
257 for (size_t i = 0; i < flag_entries.size(); ++i) {
258 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResults",
259 flag_entries[i], max_entry_id + 1);
260 }
261 } else {
262 // id 0 is never used by any entry, so we use it here to indicate that
263 // gpu is allowed.
264 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResults",
265 0, max_entry_id + 1);
266 }
257 } 267 }
258 const ChannelRequest& request = sent_requests_.front(); 268 const ChannelRequest& request = sent_requests_.front();
259 // Currently if any of the GPU features are blacklised, we don't establish a 269 // Currently if any of the GPU features are blacklised, we don't establish a
260 // GPU channel. 270 // GPU channel.
261 GPUBlacklistTestResult test_result; 271 if (gpu_feature_flags_.flags() != 0) {
262 if (gpu_feature_flags.flags() != 0) {
263 Send(new GpuMsg_CloseChannel(channel_handle)); 272 Send(new GpuMsg_CloseChannel(channel_handle));
264 SendEstablishChannelReply(IPC::ChannelHandle(), gpu_info, request.filter); 273 SendEstablishChannelReply(IPC::ChannelHandle(), gpu_info, request.filter);
265 test_result = BLOCKED;
266 } else { 274 } else {
267 SendEstablishChannelReply(channel_handle, gpu_info, request.filter); 275 SendEstablishChannelReply(channel_handle, gpu_info, request.filter);
268 test_result = ALLOWED;
269 }
270 if (!blacklist_result_recorded_) {
271 UMA_HISTOGRAM_ENUMERATION("GPU.BlacklistTestResults",
272 test_result, BLACKLIST_TEST_RESULT_MAX);
273 blacklist_result_recorded_ = true;
274 } 276 }
275 sent_requests_.pop(); 277 sent_requests_.pop();
276 } 278 }
277 279
278 void GpuProcessHost::OnSynchronizeReply() { 280 void GpuProcessHost::OnSynchronizeReply() {
279 // Guard against race conditions in abrupt GPU process termination. 281 // Guard against race conditions in abrupt GPU process termination.
280 if (queued_synchronization_replies_.size() > 0) { 282 if (queued_synchronization_replies_.size() > 0) {
281 const SynchronizationRequest& request = 283 const SynchronizationRequest& request =
282 queued_synchronization_replies_.front(); 284 queued_synchronization_replies_.front();
283 SendSynchronizationReply(request.reply, request.filter); 285 SendSynchronizationReply(request.reply, request.filter);
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 652 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
651 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) || 653 if (browser_command_line.HasSwitch(switches::kIgnoreGpuBlacklist) ||
652 blacklist->LoadGpuBlacklist(gpu_blacklist_json.as_string(), true)) { 654 blacklist->LoadGpuBlacklist(gpu_blacklist_json.as_string(), true)) {
653 gpu_blacklist_.reset(blacklist); 655 gpu_blacklist_.reset(blacklist);
654 return true; 656 return true;
655 } 657 }
656 delete blacklist; 658 delete blacklist;
657 return false; 659 return false;
658 } 660 }
659 661
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698