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

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

Issue 10454086: Histograms - Support histograms for Plugins, GPU (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/about_ui.h" 5 #include "chrome/browser/ui/webui/about_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/i18n/number_formatting.h" 17 #include "base/i18n/number_formatting.h"
18 #include "base/json/json_writer.h" 18 #include "base/json/json_writer.h"
19 #include "base/memory/ref_counted_memory.h" 19 #include "base/memory/ref_counted_memory.h"
20 #include "base/memory/singleton.h" 20 #include "base/memory/singleton.h"
21 #include "base/metrics/histogram.h"
22 #include "base/metrics/stats_table.h" 21 #include "base/metrics/stats_table.h"
23 #include "base/path_service.h" 22 #include "base/path_service.h"
24 #include "base/string_number_conversions.h" 23 #include "base/string_number_conversions.h"
25 #include "base/string_piece.h" 24 #include "base/string_piece.h"
26 #include "base/string_util.h" 25 #include "base/string_util.h"
27 #include "base/stringprintf.h" 26 #include "base/stringprintf.h"
28 #include "base/threading/thread.h" 27 #include "base/threading/thread.h"
29 #include "base/utf_string_conversions.h" 28 #include "base/utf_string_conversions.h"
30 #include "base/values.h" 29 #include "base/values.h"
31 #include "chrome/browser/about_flags.h" 30 #include "chrome/browser/about_flags.h"
32 #include "chrome/browser/browser_about_handler.h" 31 #include "chrome/browser/browser_about_handler.h"
33 #include "chrome/browser/browser_process.h" 32 #include "chrome/browser/browser_process.h"
34 #include "chrome/browser/defaults.h" 33 #include "chrome/browser/defaults.h"
35 #include "chrome/browser/memory_details.h" 34 #include "chrome/browser/memory_details.h"
36 #include "chrome/browser/metrics/histogram_synchronizer.h"
37 #include "chrome/browser/net/predictor.h" 35 #include "chrome/browser/net/predictor.h"
38 #include "chrome/browser/net/url_fixer_upper.h" 36 #include "chrome/browser/net/url_fixer_upper.h"
39 #include "chrome/browser/plugin_prefs.h" 37 #include "chrome/browser/plugin_prefs.h"
40 #include "chrome/browser/profiles/profile.h" 38 #include "chrome/browser/profiles/profile.h"
41 #include "chrome/browser/profiles/profile_manager.h" 39 #include "chrome/browser/profiles/profile_manager.h"
42 #include "chrome/browser/ui/browser_dialogs.h" 40 #include "chrome/browser/ui/browser_dialogs.h"
43 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 41 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
44 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 42 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
45 #include "chrome/common/chrome_paths.h" 43 #include "chrome/common/chrome_paths.h"
46 #include "chrome/common/chrome_version_info.h" 44 #include "chrome/common/chrome_version_info.h"
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 791
794 // Where the results are fed to. 792 // Where the results are fed to.
795 scoped_refptr<AboutUIHTMLSource> source_; 793 scoped_refptr<AboutUIHTMLSource> source_;
796 794
797 // ID identifying the request. 795 // ID identifying the request.
798 int request_id_; 796 int request_id_;
799 797
800 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); 798 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler);
801 }; 799 };
802 800
803 std::string AboutHistograms(const std::string& query) {
804 TimeDelta wait_time = TimeDelta::FromMilliseconds(10000);
805
806 #ifndef NDEBUG
807 base::StatisticsRecorder::CollectHistogramStats("Browser");
808 #endif
809
810 HistogramSynchronizer* current_synchronizer =
811 HistogramSynchronizer::CurrentSynchronizer();
812 DCHECK(current_synchronizer != NULL);
813 current_synchronizer->FetchRendererHistogramsSynchronously(wait_time);
814
815 std::string unescaped_query;
816 std::string unescaped_title("About Histograms");
817 if (!query.empty()) {
818 unescaped_query = net::UnescapeURLComponent(query,
819 net::UnescapeRule::NORMAL);
820 unescaped_title += " - " + unescaped_query;
821 }
822
823 std::string data;
824 AppendHeader(&data, 0, unescaped_title);
825 AppendBody(&data);
826 base::StatisticsRecorder::WriteHTMLGraph(unescaped_query, &data);
827 AppendFooter(&data);
828 return data;
829 }
830
831 void FinishMemoryDataRequest(const std::string& path, 801 void FinishMemoryDataRequest(const std::string& path,
832 AboutUIHTMLSource* source, 802 AboutUIHTMLSource* source,
833 int request_id) { 803 int request_id) {
834 if (path == kStringsJsPath) { 804 if (path == kStringsJsPath) {
835 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want 805 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want
836 // the refcount to be greater than 0. 806 // the refcount to be greater than 0.
837 scoped_refptr<AboutMemoryHandler> 807 scoped_refptr<AboutMemoryHandler>
838 handler(new AboutMemoryHandler(source, request_id)); 808 handler(new AboutMemoryHandler(source, request_id));
839 // TODO(jamescook): Maybe this shouldn't update UMA? 809 // TODO(jamescook): Maybe this shouldn't update UMA?
840 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); 810 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS);
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 } else if (host == chrome::kChromeUIDiscardsHost) { 1369 } else if (host == chrome::kChromeUIDiscardsHost) {
1400 response = AboutDiscards(path); 1370 response = AboutDiscards(path);
1401 #endif 1371 #endif
1402 #if defined(USE_ASH) 1372 #if defined(USE_ASH)
1403 } else if (host == chrome::kChromeUITransparencyHost) { 1373 } else if (host == chrome::kChromeUITransparencyHost) {
1404 response = AboutTransparency(path); 1374 response = AboutTransparency(path);
1405 #endif 1375 #endif
1406 } else if (host == chrome::kChromeUIDNSHost) { 1376 } else if (host == chrome::kChromeUIDNSHost) {
1407 AboutDnsHandler::Start(this, request_id); 1377 AboutDnsHandler::Start(this, request_id);
1408 return; 1378 return;
1409 } else if (host == chrome::kChromeUIHistogramsHost) {
1410 response = AboutHistograms(path);
1411 #if defined(OS_LINUX) || defined(OS_OPENBSD) 1379 #if defined(OS_LINUX) || defined(OS_OPENBSD)
1412 } else if (host == chrome::kChromeUILinuxProxyConfigHost) { 1380 } else if (host == chrome::kChromeUILinuxProxyConfigHost) {
1413 response = AboutLinuxProxyConfig(); 1381 response = AboutLinuxProxyConfig();
1414 #endif 1382 #endif
1415 } else if (host == chrome::kChromeUIMemoryHost) { 1383 } else if (host == chrome::kChromeUIMemoryHost) {
1416 response = GetAboutMemoryRedirectResponse(profile()); 1384 response = GetAboutMemoryRedirectResponse(profile());
1417 } else if (host == chrome::kChromeUIMemoryRedirectHost) { 1385 } else if (host == chrome::kChromeUIMemoryRedirectHost) {
1418 FinishMemoryDataRequest(path, this, request_id); 1386 FinishMemoryDataRequest(path, this, request_id);
1419 return; 1387 return;
1420 #if defined(OS_CHROMEOS) 1388 #if defined(OS_CHROMEOS)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 1440
1473 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) 1441 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name)
1474 : WebUIController(web_ui) { 1442 : WebUIController(web_ui) {
1475 Profile* profile = Profile::FromWebUI(web_ui); 1443 Profile* profile = Profile::FromWebUI(web_ui);
1476 ChromeURLDataManager::DataSource* source = 1444 ChromeURLDataManager::DataSource* source =
1477 new AboutUIHTMLSource(name, profile); 1445 new AboutUIHTMLSource(name, profile);
1478 if (source) { 1446 if (source) {
1479 ChromeURLDataManager::AddDataSource(profile, source); 1447 ChromeURLDataManager::AddDataSource(profile, source);
1480 } 1448 }
1481 } 1449 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698