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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/histogram_internals_request_job.cc
===================================================================
--- content/browser/histogram_internals_request_job.cc (revision 0)
+++ content/browser/histogram_internals_request_job.cc (working copy)
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/histogram_internals_request_job.h"
+
+#include "base/metrics/histogram.h"
+#include "content/browser/histogram_synchronizer.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/escape.h"
+#include "net/url_request/url_request.h"
+
+namespace content {
+
+HistogramInternalsRequestJob::HistogramInternalsRequestJob(
+ net::URLRequest* request) : net::URLRequestSimpleJob(request) {
+ const std::string& spec = request->url().possibly_invalid_spec();
+ const url_parse::Parsed& parsed =
+ request->url().parsed_for_possibly_invalid_spec();
+ // + 1 to skip the slash at the beginning of the path.
+ int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false) + 1;
+
+ if (offset < static_cast<int>(spec.size()))
+ path_.assign(spec.substr(offset));
+}
+
+void AboutHistogram(std::string* data, const std::string& path) {
+#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.
+ base::StatisticsRecorder::CollectHistogramStats("Browser");
+#endif
+ content::HistogramSynchronizer::FetchHistograms();
+
+ std::string unescaped_query;
+ std::string unescaped_title("About Histograms");
+ if (!path.empty()) {
+ unescaped_query = net::UnescapeURLComponent(path,
+ net::UnescapeRule::NORMAL);
+ unescaped_title += " - " + unescaped_query;
+ }
+
+ data->append("<!DOCTYPE html>\n<html>\n<head>\n");
+ data->append(
+ "<meta http-equiv=\"X-WebKit-CSP\" content=\"object-src 'none'; "
+ "script-src 'none' 'unsafe-eval'\">");
+ data->append("<title>");
+ data->append(net::EscapeForHTML(unescaped_title));
+ data->append("</title>\n");
+ data->append("</head><body>");
+
+ // Display any stats for which we sent off requests the last time.
+ data->append("<p>Stats as of last page load;");
+ data->append("reload to get stats as of this page load.</p>\n");
+ data->append("<table width=\"100%\">\n");
+
+ base::StatisticsRecorder::WriteHTMLGraph(unescaped_query, data);
+}
+
+bool HistogramInternalsRequestJob::GetData(std::string* mime_type,
+ std::string* charset,
+ std::string* data) const {
+ mime_type->assign("text/html");
+ charset->assign("UTF8");
+
+ data->clear();
+ AboutHistogram(data, path_);
+ return true;
+}
+
+} // namespace content
Property changes on: content/browser/histogram_internals_request_job.cc
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
Added: svn:eol-style
## -0,0 +1 ##
+LF

Powered by Google App Engine
This is Rietveld 408576698