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

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

Issue 2896713003: Create LoadingDataCollector class and have observers rely on it instead of ResourcePrefetchPredictor (Closed)
Patch Set: Address alexilin comments. Created 3 years, 7 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/glowplug_collector.h
diff --git a/chrome/browser/predictors/glowplug_collector.h b/chrome/browser/predictors/glowplug_collector.h
new file mode 100644
index 0000000000000000000000000000000000000000..08c168a36a4637d860b218b2b98f8dd2c24e8bad
--- /dev/null
+++ b/chrome/browser/predictors/glowplug_collector.h
@@ -0,0 +1,55 @@
+// Copyright 2017 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.
+
+#ifndef CHROME_BROWSER_PREDICTORS_GLOWPLUG_COLLECTOR_H_
+#define CHROME_BROWSER_PREDICTORS_GLOWPLUG_COLLECTOR_H_
+
+#include "chrome/browser/predictors/resource_prefetch_predictor.h"
+#include "content/public/common/resource_type.h"
+
+namespace net {
+class URLRequest;
+}
+
+namespace predictors {
+
+// Records navigation events as reported by various observers to the database
pasko 2017/05/23 12:24:59 Does this say that the observers of the database r
trevordixon 2017/06/13 11:40:02 I'll refactor the sentence to make the meaning cle
+// and stats collection classes. All the non-static methods of this class need
+// to be called on the UI thread.
+class GlowplugCollector : public base::SupportsWeakPtr<GlowplugCollector> {
pasko 2017/05/23 12:24:59 please try to avoid base::SupportsWeakPtr. See a d
trevordixon 2017/06/13 11:40:02 Sorry for missing this comment! Thankfully Alex to
+ public:
+ explicit GlowplugCollector(predictors::ResourcePrefetchPredictor* predictor);
alexilin 2017/05/23 08:24:37 nit: Sorry that I didn't notice it the first time,
trevordixon 2017/06/13 11:40:02 Sorry for missing this comment. I'll fix this in a
+ ~GlowplugCollector();
+
+ // Thread safe.
+ static bool ShouldRecordRequest(net::URLRequest* request,
+ content::ResourceType resource_type);
+ static bool ShouldRecordResponse(net::URLRequest* response);
+ static bool ShouldRecordRedirect(net::URLRequest* response);
+
+ // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the
+ // predictor of main frame and resource requests. Should only be called if the
+ // corresponding Should* functions return true.
+ void RecordURLRequest(
+ const predictors::ResourcePrefetchPredictor::URLRequestSummary& request);
+ void RecordURLResponse(
+ const predictors::ResourcePrefetchPredictor::URLRequestSummary& response);
+ void RecordURLRedirect(
+ const predictors::ResourcePrefetchPredictor::URLRequestSummary& response);
+
+ // Called when the main frame of a page completes loading.
+ void RecordMainFrameLoadComplete(const NavigationID& navigation_id);
+
+ // Called after the main frame's first contentful paint.
+ void RecordFirstContentfulPaint(
+ const NavigationID& navigation_id,
+ const base::TimeTicks& first_contentful_paint);
+
+ private:
+ predictors::ResourcePrefetchPredictor* const predictor_;
+};
+
+} // namespace predictors
+
+#endif // CHROME_BROWSER_PREDICTORS_GLOWPLUG_COLLECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698