blob: c86953313f2d91d5e82dfbe38d8e0696480e3147 [file] [log] [blame]
// 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 "modules/screen_orientation/ScreenOrientationDispatcher.h"
#include "public/platform/Platform.h"
#include "services/device/public/interfaces/constants.mojom-blink.h"
#include "services/service_manager/public/cpp/connector.h"
namespace blink {
ScreenOrientationDispatcher& ScreenOrientationDispatcher::Instance() {
DEFINE_STATIC_LOCAL(ScreenOrientationDispatcher,
screen_orientation_dispatcher,
(new ScreenOrientationDispatcher));
return screen_orientation_dispatcher;
}
ScreenOrientationDispatcher::ScreenOrientationDispatcher() {}
ScreenOrientationDispatcher::~ScreenOrientationDispatcher() {
DCHECK(!listener_);
}
DEFINE_TRACE(ScreenOrientationDispatcher) {
PlatformEventDispatcher::Trace(visitor);
}
void ScreenOrientationDispatcher::StartListening() {
DCHECK(!listener_);
Platform::Current()->GetConnector()->BindInterface(
device::mojom::blink::kServiceName, mojo::MakeRequest(&listener_));
listener_->Start();
}
void ScreenOrientationDispatcher::StopListening() {
DCHECK(listener_);
listener_->Stop();
listener_.reset();
}
} // namespace blink