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

Side by Side Diff: chrome/browser/ui/webui/flash_ui.cc

Issue 7058058: Update Flash diagnostics page to output when GPU process is not allowed to run and to prevent han... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/webui/flash_ui.h" 5 #include "chrome/browser/ui/webui/flash_ui.h"
6 6
7 #include "base/i18n/time_formatting.h" 7 #include "base/i18n/time_formatting.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "base/timer.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/crash_upload_list.h" 13 #include "chrome/browser/crash_upload_list.h"
13 #include "chrome/browser/platform_util.h" 14 #include "chrome/browser/platform_util.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
16 #include "chrome/browser/ui/webui/crashes_ui.h" 17 #include "chrome/browser/ui/webui/crashes_ui.h"
17 #include "chrome/common/chrome_version_info.h" 18 #include "chrome/common/chrome_version_info.h"
18 #include "chrome/common/jstemplate_builder.h" 19 #include "chrome/common/jstemplate_builder.h"
19 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
20 #include "content/browser/gpu/gpu_data_manager.h" 21 #include "content/browser/gpu/gpu_data_manager.h"
21 #include "content/browser/tab_contents/tab_contents.h" 22 #include "content/browser/tab_contents/tab_contents.h"
22 #include "content/browser/user_metrics.h" 23 #include "content/browser/user_metrics.h"
23 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
24 #include "grit/browser_resources.h" 25 #include "grit/browser_resources.h"
25 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
26 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
27 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
29 #include "webkit/glue/plugins/plugin_list.h" 30 #include "webkit/glue/plugins/plugin_list.h"
30 #include "webkit/plugins/npapi/webplugininfo.h" 31 #include "webkit/plugins/npapi/webplugininfo.h"
31 32
32 #if defined(OS_WIN) 33 #if defined(OS_WIN)
33 #include "base/win/windows_version.h" 34 #include "base/win/windows_version.h"
34 #endif 35 #endif
35 36
36 namespace { 37 namespace {
37 38
39 const int kTimeout = 8 * 1000; // 8 seconds.
40
38 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
39 // 42 //
40 // FlashUIHTMLSource 43 // FlashUIHTMLSource
41 // 44 //
42 //////////////////////////////////////////////////////////////////////////////// 45 ////////////////////////////////////////////////////////////////////////////////
43 46
44 class FlashUIHTMLSource : public ChromeURLDataManager::DataSource { 47 class FlashUIHTMLSource : public ChromeURLDataManager::DataSource {
45 public: 48 public:
46 FlashUIHTMLSource() 49 FlashUIHTMLSource()
47 : DataSource(chrome::kChromeUIFlashHost, MessageLoop::current()) {} 50 : DataSource(chrome::kChromeUIFlashHost, MessageLoop::current()) {}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void HandleRequestFlashInfo(const ListValue* args); 113 void HandleRequestFlashInfo(const ListValue* args);
111 114
112 // Callback for the GPU information update. 115 // Callback for the GPU information update.
113 void OnGpuInfoUpdate(); 116 void OnGpuInfoUpdate();
114 117
115 private: 118 private:
116 // Called when we think we might have enough information to return data back 119 // Called when we think we might have enough information to return data back
117 // to the page. 120 // to the page.
118 void MaybeRespondToPage(); 121 void MaybeRespondToPage();
119 122
123 // In certain cases we might not get called back from the GPU process so we
124 // set an upper limit on the time we wait. This function gets called when the
125 // time has passed. This actually doesn't prevent the rest of the information
126 // to appear later, the page will just reflow when more information becomes
127 // available.
128 void OnTimeout();
129
130 // A timer to keep track of when the data fetching times out.
131 base::OneShotTimer<FlashDOMHandler> timeout_;
132
120 // GPU variables. 133 // GPU variables.
121 GpuDataManager* gpu_data_manager_; 134 GpuDataManager* gpu_data_manager_;
122 Callback0::Type* gpu_info_update_callback_; 135 Callback0::Type* gpu_info_update_callback_;
123 136
124 // Crash list. 137 // Crash list.
125 scoped_refptr<CrashUploadList> upload_list_; 138 scoped_refptr<CrashUploadList> upload_list_;
126 139
127 // Whether the list of all crashes is available. 140 // Whether the list of all crashes is available.
128 bool crash_list_available_; 141 bool crash_list_available_;
129 // Whether the page has requested data. 142 // Whether the page has requested data.
(...skipping 15 matching lines...) Expand all
145 // Watch for changes in GPUInfo. 158 // Watch for changes in GPUInfo.
146 gpu_data_manager_ = GpuDataManager::GetInstance(); 159 gpu_data_manager_ = GpuDataManager::GetInstance();
147 gpu_info_update_callback_ = 160 gpu_info_update_callback_ =
148 NewCallback(this, &FlashDOMHandler::OnGpuInfoUpdate); 161 NewCallback(this, &FlashDOMHandler::OnGpuInfoUpdate);
149 gpu_data_manager_->AddGpuInfoUpdateCallback(gpu_info_update_callback_); 162 gpu_data_manager_->AddGpuInfoUpdateCallback(gpu_info_update_callback_);
150 163
151 // Tell GpuDataManager it should have full GpuInfo. If the 164 // Tell GpuDataManager it should have full GpuInfo. If the
152 // GPU process has not run yet, this will trigger its launch. 165 // GPU process has not run yet, this will trigger its launch.
153 gpu_data_manager_->RequestCompleteGpuInfoIfNeeded(); 166 gpu_data_manager_->RequestCompleteGpuInfoIfNeeded();
154 167
155 const GPUInfo& gpu_info = gpu_data_manager_->gpu_info(); 168 // GPU access might not be allowed at all, which will cause us not to get a
156 if (gpu_info.finalized) 169 // call back.
170 if (!gpu_data_manager_->GpuAccessAllowed())
157 OnGpuInfoUpdate(); 171 OnGpuInfoUpdate();
172
173 // And lastly, we fire off a timer to make sure we never get stuck at the
174 // "Loading..." message.
175 timeout_.Start(base::TimeDelta::FromMilliseconds(kTimeout),
176 this, &FlashDOMHandler::OnTimeout);
158 } 177 }
159 178
160 void FlashDOMHandler::RegisterMessages() { 179 void FlashDOMHandler::RegisterMessages() {
161 web_ui_->RegisterMessageCallback("requestFlashInfo", 180 web_ui_->RegisterMessageCallback("requestFlashInfo",
162 NewCallback(this, &FlashDOMHandler::HandleRequestFlashInfo)); 181 NewCallback(this, &FlashDOMHandler::HandleRequestFlashInfo));
163 } 182 }
164 183
165 void FlashDOMHandler::OnCrashListAvailable() { 184 void FlashDOMHandler::OnCrashListAvailable() {
166 crash_list_available_ = true; 185 crash_list_available_ = true;
167 MaybeRespondToPage(); 186 MaybeRespondToPage();
(...skipping 13 matching lines...) Expand all
181 void FlashDOMHandler::HandleRequestFlashInfo(const ListValue* args) { 200 void FlashDOMHandler::HandleRequestFlashInfo(const ListValue* args) {
182 page_has_requested_data_ = true; 201 page_has_requested_data_ = true;
183 MaybeRespondToPage(); 202 MaybeRespondToPage();
184 } 203 }
185 204
186 void FlashDOMHandler::OnGpuInfoUpdate() { 205 void FlashDOMHandler::OnGpuInfoUpdate() {
187 has_gpu_info_ = true; 206 has_gpu_info_ = true;
188 MaybeRespondToPage(); 207 MaybeRespondToPage();
189 } 208 }
190 209
210 void FlashDOMHandler::OnTimeout() {
211 // We don't set page_has_requested_data_ because that is guaranteed to appear
212 // and we shouldn't be responding to the page before then.
213 has_gpu_info_ = true;
214 crash_list_available_ = true;
215 MaybeRespondToPage();
216 }
217
191 void FlashDOMHandler::MaybeRespondToPage() { 218 void FlashDOMHandler::MaybeRespondToPage() {
192 // We don't reply until everything is ready. The page is showing a 'loading' 219 // We don't reply until everything is ready. The page is showing a 'loading'
193 // message until then. 220 // message until then. If you add criteria to this list, please update the
221 // function OnTimeout() as well.
194 if (!page_has_requested_data_ || !crash_list_available_ || !has_gpu_info_) 222 if (!page_has_requested_data_ || !crash_list_available_ || !has_gpu_info_)
195 return; 223 return;
196 224
225 timeout_.Stop();
226
197 // This is code that runs only when the user types in about:flash. We don't 227 // This is code that runs only when the user types in about:flash. We don't
198 // need to jump through hoops to offload this to the IO thread. 228 // need to jump through hoops to offload this to the IO thread.
199 base::ThreadRestrictions::ScopedAllowIO allow_io; 229 base::ThreadRestrictions::ScopedAllowIO allow_io;
200 230
201 // Obtain the Chrome version info. 231 // Obtain the Chrome version info.
202 chrome::VersionInfo version_info; 232 chrome::VersionInfo version_info;
203 233
204 ListValue* list = new ListValue(); 234 ListValue* list = new ListValue();
205 235
206 // Chrome version information. 236 // Chrome version information.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 AddPair(list, ASCIIToUTF16("Crash Reporting"), 298 AddPair(list, ASCIIToUTF16("Crash Reporting"),
269 "Enable crash reporting to see crash IDs"); 299 "Enable crash reporting to see crash IDs");
270 AddPair(list, ASCIIToUTF16("For more details"), 300 AddPair(list, ASCIIToUTF16("For more details"),
271 chrome::kLearnMoreReportingURL); 301 chrome::kLearnMoreReportingURL);
272 } 302 }
273 303
274 // GPU information. 304 // GPU information.
275 AddPair(list, ASCIIToUTF16(""), "--- GPU information ---"); 305 AddPair(list, ASCIIToUTF16(""), "--- GPU information ---");
276 const GPUInfo& gpu_info = gpu_data_manager_->gpu_info(); 306 const GPUInfo& gpu_info = gpu_data_manager_->gpu_info();
277 307
308 if (!gpu_data_manager_->GpuAccessAllowed())
309 AddPair(list, ASCIIToUTF16("WARNING:"), "GPU access is not allowed");
278 #if defined(OS_WIN) 310 #if defined(OS_WIN)
279 const DxDiagNode& node = gpu_info.dx_diagnostics; 311 const DxDiagNode& node = gpu_info.dx_diagnostics;
280 for (std::map<std::string, DxDiagNode>::const_iterator it = 312 for (std::map<std::string, DxDiagNode>::const_iterator it =
281 node.children.begin(); 313 node.children.begin();
282 it != node.children.end(); 314 it != node.children.end();
283 ++it) { 315 ++it) {
284 for (std::map<std::string, std::string>::const_iterator it2 = 316 for (std::map<std::string, std::string>::const_iterator it2 =
285 it->second.values.begin(); 317 it->second.values.begin();
286 it2 != it->second.values.end(); 318 it2 != it->second.values.end();
287 ++it2) { 319 ++it2) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 375
344 // Set up the about:flash source. 376 // Set up the about:flash source.
345 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); 377 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
346 } 378 }
347 379
348 // static 380 // static
349 RefCountedMemory* FlashUI::GetFaviconResourceBytes() { 381 RefCountedMemory* FlashUI::GetFaviconResourceBytes() {
350 // Use the default icon for now. 382 // Use the default icon for now.
351 return NULL; 383 return NULL;
352 } 384 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698