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 |