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

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

Issue 1292433002: Defer media playback in background tabs. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. Created 5 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
(Empty)
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 #include "chrome/renderer/prerender/prerender_media_load_deferrer.h"
6
7 #include "base/callback_helpers.h"
8 #include "chrome/common/prerender_messages.h"
9
10 namespace prerender {
11
12 PrerenderMediaLoadDeferrer::PrerenderMediaLoadDeferrer(
13 content::RenderFrame* render_frame,
14 const base::Closure& closure)
15 : RenderFrameObserver(render_frame),
16 is_prerendering_(true),
17 continue_loading_cb_(closure) {
18 DCHECK(!continue_loading_cb_.is_null());
19 }
20
21 PrerenderMediaLoadDeferrer::~PrerenderMediaLoadDeferrer() {}
22
23 bool PrerenderMediaLoadDeferrer::OnMessageReceived(
24 const IPC::Message& message) {
25 IPC_BEGIN_MESSAGE_MAP(PrerenderMediaLoadDeferrer, message)
26 IPC_MESSAGE_HANDLER(PrerenderMsg_SetIsPrerendering, OnSetIsPrerendering)
27 IPC_END_MESSAGE_MAP()
28
29 return false;
30 }
31
32 void PrerenderMediaLoadDeferrer::OnSetIsPrerendering(bool is_prerendering) {
33 // Prerendering can only be enabled prior to a RenderFrame's first
34 // navigation, so no PrerenderMediaLoadDeferrer should see the notification
35 // that enables prerendering.
36 DCHECK(!is_prerendering);
37 if (!is_prerendering_ || is_prerendering)
38 return;
39
40 is_prerendering_ = false;
41 base::ResetAndReturn(&continue_loading_cb_).Run();
42 }
43
44 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/renderer/prerender/prerender_media_load_deferrer.h ('k') | chromecast/renderer/cast_content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698