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

Side by Side Diff: chrome/renderer/prerender/prerender_helper.cc

Issue 2172613002: Renderer-side changes for NoState Prefetch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix style Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/prerender/prerender_helper.h" 5 #include "chrome/renderer/prerender/prerender_helper.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "chrome/common/prerender_messages.h" 9 #include "chrome/common/prerender_messages.h"
10 #include "content/public/renderer/document_state.h" 10 #include "content/public/renderer/document_state.h"
(...skipping 16 matching lines...) Expand all
27 if (render_view->GetMainRenderFrame() == render_frame) { 27 if (render_view->GetMainRenderFrame() == render_frame) {
28 render_view->GetWebView()->setVisibilityState( 28 render_view->GetWebView()->setVisibilityState(
29 render_frame->GetVisibilityState(), false); 29 render_frame->GetVisibilityState(), false);
30 } 30 }
31 } 31 }
32 32
33 } // namespace 33 } // namespace
34 34
35 namespace prerender { 35 namespace prerender {
36 36
37 PrerenderHelper::PrerenderHelper(content::RenderFrame* render_frame) 37 PrerenderHelper::PrerenderHelper(content::RenderFrame* render_frame,
38 PrerenderMode prerender_mode)
38 : content::RenderFrameObserver(render_frame), 39 : content::RenderFrameObserver(render_frame),
39 content::RenderFrameObserverTracker<PrerenderHelper>(render_frame) { 40 content::RenderFrameObserverTracker<PrerenderHelper>(render_frame),
41 prerender_mode_(prerender_mode) {
42 DCHECK_NE(prerender_mode_, NO_PRERENDER);
40 UpdateVisibilityState(render_frame); 43 UpdateVisibilityState(render_frame);
41 } 44 }
42 45
46 PrerenderHelper::PrerenderHelper(content::RenderFrame* sub_frame)
47 : PrerenderHelper(sub_frame,
48 GetPrerenderMode(
49 sub_frame->GetRenderView()->GetMainRenderFrame())) {
50 DCHECK(!render_frame()->IsMainFrame());
51 }
52
43 PrerenderHelper::~PrerenderHelper() { 53 PrerenderHelper::~PrerenderHelper() {
44 } 54 }
45 55
46 // static. 56 // static.
47 bool PrerenderHelper::IsPrerendering(const content::RenderFrame* render_frame) { 57 bool PrerenderHelper::IsPrerendering(const content::RenderFrame* render_frame) {
48 return PrerenderHelper::Get(render_frame) != NULL; 58 return PrerenderHelper::GetPrerenderMode(render_frame) != NO_PRERENDER;
59 }
60
61 // static.
62 PrerenderMode PrerenderHelper::GetPrerenderMode(
63 const content::RenderFrame* render_frame) {
64 PrerenderHelper* helper = PrerenderHelper::Get(render_frame);
65 if (!helper)
66 return NO_PRERENDER;
67
68 DCHECK_NE(helper->prerender_mode_, NO_PRERENDER);
69 return helper->prerender_mode_;
49 } 70 }
50 71
51 bool PrerenderHelper::OnMessageReceived( 72 bool PrerenderHelper::OnMessageReceived(
52 const IPC::Message& message) { 73 const IPC::Message& message) {
53 IPC_BEGIN_MESSAGE_MAP(PrerenderHelper, message) 74 IPC_BEGIN_MESSAGE_MAP(PrerenderHelper, message)
54 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering) 75 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering)
55 IPC_END_MESSAGE_MAP() 76 IPC_END_MESSAGE_MAP()
56 // Return false on PrerenderMsg_SetIsPrerendering so other observers can see 77 // Return false on PrerenderMsg_SetIsPrerendering so other observers can see
57 // the message. 78 // the message.
58 return false; 79 return false;
(...skipping 12 matching lines...) Expand all
71 delete this; 92 delete this;
72 93
73 UpdateVisibilityState(frame); 94 UpdateVisibilityState(frame);
74 } 95 }
75 96
76 void PrerenderHelper::OnDestruct() { 97 void PrerenderHelper::OnDestruct() {
77 delete this; 98 delete this;
78 } 99 }
79 100
80 } // namespace prerender 101 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/renderer/prerender/prerender_helper.h ('k') | chrome/renderer/prerender/prerenderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698