~chrisccoulson/oxide/lp1504853

« back to all changes in this revision

Viewing changes to shared/browser/compositor/oxide_compositor_observer.cc

  • Committer: Chris Coulson
  • Date: 2015-10-21 19:06:54 UTC
  • mfrom: (1215.1.13 oxide)
  • Revision ID: chris.coulson@canonical.com-20151021190654-cfcbueitgzojv7jc
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// vim:expandtab:shiftwidth=2:tabstop=2:
 
2
// Copyright (C) 2015 Canonical Ltd.
 
3
 
 
4
// This library is free software; you can redistribute it and/or
 
5
// modify it under the terms of the GNU Lesser General Public
 
6
// License as published by the Free Software Foundation; either
 
7
// version 2.1 of the License, or (at your option) any later version.
 
8
 
 
9
// This library is distributed in the hope that it will be useful,
 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
// Lesser General Public License for more details.
 
13
 
 
14
// You should have received a copy of the GNU Lesser General Public
 
15
// License along with this library; if not, write to the Free Software
 
16
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 
 
18
#include "oxide_compositor_observer.h"
 
19
 
 
20
#include "oxide_compositor.h"
 
21
 
 
22
namespace oxide {
 
23
 
 
24
CompositorObserver::CompositorObserver()
 
25
    : compositor_(nullptr) {}
 
26
 
 
27
CompositorObserver::CompositorObserver(Compositor* compositor)
 
28
    : compositor_(compositor) {
 
29
  if (compositor_) {
 
30
    compositor_->AddObserver(this);
 
31
  }
 
32
}
 
33
 
 
34
void CompositorObserver::Observe(Compositor* compositor) {
 
35
  if (compositor == compositor_) {
 
36
    return;
 
37
  }
 
38
 
 
39
  if (compositor_) {
 
40
    compositor_->RemoveObserver(this);
 
41
  }
 
42
  compositor_ = compositor;
 
43
  if (compositor_) {
 
44
    compositor_->AddObserver(this);
 
45
  }
 
46
}
 
47
 
 
48
void CompositorObserver::OnCompositorDestruction() {
 
49
  compositor_ = nullptr;
 
50
}
 
51
 
 
52
CompositorObserver::~CompositorObserver() {
 
53
  if (compositor_) {
 
54
    compositor_->RemoveObserver(this);
 
55
  }
 
56
}
 
57
 
 
58
void CompositorObserver::CompositorDidCommit() {}
 
59
 
 
60
} // namespace oxide