Rewrite AndroidSyncSettings to be significantly simpler.
[chromium-blink-merge.git] / chromeos / dbus / services / console_service_provider.cc
blob1d7362e3d0331ac7dcdffdddbd56a3f2a74c6594
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.
5 #include "chromeos/dbus/services/console_service_provider.h"
7 #include "base/bind.h"
8 #include "dbus/message.h"
9 #include "third_party/cros_system_api/dbus/service_constants.h"
11 namespace chromeos {
13 ConsoleServiceProvider::ConsoleServiceProvider(scoped_ptr<Delegate> delegate)
14 : delegate_(delegate.Pass()),
15 weak_ptr_factory_(this) {
18 ConsoleServiceProvider::~ConsoleServiceProvider() {
21 void ConsoleServiceProvider::Start(
22 scoped_refptr<dbus::ExportedObject> exported_object) {
23 exported_object->ExportMethod(
24 kLibCrosServiceInterface, kTakeDisplayOwnership,
25 base::Bind(&ConsoleServiceProvider::TakeDisplayOwnership,
26 weak_ptr_factory_.GetWeakPtr()),
27 base::Bind(&ConsoleServiceProvider::OnExported,
28 weak_ptr_factory_.GetWeakPtr()));
30 exported_object->ExportMethod(
31 kLibCrosServiceInterface, kReleaseDisplayOwnership,
32 base::Bind(&ConsoleServiceProvider::ReleaseDisplayOwnership,
33 weak_ptr_factory_.GetWeakPtr()),
34 base::Bind(&ConsoleServiceProvider::OnExported,
35 weak_ptr_factory_.GetWeakPtr()));
38 void ConsoleServiceProvider::TakeDisplayOwnership(
39 dbus::MethodCall* method_call,
40 dbus::ExportedObject::ResponseSender response_sender) {
41 delegate_->TakeDisplayOwnership();
42 response_sender.Run(dbus::Response::FromMethodCall(method_call));
45 void ConsoleServiceProvider::ReleaseDisplayOwnership(
46 dbus::MethodCall* method_call,
47 dbus::ExportedObject::ResponseSender response_sender) {
48 delegate_->ReleaseDisplayOwnership();
49 response_sender.Run(dbus::Response::FromMethodCall(method_call));
52 void ConsoleServiceProvider::OnExported(const std::string& interface_name,
53 const std::string& method_name,
54 bool success) {
55 if (!success)
56 LOG(ERROR) << "failed to export " << interface_name << "." << method_name;
59 } // namespace chromeos