Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3076)

Unified Diff: device/vibration/vibration_manager_impl_default.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/vibration/vibration_manager_impl_default.cc
diff --git a/device/vibration/vibration_manager_impl_default.cc b/device/vibration/vibration_manager_impl_default.cc
index 123a5dc53784ca7c5120154761dc65508158a6b6..df59a122b073c874c2205426822cab39863e3192 100644
--- a/device/vibration/vibration_manager_impl_default.cc
+++ b/device/vibration/vibration_manager_impl_default.cc
@@ -5,6 +5,7 @@
#include <stdint.h>
#include <utility>
+#include "base/memory/ptr_util.h"
#include "device/vibration/vibration_manager_impl.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
@@ -14,30 +15,22 @@ namespace {
class VibrationManagerEmptyImpl : public VibrationManager {
public:
+ VibrationManagerEmptyImpl() {}
+ ~VibrationManagerEmptyImpl() override {}
+
void Vibrate(int64_t milliseconds, const VibrateCallback& callback) override {
callback.Run();
}
void Cancel(const CancelCallback& callback) override { callback.Run(); }
-
- private:
- friend VibrationManagerImpl;
-
- explicit VibrationManagerEmptyImpl(
- mojo::InterfaceRequest<VibrationManager> request)
- : binding_(this, std::move(request)) {}
- ~VibrationManagerEmptyImpl() override {}
-
- // The binding between this object and the other end of the pipe.
- mojo::StrongBinding<VibrationManager> binding_;
};
} // namespace
// static
-void VibrationManagerImpl::Create(
- mojo::InterfaceRequest<VibrationManager> request) {
- new VibrationManagerEmptyImpl(std::move(request));
+void VibrationManagerImpl::Create(VibrationManagerRequest request) {
+ mojo::MakeStrongBinding(base::MakeUnique<VibrationManagerEmptyImpl>(),
+ std::move(request));
}
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698