• 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 #include "content/browser/renderer_host/delegated_frame_evictor.h"
6 
7 #include "base/logging.h"
8 
9 namespace content {
10 
DelegatedFrameEvictor(DelegatedFrameEvictorClient * client)11 DelegatedFrameEvictor::DelegatedFrameEvictor(
12     DelegatedFrameEvictorClient* client)
13     : client_(client), has_frame_(false) {}
14 
~DelegatedFrameEvictor()15 DelegatedFrameEvictor::~DelegatedFrameEvictor() { DiscardedFrame(); }
16 
SwappedFrame(bool visible)17 void DelegatedFrameEvictor::SwappedFrame(bool visible) {
18   has_frame_ = true;
19   RendererFrameManager::GetInstance()->AddFrame(this, visible);
20 }
21 
DiscardedFrame()22 void DelegatedFrameEvictor::DiscardedFrame() {
23   RendererFrameManager::GetInstance()->RemoveFrame(this);
24   has_frame_ = false;
25 }
26 
SetVisible(bool visible)27 void DelegatedFrameEvictor::SetVisible(bool visible) {
28   if (has_frame_) {
29     if (visible) {
30       RendererFrameManager::GetInstance()->LockFrame(this);
31     } else {
32       RendererFrameManager::GetInstance()->UnlockFrame(this);
33     }
34   }
35 }
36 
LockFrame()37 void DelegatedFrameEvictor::LockFrame() {
38   DCHECK(has_frame_);
39   RendererFrameManager::GetInstance()->LockFrame(this);
40 }
41 
UnlockFrame()42 void DelegatedFrameEvictor::UnlockFrame() {
43   DCHECK(has_frame_);
44   RendererFrameManager::GetInstance()->UnlockFrame(this);
45 }
46 
EvictCurrentFrame()47 void DelegatedFrameEvictor::EvictCurrentFrame() {
48   client_->EvictDelegatedFrame();
49 }
50 
51 }  // namespace content
52