• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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_MEDIA_LOAD_DEFERRER_H_
6 #define CHROME_RENDERER_PRERENDER_PRERENDER_MEDIA_LOAD_DEFERRER_H_
7 
8 #include "base/callback.h"
9 #include "content/public/renderer/render_frame_observer.h"
10 
11 namespace prerender {
12 
13 // Defers media player loading in prerendered pages until the prerendered page
14 // is swapped in.
15 class PrerenderMediaLoadDeferrer : public content::RenderFrameObserver {
16  public:
17   // Will run |closure| to continue loading the media resource once the page is
18   // swapped in.
19   PrerenderMediaLoadDeferrer(content::RenderFrame* render_frame,
20                              const base::Closure& closure);
21   virtual ~PrerenderMediaLoadDeferrer();
22 
23  private:
24   // RenderFrameObserver method:
25   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
26 
27   void OnSetIsPrerendering(bool is_prerendering);
28 
29   bool is_prerendering_;
30   base::Closure continue_loading_cb_;
31 
32   DISALLOW_COPY_AND_ASSIGN(PrerenderMediaLoadDeferrer);
33 };
34 
35 }  // namespace prerender
36 
37 #endif  // CHROME_RENDERER_PRERENDER_PRERENDER_MEDIA_LOAD_DEFERRER_H_
38