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

Unified Diff: content/browser/histogram_internals_request_job.cc

Issue 2658163002: Merge histograms from providers into StatisticsRecorder for display. (Closed)
Patch Set: rebased Created 3 years, 11 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
« no previous file with comments | « content/browser/histogram_internals_request_job.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/histogram_internals_request_job.cc
diff --git a/content/browser/histogram_internals_request_job.cc b/content/browser/histogram_internals_request_job.cc
index c726e0770952af96d95a5afdfbf4f7102a58cc75..3dd61a3bda7072a77a8d0af92307146ad915a029 100644
--- a/content/browser/histogram_internals_request_job.cc
+++ b/content/browser/histogram_internals_request_job.cc
@@ -7,6 +7,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/metrics/statistics_recorder.h"
#include "content/browser/histogram_synchronizer.h"
+#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
@@ -15,8 +16,9 @@
namespace content {
HistogramInternalsRequestJob::HistogramInternalsRequestJob(
- net::URLRequest* request, net::NetworkDelegate* network_delegate)
- : net::URLRequestSimpleJob(request, network_delegate) {
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate)
+ : net::URLRequestSimpleJob(request, network_delegate), weak_factory_(this) {
const std::string& spec = request->url().possibly_invalid_spec();
const url::Parsed& parsed = request->url().parsed_for_possibly_invalid_spec();
// + 1 to skip the slash at the beginning of the path.
@@ -26,6 +28,8 @@ HistogramInternalsRequestJob::HistogramInternalsRequestJob(
path_.assign(spec.substr(offset));
}
+HistogramInternalsRequestJob::~HistogramInternalsRequestJob() {}
+
void AboutHistogram(std::string* data, const std::string& path) {
HistogramSynchronizer::FetchHistograms();
@@ -54,6 +58,17 @@ void AboutHistogram(std::string* data, const std::string& path) {
base::StatisticsRecorder::WriteHTMLGraph(unescaped_query, data);
}
+void HistogramInternalsRequestJob::Start() {
+ // First import histograms from all providers and then start the URL fetch
+ // job. It's not possible to call URLRequestSimpleJob::Start through Bind,
+ // it ends up re-calling this method, so a small helper method is used.
+ content::BrowserThread::PostTaskAndReply(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&base::StatisticsRecorder::ImportProvidedHistograms),
+ base::Bind(&HistogramInternalsRequestJob::StartUrlRequest,
+ weak_factory_.GetWeakPtr()));
+}
+
int HistogramInternalsRequestJob::GetData(
std::string* mime_type,
std::string* charset,
@@ -67,4 +82,8 @@ int HistogramInternalsRequestJob::GetData(
return net::OK;
}
+void HistogramInternalsRequestJob::StartUrlRequest() {
+ URLRequestSimpleJob::Start();
+}
+
} // namespace content
« no previous file with comments | « content/browser/histogram_internals_request_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698