| Index: content/browser/screen_orientation/screen_orientation_listener_android.cc
|
| diff --git a/content/browser/screen_orientation/screen_orientation_listener_android.cc b/content/browser/screen_orientation/screen_orientation_listener_android.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..850e89e5b9fb509d99fb202917a7658d8337794a
|
| --- /dev/null
|
| +++ b/content/browser/screen_orientation/screen_orientation_listener_android.cc
|
| @@ -0,0 +1,46 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/screen_orientation/screen_orientation_listener_android.h"
|
| +
|
| +#include "base/message_loop/message_loop.h"
|
| +#include "content/browser/screen_orientation/screen_orientation_delegate_android.h"
|
| +#include "content/common/screen_orientation_messages.h"
|
| +
|
| +namespace content {
|
| +
|
| +ScreenOrientationListenerAndroid::ScreenOrientationListenerAndroid()
|
| + : BrowserMessageFilter(ScreenOrientationMsgStart),
|
| + BrowserAssociatedInterface<device::mojom::ScreenOrientationListener>(
|
| + this,
|
| + this),
|
| + listeners_count_(0) {}
|
| +
|
| +ScreenOrientationListenerAndroid::~ScreenOrientationListenerAndroid() {
|
| + DCHECK(base::MessageLoopForIO::IsCurrent());
|
| + if (listeners_count_ > 0)
|
| + ScreenOrientationDelegateAndroid::StopAccurateListening();
|
| +}
|
| +
|
| +bool ScreenOrientationListenerAndroid::OnMessageReceived(
|
| + const IPC::Message& message) {
|
| + return false;
|
| +}
|
| +
|
| +void ScreenOrientationListenerAndroid::Start() {
|
| + DCHECK(base::MessageLoopForIO::IsCurrent());
|
| + ++listeners_count_;
|
| + if (listeners_count_ == 1)
|
| + ScreenOrientationDelegateAndroid::StartAccurateListening();
|
| +}
|
| +
|
| +void ScreenOrientationListenerAndroid::Stop() {
|
| + DCHECK(base::MessageLoopForIO::IsCurrent());
|
| + DCHECK(listeners_count_ > 0);
|
| + --listeners_count_;
|
| + if (listeners_count_ == 0)
|
| + ScreenOrientationDelegateAndroid::StopAccurateListening();
|
| +}
|
| +
|
| +} // namespace content
|
|
|