From 7742fb4516ba94d8c0b6cdb8ddbb25839065642f Mon Sep 17 00:00:00 2001 From: jam Date: Tue, 11 Nov 2014 09:38:30 -0800 Subject: [PATCH] Remove async_waiter in device/serial and use the copied version in mojo/public. Review URL: https://codereview.chromium.org/715613004 Cr-Commit-Position: refs/heads/master@{#303668} --- device/serial/BUILD.gn | 2 -- device/serial/async_waiter.cc | 37 -------------------------------- device/serial/async_waiter.h | 40 ----------------------------------- device/serial/data_sink_unittest.cc | 2 +- device/serial/data_source_unittest.cc | 2 +- device/serial/serial.gyp | 2 -- 6 files changed, 2 insertions(+), 83 deletions(-) delete mode 100644 device/serial/async_waiter.cc delete mode 100644 device/serial/async_waiter.h diff --git a/device/serial/BUILD.gn b/device/serial/BUILD.gn index 5e0dff6daaf6..05321686b290 100644 --- a/device/serial/BUILD.gn +++ b/device/serial/BUILD.gn @@ -9,8 +9,6 @@ static_library("serial") { output_name = "device_serial" sources = [ - "async_waiter.cc", - "async_waiter.h", "buffer.cc", "buffer.h", "data_receiver.cc", diff --git a/device/serial/async_waiter.cc b/device/serial/async_waiter.cc deleted file mode 100644 index eb533fd2cecd..000000000000 --- a/device/serial/async_waiter.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "device/serial/async_waiter.h" - -namespace device { - -AsyncWaiter::AsyncWaiter(mojo::Handle handle, - MojoHandleSignals signals, - const Callback& callback) - : waiter_(mojo::Environment::GetDefaultAsyncWaiter()), - id_(0), - callback_(callback) { - id_ = waiter_->AsyncWait(handle.value(), - signals, - MOJO_DEADLINE_INDEFINITE, - &AsyncWaiter::WaitComplete, - this); -} - -AsyncWaiter::~AsyncWaiter() { - if (id_) - waiter_->CancelWait(id_); -} - -// static -void AsyncWaiter::WaitComplete(void* waiter, MojoResult result) { - static_cast(waiter)->WaitCompleteInternal(result); -} - -void AsyncWaiter::WaitCompleteInternal(MojoResult result) { - id_ = 0; - callback_.Run(result); -} - -} // namespace device diff --git a/device/serial/async_waiter.h b/device/serial/async_waiter.h deleted file mode 100644 index f39bf32a60bd..000000000000 --- a/device/serial/async_waiter.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef DEVICE_SERIAL_ASYNC_WAITER_H_ -#define DEVICE_SERIAL_ASYNC_WAITER_H_ - -#include "base/callback.h" -#include "mojo/public/c/environment/async_waiter.h" -#include "mojo/public/cpp/environment/environment.h" -#include "mojo/public/cpp/system/handle.h" - -namespace device { - -// A class that waits until a handle is ready and calls |callback| with the -// result. If the AsyncWaiter is deleted before the handle is ready, the wait is -// cancelled and the callback will not be called. -class AsyncWaiter { - public: - typedef base::Callback Callback; - - AsyncWaiter(mojo::Handle handle, - MojoHandleSignals signals, - const Callback& callback); - ~AsyncWaiter(); - - private: - static void WaitComplete(void* waiter, MojoResult result); - void WaitCompleteInternal(MojoResult result); - - const MojoAsyncWaiter* waiter_; - MojoAsyncWaitID id_; - const Callback callback_; - - DISALLOW_COPY_AND_ASSIGN(AsyncWaiter); -}; - -} // namespace device - -#endif // DEVICE_SERIAL_ASYNC_WAITER_H_ diff --git a/device/serial/data_sink_unittest.cc b/device/serial/data_sink_unittest.cc index 9703b51dad6f..29f3587de86e 100644 --- a/device/serial/data_sink_unittest.cc +++ b/device/serial/data_sink_unittest.cc @@ -6,11 +6,11 @@ #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/strings/string_piece.h" -#include "device/serial/async_waiter.h" #include "device/serial/data_sender.h" #include "device/serial/data_sink_receiver.h" #include "device/serial/data_stream.mojom.h" #include "mojo/public/cpp/bindings/interface_ptr.h" +#include "mojo/public/cpp/environment/async_waiter.h" #include "testing/gtest/include/gtest/gtest.h" namespace device { diff --git a/device/serial/data_source_unittest.cc b/device/serial/data_source_unittest.cc index 7dee58744bdc..3d96f55784a7 100644 --- a/device/serial/data_source_unittest.cc +++ b/device/serial/data_source_unittest.cc @@ -6,12 +6,12 @@ #include "base/message_loop/message_loop.h" #include "base/run_loop.h" #include "base/strings/string_piece.h" -#include "device/serial/async_waiter.h" #include "device/serial/buffer.h" #include "device/serial/data_receiver.h" #include "device/serial/data_source_sender.h" #include "device/serial/data_stream.mojom.h" #include "mojo/public/cpp/bindings/interface_ptr.h" +#include "mojo/public/cpp/environment/async_waiter.h" #include "testing/gtest/include/gtest/gtest.h" namespace device { diff --git a/device/serial/serial.gyp b/device/serial/serial.gyp index 7da99be56549..50aaa709fb7d 100644 --- a/device/serial/serial.gyp +++ b/device/serial/serial.gyp @@ -58,8 +58,6 @@ '<(SHARED_INTERMEDIATE_DIR)/device/serial/serial.mojom.h', '<(SHARED_INTERMEDIATE_DIR)/device/serial/serial_serialization.mojom.cc', '<(SHARED_INTERMEDIATE_DIR)/device/serial/serial_serialization.mojom.h', - 'async_waiter.cc', - 'async_waiter.h', 'buffer.cc', 'buffer.h', 'data_receiver.cc', -- 2.11.4.GIT