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

Unified Diff: chrome/browser/prerender/prerender_plt_recorder.cc

Issue 6263014: Add Perceived PageLoad Time (PPLT) metrics for Prerender Experiments,... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
Index: chrome/browser/prerender/prerender_plt_recorder.cc
===================================================================
--- chrome/browser/prerender/prerender_plt_recorder.cc (revision 0)
+++ chrome/browser/prerender/prerender_plt_recorder.cc (revision 0)
@@ -0,0 +1,47 @@
+// Copyright (c) 2010 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 "chrome/browser/prerender/prerender_plt_recorder.h"
+
+#include "base/time.h"
+#include "chrome/browser/prerender/prerender_manager.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/render_messages.h"
+
+PrerenderPLTRecorder::PrerenderPLTRecorder(TabContents* tab_contents)
+ : tab_contents_(tab_contents),
+ pplt_load_start_() {
+
+}
+
+PrerenderPLTRecorder::~PrerenderPLTRecorder() {
+}
+
+bool PrerenderPLTRecorder::OnMessageReceived(const IPC::Message& message) {
+ IPC_BEGIN_MESSAGE_MAP(PrerenderPLTRecorder, message)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame,
+ OnDidStartProvisionalLoadForFrame)
+ IPC_END_MESSAGE_MAP()
+ return false;
+}
+
+void PrerenderPLTRecorder::OnDidStartProvisionalLoadForFrame(int64 frame_id,
+ bool is_main_frame,
brettw 2011/01/26 22:13:28 Since these won't fit, all the arguments should ju
+ const GURL& url) {
+ if (is_main_frame) {
+ // Record the beginning of a new PPLT navigation.
+ pplt_load_start_ = base::TimeTicks::Now();
+ }
+}
+
+void PrerenderPLTRecorder::DidStopLoading() {
+ // Compute the PPLT metric and report it in a histogram, if needed.
+ PrerenderManager* pm = tab_contents_->profile()->GetPrerenderManager();
+ if (pm != NULL && !pplt_load_start_.is_null())
+ pm->RecordPerceivedPageLoadTime(base::TimeTicks::Now() - pplt_load_start_);
+
+ // Reset the PPLT metric.
+ pplt_load_start_ = base::TimeTicks();
+}

Powered by Google App Engine
This is Rietveld 408576698