Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / renderer_host / begin_frame_observer_proxy.cc
blob7a6651f53c3a9faf6d55e981e1838d333563dd5a
1 // Copyright 2015 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.
5 #include "content/browser/renderer_host/begin_frame_observer_proxy.h"
7 namespace content {
9 BeginFrameObserverProxy::BeginFrameObserverProxy(
10 BeginFrameObserverProxyClient* client)
11 : needs_begin_frames_(false),
12 client_(client),
13 compositor_(nullptr) {
16 BeginFrameObserverProxy::~BeginFrameObserverProxy() {
19 void BeginFrameObserverProxy::SetNeedsBeginFrames(bool needs_begin_frames) {
20 if (needs_begin_frames_ == needs_begin_frames)
21 return;
23 needs_begin_frames_ = needs_begin_frames;
25 // In some cases, BeginFrame message is requested before |client_|'s window is
26 // added in the root window hierarchy.
27 if (!compositor_)
28 return;
30 if (needs_begin_frames)
31 StartObservingBeginFrames();
32 else
33 StopObservingBeginFrames();
36 void BeginFrameObserverProxy::SetCompositor(ui::Compositor* compositor) {
37 DCHECK(!compositor_);
38 DCHECK(compositor);
40 compositor_ = compositor;
41 if (needs_begin_frames_)
42 StartObservingBeginFrames();
45 void BeginFrameObserverProxy::ResetCompositor() {
46 if (!compositor_)
47 return;
49 if (needs_begin_frames_)
50 StopObservingBeginFrames();
51 compositor_ = nullptr;
54 void BeginFrameObserverProxy::OnSendBeginFrame(const cc::BeginFrameArgs& args) {
55 if (last_sent_begin_frame_args_.frame_time != args.frame_time)
56 client_->SendBeginFrame(args);
57 last_sent_begin_frame_args_ = args;
60 void BeginFrameObserverProxy::StartObservingBeginFrames() {
61 DCHECK(compositor_);
62 compositor_->AddBeginFrameObserver(this);
65 void BeginFrameObserverProxy::StopObservingBeginFrames() {
66 DCHECK(compositor_);
67 compositor_->RemoveBeginFrameObserver(this);
70 } // namespace content