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

Unified Diff: chrome/browser/predictors/resource_prefetcher.h

Issue 2688633002: predictors: Add prefetching hit/miss histograms. (Closed)
Patch Set: Add units. Created 3 years, 10 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: chrome/browser/predictors/resource_prefetcher.h
diff --git a/chrome/browser/predictors/resource_prefetcher.h b/chrome/browser/predictors/resource_prefetcher.h
index caba0981c0891b679d98deb0d018c650c034531b..cc80802900facd51c181e93ca83effd6469cc770 100644
--- a/chrome/browser/predictors/resource_prefetcher.h
+++ b/chrome/browser/predictors/resource_prefetcher.h
@@ -10,12 +10,14 @@
#include <list>
#include <map>
#include <memory>
+#include <string>
#include <utility>
#include <vector>
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
#include "base/threading/thread_checker.h"
+#include "base/time/time.h"
#include "chrome/browser/predictors/resource_prefetch_common.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/url_request.h"
@@ -44,6 +46,27 @@ constexpr char kResourcePrefetchPredictorPrefetchedSizeHistogram[] =
// - Lives entirely on the IO thread.
class ResourcePrefetcher : public net::URLRequest::Delegate {
public:
+ struct PrefetchedRequestStats {
+ PrefetchedRequestStats(const GURL& resource_url,
+ bool was_cached,
+ size_t total_received_bytes);
+ ~PrefetchedRequestStats();
+
+ GURL resource_url;
+ bool was_cached;
+ size_t total_received_bytes;
+ };
+
+ struct PrefetcherStats {
+ explicit PrefetcherStats(const GURL& url);
+ ~PrefetcherStats();
+ PrefetcherStats(const PrefetcherStats& other);
+
+ GURL url;
+ base::TimeTicks start_time;
+ std::vector<PrefetchedRequestStats> requests_stats;
+ };
+
// Used to communicate when the prefetching is done. All methods are invoked
// on the IO thread.
class Delegate {
@@ -52,7 +75,9 @@ class ResourcePrefetcher : public net::URLRequest::Delegate {
// Called when the ResourcePrefetcher is finished, i.e. there is nothing
// pending in flight.
- virtual void ResourcePrefetcherFinished(ResourcePrefetcher* prefetcher) = 0;
+ virtual void ResourcePrefetcherFinished(
+ ResourcePrefetcher* prefetcher,
+ std::unique_ptr<PrefetcherStats> stats) = 0;
virtual net::URLRequestContext* GetURLRequestContext() = 0;
};
@@ -129,6 +154,7 @@ class ResourcePrefetcher : public net::URLRequest::Delegate {
inflight_requests_;
std::list<GURL> request_queue_;
std::map<std::string, size_t> host_inflight_counts_;
+ std::unique_ptr<PrefetcherStats> stats_;
DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcher);
};

Powered by Google App Engine
This is Rietveld 408576698