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

Side by Side Diff: content/browser/histogram_internals_request_job.cc

Issue 10454086: Histograms - Support histograms for Plugins, GPU (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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
Property Changes:
Added: svn:executable
## -0,0 +1 ##
+*
Added: svn:eol-style
## -0,0 +1 ##
+LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/histogram_internals_request_job.h"
6
7 #include "base/metrics/histogram.h"
8 #include "content/browser/histogram_synchronizer.h"
9 #include "googleurl/src/gurl.h"
10 #include "net/base/escape.h"
11 #include "net/url_request/url_request.h"
12
13 namespace content {
14
15 HistogramInternalsRequestJob::HistogramInternalsRequestJob(
16 net::URLRequest* request) : net::URLRequestSimpleJob(request) {
17 const std::string& spec = request->url().possibly_invalid_spec();
18 const url_parse::Parsed& parsed =
19 request->url().parsed_for_possibly_invalid_spec();
20 // + 1 to skip the slash at the beginning of the path.
21 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false) + 1;
22
23 if (offset < static_cast<int>(spec.size()))
24 path_.assign(spec.substr(offset));
25 }
26
27 void AboutHistogram(std::string* data, const std::string& path) {
28 #ifndef NDEBUG
jar (doing other things) 2012/07/09 23:04:12 Add comment: We only rush the acquisition of Hist
ramant (doing other things) 2012/07/11 23:52:54 Done.
29 base::StatisticsRecorder::CollectHistogramStats("Browser");
30 #endif
31 content::HistogramSynchronizer::FetchHistograms();
32
33 std::string unescaped_query;
34 std::string unescaped_title("About Histograms");
35 if (!path.empty()) {
36 unescaped_query = net::UnescapeURLComponent(path,
37 net::UnescapeRule::NORMAL);
38 unescaped_title += " - " + unescaped_query;
39 }
40
41 data->append("<!DOCTYPE html>\n<html>\n<head>\n");
42 data->append(
43 "<meta http-equiv=\"X-WebKit-CSP\" content=\"object-src 'none'; "
44 "script-src 'none' 'unsafe-eval'\">");
45 data->append("<title>");
46 data->append(net::EscapeForHTML(unescaped_title));
47 data->append("</title>\n");
48 data->append("</head><body>");
49
50 // Display any stats for which we sent off requests the last time.
51 data->append("<p>Stats as of last page load;");
52 data->append("reload to get stats as of this page load.</p>\n");
53 data->append("<table width=\"100%\">\n");
54
55 base::StatisticsRecorder::WriteHTMLGraph(unescaped_query, data);
56 }
57
58 bool HistogramInternalsRequestJob::GetData(std::string* mime_type,
59 std::string* charset,
60 std::string* data) const {
61 mime_type->assign("text/html");
62 charset->assign("UTF8");
63
64 data->clear();
65 AboutHistogram(data, path_);
66 return true;
67 }
68
69 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698