1 // Copyright (c) 2012 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 "chrome/browser/chromeos/dbus/liveness_service_provider.h" 6 7 #include "base/bind.h" 8 #include "dbus/bus.h" 9 #include "dbus/message.h" 10 #include "third_party/cros_system_api/dbus/service_constants.h" 11 12 namespace chromeos { 13 14 LivenessServiceProvider::LivenessServiceProvider() : weak_ptr_factory_(this) {} 15 16 LivenessServiceProvider::~LivenessServiceProvider() {} 17 18 void LivenessServiceProvider::Start( 19 scoped_refptr<dbus::ExportedObject> exported_object) { 20 exported_object->ExportMethod( 21 kLibCrosServiceInterface, 22 kCheckLiveness, 23 base::Bind(&LivenessServiceProvider::CheckLiveness, 24 weak_ptr_factory_.GetWeakPtr()), 25 base::Bind(&LivenessServiceProvider::OnExported, 26 weak_ptr_factory_.GetWeakPtr())); 27 } 28 29 void LivenessServiceProvider::OnExported(const std::string& interface_name, 30 const std::string& method_name, 31 bool success) { 32 if (!success) { 33 LOG(ERROR) << "Failed to export " << interface_name << "." 34 << method_name; 35 } 36 } 37 38 void LivenessServiceProvider::CheckLiveness( 39 dbus::MethodCall* method_call, 40 dbus::ExportedObject::ResponseSender response_sender) { 41 response_sender.Run(dbus::Response::FromMethodCall(method_call)); 42 } 43 44 } // namespace chromeos 45