OLD | NEW |
---|---|
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 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 | 789 |
792 // Where the results are fed to. | 790 // Where the results are fed to. |
793 scoped_refptr<AboutUIHTMLSource> source_; | 791 scoped_refptr<AboutUIHTMLSource> source_; |
794 | 792 |
795 // ID identifying the request. | 793 // ID identifying the request. |
796 int request_id_; | 794 int request_id_; |
797 | 795 |
798 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); | 796 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); |
799 }; | 797 }; |
800 | 798 |
801 std::string AboutHistograms(const std::string& query) { | |
802 TimeDelta wait_time = TimeDelta::FromMilliseconds(10000); | |
803 | |
804 #ifndef NDEBUG | |
805 base::StatisticsRecorder::CollectHistogramStats("Browser"); | |
jar (doing other things)
2012/07/09 23:04:12
Please modify the XML file to show these histogram
ramant (doing other things)
2012/07/11 23:52:54
Submitting a separate CL for XML changes.
Done.
| |
806 #endif | |
807 | |
808 HistogramSynchronizer* current_synchronizer = | |
809 HistogramSynchronizer::CurrentSynchronizer(); | |
810 DCHECK(current_synchronizer != NULL); | |
811 current_synchronizer->FetchRendererHistogramsSynchronously(wait_time); | |
812 | |
813 std::string unescaped_query; | |
814 std::string unescaped_title("About Histograms"); | |
815 if (!query.empty()) { | |
816 unescaped_query = net::UnescapeURLComponent(query, | |
817 net::UnescapeRule::NORMAL); | |
818 unescaped_title += " - " + unescaped_query; | |
819 } | |
820 | |
821 std::string data; | |
822 AppendHeader(&data, 0, unescaped_title); | |
823 AppendBody(&data); | |
824 base::StatisticsRecorder::WriteHTMLGraph(unescaped_query, &data); | |
825 AppendFooter(&data); | |
826 return data; | |
827 } | |
828 | |
829 void FinishMemoryDataRequest(const std::string& path, | 799 void FinishMemoryDataRequest(const std::string& path, |
830 AboutUIHTMLSource* source, | 800 AboutUIHTMLSource* source, |
831 int request_id) { | 801 int request_id) { |
832 if (path == kStringsJsPath) { | 802 if (path == kStringsJsPath) { |
833 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want | 803 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want |
834 // the refcount to be greater than 0. | 804 // the refcount to be greater than 0. |
835 scoped_refptr<AboutMemoryHandler> | 805 scoped_refptr<AboutMemoryHandler> |
836 handler(new AboutMemoryHandler(source, request_id)); | 806 handler(new AboutMemoryHandler(source, request_id)); |
837 // TODO(jamescook): Maybe this shouldn't update UMA? | 807 // TODO(jamescook): Maybe this shouldn't update UMA? |
838 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); | 808 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1397 } else if (host == chrome::kChromeUIDiscardsHost) { | 1367 } else if (host == chrome::kChromeUIDiscardsHost) { |
1398 response = AboutDiscards(path); | 1368 response = AboutDiscards(path); |
1399 #endif | 1369 #endif |
1400 #if defined(USE_ASH) | 1370 #if defined(USE_ASH) |
1401 } else if (host == chrome::kChromeUITransparencyHost) { | 1371 } else if (host == chrome::kChromeUITransparencyHost) { |
1402 response = AboutTransparency(path); | 1372 response = AboutTransparency(path); |
1403 #endif | 1373 #endif |
1404 } else if (host == chrome::kChromeUIDNSHost) { | 1374 } else if (host == chrome::kChromeUIDNSHost) { |
1405 AboutDnsHandler::Start(this, request_id); | 1375 AboutDnsHandler::Start(this, request_id); |
1406 return; | 1376 return; |
1407 } else if (host == chrome::kChromeUIHistogramsHost) { | |
1408 response = AboutHistograms(path); | |
1409 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 1377 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
1410 } else if (host == chrome::kChromeUILinuxProxyConfigHost) { | 1378 } else if (host == chrome::kChromeUILinuxProxyConfigHost) { |
1411 response = AboutLinuxProxyConfig(); | 1379 response = AboutLinuxProxyConfig(); |
1412 #endif | 1380 #endif |
1413 } else if (host == chrome::kChromeUIMemoryHost) { | 1381 } else if (host == chrome::kChromeUIMemoryHost) { |
1414 response = GetAboutMemoryRedirectResponse(profile()); | 1382 response = GetAboutMemoryRedirectResponse(profile()); |
1415 } else if (host == chrome::kChromeUIMemoryRedirectHost) { | 1383 } else if (host == chrome::kChromeUIMemoryRedirectHost) { |
1416 FinishMemoryDataRequest(path, this, request_id); | 1384 FinishMemoryDataRequest(path, this, request_id); |
1417 return; | 1385 return; |
1418 #if defined(OS_CHROMEOS) | 1386 #if defined(OS_CHROMEOS) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1471 | 1439 |
1472 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) | 1440 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) |
1473 : WebUIController(web_ui) { | 1441 : WebUIController(web_ui) { |
1474 Profile* profile = Profile::FromWebUI(web_ui); | 1442 Profile* profile = Profile::FromWebUI(web_ui); |
1475 ChromeURLDataManager::DataSource* source = | 1443 ChromeURLDataManager::DataSource* source = |
1476 new AboutUIHTMLSource(name, profile); | 1444 new AboutUIHTMLSource(name, profile); |
1477 if (source) { | 1445 if (source) { |
1478 ChromeURLDataManager::AddDataSource(profile, source); | 1446 ChromeURLDataManager::AddDataSource(profile, source); |
1479 } | 1447 } |
1480 } | 1448 } |
OLD | NEW |