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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/prerender/prerender_plt_recorder.h"
6
7 #include "base/time.h"
8 #include "chrome/browser/prerender/prerender_manager.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/tab_contents/tab_contents.h"
11 #include "chrome/common/render_messages.h"
12
13 PrerenderPLTRecorder::PrerenderPLTRecorder(TabContents* tab_contents)
14 : tab_contents_(tab_contents),
15 pplt_load_start_() {
16
17 }
18
19 PrerenderPLTRecorder::~PrerenderPLTRecorder() {
20 }
21
22 bool PrerenderPLTRecorder::OnMessageReceived(const IPC::Message& message) {
23 IPC_BEGIN_MESSAGE_MAP(PrerenderPLTRecorder, message)
24 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame,
25 OnDidStartProvisionalLoadForFrame)
26 IPC_END_MESSAGE_MAP()
27 return false;
28 }
29
30 void PrerenderPLTRecorder::OnDidStartProvisionalLoadForFrame(int64 frame_id,
31 bool is_main_frame,
brettw 2011/01/26 22:13:28 Since these won't fit, all the arguments should ju
32 const GURL& url) {
33 if (is_main_frame) {
34 // Record the beginning of a new PPLT navigation.
35 pplt_load_start_ = base::TimeTicks::Now();
36 }
37 }
38
39 void PrerenderPLTRecorder::DidStopLoading() {
40 // Compute the PPLT metric and report it in a histogram, if needed.
41 PrerenderManager* pm = tab_contents_->profile()->GetPrerenderManager();
42 if (pm != NULL && !pplt_load_start_.is_null())
43 pm->RecordPerceivedPageLoadTime(base::TimeTicks::Now() - pplt_load_start_);
44
45 // Reset the PPLT metric.
46 pplt_load_start_ = base::TimeTicks();
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698