diff options
author | jamesr <jamesr@chromium.org> | 2014-11-18 17:35:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-19 01:35:49 +0000 |
commit | a9125266d3fc89ff0bfd4c3a05bf2f31ffaeff1f (patch) | |
tree | 954602a17f1bfd7fd9d10c255360f75a6ada0d28 /device/battery | |
parent | 558999147d4fdfd1ae7ee79cfa1c6599eab47d57 (diff) | |
download | chromium_src-a9125266d3fc89ff0bfd4c3a05bf2f31ffaeff1f.zip chromium_src-a9125266d3fc89ff0bfd4c3a05bf2f31ffaeff1f.tar.gz chromium_src-a9125266d3fc89ff0bfd4c3a05bf2f31ffaeff1f.tar.bz2 |
Update mojo sdk to rev e01f9a49449381a5eb430c1fd88bf2cae73ec35a
Includes updates to ipc/mojo/ipc_channel_mojo.cc for mojo::embedder API
changes and updates to use mojo::Binding<> in ui/keyboard and
device/battery.
Review URL: https://codereview.chromium.org/728133002
Cr-Commit-Position: refs/heads/master@{#304731}
Diffstat (limited to 'device/battery')
-rw-r--r-- | device/battery/battery_monitor_impl.cc | 14 | ||||
-rw-r--r-- | device/battery/battery_monitor_impl.h | 18 |
2 files changed, 18 insertions, 14 deletions
diff --git a/device/battery/battery_monitor_impl.cc b/device/battery/battery_monitor_impl.cc index 3cbf57d..dc07b62 100644 --- a/device/battery/battery_monitor_impl.cc +++ b/device/battery/battery_monitor_impl.cc @@ -11,24 +11,26 @@ namespace device { // static void BatteryMonitorImpl::Create( mojo::InterfaceRequest<BatteryMonitor> request) { - BindToRequest(new BatteryMonitorImpl(), &request); + new BatteryMonitorImpl(request.Pass()); } -BatteryMonitorImpl::BatteryMonitorImpl() { +BatteryMonitorImpl::BatteryMonitorImpl( + mojo::InterfaceRequest<BatteryMonitor> request) + : binding_(this, request.Pass()), + subscription_(BatteryStatusService::GetInstance()->AddCallback( + base::Bind(&BatteryMonitorImpl::DidChange, base::Unretained(this)))) { } BatteryMonitorImpl::~BatteryMonitorImpl() { } -void BatteryMonitorImpl::OnConnectionEstablished() { - subscription_ = BatteryStatusService::GetInstance()->AddCallback( - base::Bind(&BatteryMonitorImpl::DidChange, base::Unretained(this))); +void BatteryMonitorImpl::RegisterSubscription() { } void BatteryMonitorImpl::DidChange(const BatteryStatus& battery_status) { BatteryStatusPtr status(BatteryStatus::New()); *status = battery_status; - client()->DidChange(status.Pass()); + binding_.client()->DidChange(status.Pass()); } } // namespace device diff --git a/device/battery/battery_monitor_impl.h b/device/battery/battery_monitor_impl.h index 5c64843..7916b0d 100644 --- a/device/battery/battery_monitor_impl.h +++ b/device/battery/battery_monitor_impl.h @@ -2,31 +2,33 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_ +#define DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_ + #include "base/memory/scoped_ptr.h" #include "device/battery/battery_export.h" #include "device/battery/battery_monitor.mojom.h" #include "device/battery/battery_status_service.h" - -#ifndef DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_ -#define DEVICE_BATTERY_BATTERY_MONITOR_IMPL_H_ +#include "mojo/public/cpp/bindings/strong_binding.h" namespace device { -class BatteryMonitorImpl : public mojo::InterfaceImpl<BatteryMonitor> { +class BatteryMonitorImpl : public BatteryMonitor { public: DEVICE_BATTERY_EXPORT static void Create( mojo::InterfaceRequest<BatteryMonitor> request); private: - BatteryMonitorImpl(); + explicit BatteryMonitorImpl(mojo::InterfaceRequest<BatteryMonitor> request); ~BatteryMonitorImpl() override; - // mojo::InterfaceImpl<..> methods: - void OnConnectionEstablished() override; - + void RegisterSubscription(); void DidChange(const BatteryStatus& battery_status); + mojo::StrongBinding<BatteryMonitor> binding_; scoped_ptr<BatteryStatusService::BatteryUpdateSubscription> subscription_; + + DISALLOW_COPY_AND_ASSIGN(BatteryMonitorImpl); }; } // namespace device |