1 // Copyright (c) 2011 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 #ifndef CHROME_RENDERER_PRERENDER_PRERENDER_HELPER_H_ 6 #define CHROME_RENDERER_PRERENDER_PRERENDER_HELPER_H_ 7 8 #include "base/compiler_specific.h" 9 #include "base/time/time.h" 10 #include "content/public/renderer/render_frame_observer.h" 11 #include "content/public/renderer/render_frame_observer_tracker.h" 12 13 namespace prerender { 14 15 // Helper class to track whether its RenderFrame is currently being prerendered. 16 // Created when prerendering starts and deleted as soon as it stops. 17 class PrerenderHelper 18 : public content::RenderFrameObserver, 19 public content::RenderFrameObserverTracker<PrerenderHelper> { 20 public: 21 explicit PrerenderHelper(content::RenderFrame* render_frame); 22 virtual ~PrerenderHelper(); 23 24 // Returns true if |render_view| is currently prerendering. 25 static bool IsPrerendering(const content::RenderFrame* render_frame); 26 27 private: 28 // RenderViewObserver implementation 29 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 30 31 void OnSetIsPrerendering(bool is_prerendering); 32 33 DISALLOW_COPY_AND_ASSIGN(PrerenderHelper); 34 }; 35 36 } // namespace prerender 37 38 #endif // CHROME_RENDERER_PRERENDER_PRERENDER_HELPER_H_ 39