OLD | NEW |
| (Empty) |
1 // Copyright 2014 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/screen_orientation/screen_orientation_listener_android
.h" | |
6 | |
7 #include "base/message_loop/message_loop.h" | |
8 #include "content/browser/screen_orientation/screen_orientation_delegate_android
.h" | |
9 #include "content/common/screen_orientation_messages.h" | |
10 | |
11 namespace content { | |
12 | |
13 ScreenOrientationListenerAndroid::ScreenOrientationListenerAndroid() | |
14 : BrowserMessageFilter(ScreenOrientationMsgStart), | |
15 BrowserAssociatedInterface<device::mojom::ScreenOrientationListener>( | |
16 this, | |
17 this), | |
18 listeners_count_(0) {} | |
19 | |
20 ScreenOrientationListenerAndroid::~ScreenOrientationListenerAndroid() { | |
21 DCHECK(base::MessageLoopForIO::IsCurrent()); | |
22 if (listeners_count_ > 0) | |
23 ScreenOrientationDelegateAndroid::StopAccurateListening(); | |
24 } | |
25 | |
26 bool ScreenOrientationListenerAndroid::OnMessageReceived( | |
27 const IPC::Message& message) { | |
28 return false; | |
29 } | |
30 | |
31 void ScreenOrientationListenerAndroid::Start() { | |
32 DCHECK(base::MessageLoopForIO::IsCurrent()); | |
33 ++listeners_count_; | |
34 if (listeners_count_ == 1) | |
35 ScreenOrientationDelegateAndroid::StartAccurateListening(); | |
36 } | |
37 | |
38 void ScreenOrientationListenerAndroid::Stop() { | |
39 DCHECK(base::MessageLoopForIO::IsCurrent()); | |
40 DCHECK(listeners_count_ > 0); | |
41 --listeners_count_; | |
42 if (listeners_count_ == 0) | |
43 ScreenOrientationDelegateAndroid::StopAccurateListening(); | |
44 } | |
45 | |
46 } // namespace content | |
OLD | NEW |