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

Unified Diff: mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc

Issue 1535943002: Convert Pass()→std::move() in //mojo/public/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove self-move checks to avoid triggering clang warning. Created 5 years 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: mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
index faf46488e74c2ee08d707b50cb192bee91bbe0d1..478be7abedcef94d65559d187ba27c7a0a55924a 100644
--- a/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/interface_ptr_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <utility>
+
#include "base/message_loop/message_loop.h"
#include "mojo/message_pump/message_pump_mojo.h"
#include "mojo/public/cpp/bindings/binding.h"
@@ -41,7 +43,7 @@ typedef mojo::Callback<void(double)> CalcCallback;
class MathCalculatorImpl : public math::Calculator {
public:
explicit MathCalculatorImpl(InterfaceRequest<math::Calculator> request)
- : total_(0.0), binding_(this, request.Pass()) {}
+ : total_(0.0), binding_(this, std::move(request)) {}
~MathCalculatorImpl() override {}
void CloseMessagePipe() { binding_.Close(); }
@@ -71,7 +73,7 @@ class MathCalculatorImpl : public math::Calculator {
class MathCalculatorUI {
public:
explicit MathCalculatorUI(math::CalculatorPtr calculator)
- : calculator_(calculator.Pass()),
+ : calculator_(std::move(calculator)),
output_(0.0),
callback_(MakeRunnable(&MathCalculatorUI::Output, this)) {}
@@ -102,7 +104,7 @@ class MathCalculatorUI {
class SelfDestructingMathCalculatorUI {
public:
explicit SelfDestructingMathCalculatorUI(math::CalculatorPtr calculator)
- : calculator_(calculator.Pass()), nesting_level_(0) {
+ : calculator_(std::move(calculator)), nesting_level_(0) {
++num_instances_;
}
@@ -141,7 +143,9 @@ class ReentrantServiceImpl : public sample::Service {
~ReentrantServiceImpl() override {}
explicit ReentrantServiceImpl(InterfaceRequest<sample::Service> request)
- : call_depth_(0), max_call_depth_(0), binding_(this, request.Pass()) {}
+ : call_depth_(0),
+ max_call_depth_(0),
+ binding_(this, std::move(request)) {}
int max_call_depth() { return max_call_depth_; }
@@ -205,7 +209,7 @@ TEST_F(InterfacePtrTest, EndToEnd) {
MathCalculatorImpl calc_impl(GetProxy(&calc));
// Suppose this is instantiated in a process that has pipe1_.
- MathCalculatorUI calculator_ui(calc.Pass());
+ MathCalculatorUI calculator_ui(std::move(calc));
calculator_ui.Add(2.0);
calculator_ui.Multiply(5.0);
@@ -220,7 +224,7 @@ TEST_F(InterfacePtrTest, EndToEnd_Synchronous) {
MathCalculatorImpl calc_impl(GetProxy(&calc));
// Suppose this is instantiated in a process that has pipe1_.
- MathCalculatorUI calculator_ui(calc.Pass());
+ MathCalculatorUI calculator_ui(std::move(calc));
EXPECT_EQ(0.0, calculator_ui.GetOutput());
@@ -245,7 +249,7 @@ TEST_F(InterfacePtrTest, Movable) {
EXPECT_TRUE(!a);
EXPECT_FALSE(!b);
- a = b.Pass();
+ a = std::move(b);
EXPECT_FALSE(!a);
EXPECT_TRUE(!b);
@@ -261,7 +265,8 @@ TEST_F(InterfacePtrTest, Resettable) {
// Save this so we can test it later.
Handle handle = pipe.handle0.get();
- a = MakeProxy(InterfacePtrInfo<math::Calculator>(pipe.handle0.Pass(), 0u));
+ a = MakeProxy(
+ InterfacePtrInfo<math::Calculator>(std::move(pipe.handle0), 0u));
EXPECT_FALSE(!a);
@@ -288,7 +293,7 @@ TEST_F(InterfacePtrTest, EncounteredError) {
math::CalculatorPtr proxy;
MathCalculatorImpl calc_impl(GetProxy(&proxy));
- MathCalculatorUI calculator_ui(proxy.Pass());
+ MathCalculatorUI calculator_ui(std::move(proxy));
calculator_ui.Add(2.0);
PumpMessages();
@@ -318,7 +323,7 @@ TEST_F(InterfacePtrTest, EncounteredErrorCallback) {
proxy.set_connection_error_handler(
[&encountered_error]() { encountered_error = true; });
- MathCalculatorUI calculator_ui(proxy.Pass());
+ MathCalculatorUI calculator_ui(std::move(proxy));
calculator_ui.Add(2.0);
PumpMessages();
@@ -351,7 +356,7 @@ TEST_F(InterfacePtrTest, DestroyInterfacePtrOnMethodResponse) {
EXPECT_EQ(0, SelfDestructingMathCalculatorUI::num_instances());
SelfDestructingMathCalculatorUI* impl =
- new SelfDestructingMathCalculatorUI(proxy.Pass());
+ new SelfDestructingMathCalculatorUI(std::move(proxy));
impl->BeginTest(false);
PumpMessages();
@@ -366,7 +371,7 @@ TEST_F(InterfacePtrTest, NestedDestroyInterfacePtrOnMethodResponse) {
EXPECT_EQ(0, SelfDestructingMathCalculatorUI::num_instances());
SelfDestructingMathCalculatorUI* impl =
- new SelfDestructingMathCalculatorUI(proxy.Pass());
+ new SelfDestructingMathCalculatorUI(std::move(proxy));
impl->BeginTest(true);
PumpMessages();
@@ -442,7 +447,7 @@ class StrongMathCalculatorImpl : public math::Calculator {
bool* destroyed)
: error_received_(error_received),
destroyed_(destroyed),
- binding_(this, handle.Pass()) {
+ binding_(this, std::move(handle)) {
binding_.set_connection_error_handler(
[this]() { *error_received_ = true; });
}
@@ -475,16 +480,16 @@ TEST(StrongConnectorTest, Math) {
bool error_received = false;
bool destroyed = false;
MessagePipe pipe;
- new StrongMathCalculatorImpl(pipe.handle0.Pass(), &error_received,
+ new StrongMathCalculatorImpl(std::move(pipe.handle0), &error_received,
&destroyed);
math::CalculatorPtr calc;
- calc.Bind(InterfacePtrInfo<math::Calculator>(pipe.handle1.Pass(), 0u));
+ calc.Bind(InterfacePtrInfo<math::Calculator>(std::move(pipe.handle1), 0u));
{
// Suppose this is instantiated in a process that has the other end of the
// message pipe.
- MathCalculatorUI calculator_ui(calc.Pass());
+ MathCalculatorUI calculator_ui(std::move(calc));
calculator_ui.Add(2.0);
calculator_ui.Multiply(5.0);
@@ -511,7 +516,7 @@ class WeakMathCalculatorImpl : public math::Calculator {
bool* destroyed)
: error_received_(error_received),
destroyed_(destroyed),
- binding_(this, handle.Pass()) {
+ binding_(this, std::move(handle)) {
binding_.set_connection_error_handler(
[this]() { *error_received_ = true; });
}
@@ -543,15 +548,16 @@ TEST(WeakConnectorTest, Math) {
bool error_received = false;
bool destroyed = false;
MessagePipe pipe;
- WeakMathCalculatorImpl impl(pipe.handle0.Pass(), &error_received, &destroyed);
+ WeakMathCalculatorImpl impl(std::move(pipe.handle0), &error_received,
+ &destroyed);
math::CalculatorPtr calc;
- calc.Bind(InterfacePtrInfo<math::Calculator>(pipe.handle1.Pass(), 0u));
+ calc.Bind(InterfacePtrInfo<math::Calculator>(std::move(pipe.handle1), 0u));
{
// Suppose this is instantiated in a process that has the other end of the
// message pipe.
- MathCalculatorUI calculator_ui(calc.Pass());
+ MathCalculatorUI calculator_ui(std::move(calc));
calculator_ui.Add(2.0);
calculator_ui.Multiply(5.0);
@@ -574,8 +580,7 @@ TEST(WeakConnectorTest, Math) {
class CImpl : public C {
public:
CImpl(bool* d_called, InterfaceRequest<C> request)
- : d_called_(d_called),
- binding_(this, request.Pass()) {}
+ : d_called_(d_called), binding_(this, std::move(request)) {}
~CImpl() override {}
private:
@@ -590,13 +595,12 @@ class CImpl : public C {
class BImpl : public B {
public:
BImpl(bool* d_called, InterfaceRequest<B> request)
- : d_called_(d_called),
- binding_(this, request.Pass()) {}
+ : d_called_(d_called), binding_(this, std::move(request)) {}
~BImpl() override {}
private:
void GetC(InterfaceRequest<C> c) override {
- new CImpl(d_called_, c.Pass());
+ new CImpl(d_called_, std::move(c));
}
bool* d_called_;
@@ -606,15 +610,14 @@ class BImpl : public B {
class AImpl : public A {
public:
explicit AImpl(InterfaceRequest<A> request)
- : d_called_(false),
- binding_(this, request.Pass()) {}
+ : d_called_(false), binding_(this, std::move(request)) {}
~AImpl() override {}
bool d_called() const { return d_called_; }
private:
void GetB(InterfaceRequest<B> b) override {
- new BImpl(&d_called_, b.Pass());
+ new BImpl(&d_called_, std::move(b));
}
bool d_called_;

Powered by Google App Engine
This is Rietveld 408576698