EDK: Move DispatcherTransport to handle_transport.*.
I'll rename DispatcherTransport to HandleTransport separately.
R=azani@chromium.org
Review URL: https://codereview.chromium.org/1942423002 .
diff --git a/mojo/edk/system/BUILD.gn b/mojo/edk/system/BUILD.gn
index 8f724a7..789066b 100644
--- a/mojo/edk/system/BUILD.gn
+++ b/mojo/edk/system/BUILD.gn
@@ -53,6 +53,8 @@
"handle_signals_state.h",
"handle_table.cc",
"handle_table.h",
+ "handle_transport.cc",
+ "handle_transport.h",
"incoming_endpoint.cc",
"incoming_endpoint.h",
"ipc_support.cc",
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
index 57626ca..c98eeac 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -19,6 +19,7 @@
#include "mojo/edk/system/data_pipe_producer_dispatcher.h"
#include "mojo/edk/system/dispatcher.h"
#include "mojo/edk/system/handle_signals_state.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/memory.h"
#include "mojo/edk/system/message_pipe.h"
#include "mojo/edk/system/message_pipe_dispatcher.h"
diff --git a/mojo/edk/system/data_pipe_impl_unittest.cc b/mojo/edk/system/data_pipe_impl_unittest.cc
index 858044a..4fc0742 100644
--- a/mojo/edk/system/data_pipe_impl_unittest.cc
+++ b/mojo/edk/system/data_pipe_impl_unittest.cc
@@ -21,6 +21,7 @@
#include "mojo/edk/system/data_pipe.h"
#include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
#include "mojo/edk/system/data_pipe_producer_dispatcher.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/memory.h"
#include "mojo/edk/system/message_pipe.h"
#include "mojo/edk/system/raw_channel.h"
diff --git a/mojo/edk/system/dispatcher.cc b/mojo/edk/system/dispatcher.cc
index f3ef810..f143d57 100644
--- a/mojo/edk/system/dispatcher.cc
+++ b/mojo/edk/system/dispatcher.cc
@@ -8,6 +8,7 @@
#include "mojo/edk/system/configuration.h"
#include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
#include "mojo/edk/system/data_pipe_producer_dispatcher.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/message_pipe_dispatcher.h"
#include "mojo/edk/system/platform_handle_dispatcher.h"
#include "mojo/edk/system/shared_buffer_dispatcher.h"
@@ -29,8 +30,6 @@
} // namespace test
-// Dispatcher ------------------------------------------------------------------
-
// TODO(vtl): The thread-safety analyzer isn't smart enough to deal with the
// fact that we give up if |TryLock()| fails.
// static
@@ -300,8 +299,7 @@
RemoveAwakableImplNoLock(awakable, handle_signals_state);
}
-Dispatcher::Dispatcher() : is_closed_(false) {
-}
+Dispatcher::Dispatcher() : is_closed_(false) {}
Dispatcher::~Dispatcher() {
// Make sure that |Close()| was called.
@@ -573,13 +571,5 @@
platform_handles);
}
-// DispatcherTransport ---------------------------------------------------------
-
-void DispatcherTransport::End() {
- DCHECK(dispatcher_);
- dispatcher_->mutex_.Unlock();
- dispatcher_ = nullptr;
-}
-
} // namespace system
} // namespace mojo
diff --git a/mojo/edk/system/dispatcher.h b/mojo/edk/system/dispatcher.h
index fc72390..1078bdd 100644
--- a/mojo/edk/system/dispatcher.h
+++ b/mojo/edk/system/dispatcher.h
@@ -444,43 +444,6 @@
MOJO_DISALLOW_COPY_AND_ASSIGN(Dispatcher);
};
-// Wrapper around a |Dispatcher| pointer, while it's being processed to be
-// passed in a message pipe. See the comment about
-// |Dispatcher::HandleTableAccess| for more details.
-//
-// Note: This class is deliberately "thin" -- no more expensive than a
-// |Dispatcher*|.
-class DispatcherTransport final {
- public:
- DispatcherTransport() : dispatcher_(nullptr) {}
-
- void End() MOJO_NOT_THREAD_SAFE;
-
- Dispatcher::Type GetType() const { return dispatcher_->GetType(); }
- bool IsBusy() const MOJO_NOT_THREAD_SAFE {
- return dispatcher_->IsBusyNoLock();
- }
- void Close() MOJO_NOT_THREAD_SAFE { dispatcher_->CloseNoLock(); }
- util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndClose(
- MessagePipe* message_pipe,
- unsigned port) MOJO_NOT_THREAD_SAFE {
- return dispatcher_->CreateEquivalentDispatcherAndCloseNoLock(message_pipe,
- port);
- }
-
- bool is_valid() const { return !!dispatcher_; }
-
- private:
- friend class Dispatcher::HandleTableAccess;
-
- explicit DispatcherTransport(Dispatcher* dispatcher)
- : dispatcher_(dispatcher) {}
-
- Dispatcher* dispatcher_;
-
- // Copy and assign allowed.
-};
-
// So logging macros and |DCHECK_EQ()|, etc. work.
inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) {
return out << static_cast<int>(type);
diff --git a/mojo/edk/system/handle_table.cc b/mojo/edk/system/handle_table.cc
index 928b1dd..b33e7e3 100644
--- a/mojo/edk/system/handle_table.cc
+++ b/mojo/edk/system/handle_table.cc
@@ -10,14 +10,14 @@
#include "base/logging.h"
#include "mojo/edk/system/configuration.h"
#include "mojo/edk/system/dispatcher.h"
+#include "mojo/edk/system/handle_transport.h"
using mojo::util::RefPtr;
namespace mojo {
namespace system {
-HandleTable::Entry::Entry() : busy(false) {
-}
+HandleTable::Entry::Entry() : busy(false) {}
HandleTable::Entry::Entry(Handle&& handle)
: handle(std::move(handle)), busy(false) {}
diff --git a/mojo/edk/system/handle_transport.cc b/mojo/edk/system/handle_transport.cc
new file mode 100644
index 0000000..37925ea
--- /dev/null
+++ b/mojo/edk/system/handle_transport.cc
@@ -0,0 +1,19 @@
+// Copyright 2016 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 "mojo/edk/system/handle_transport.h"
+
+#include "base/logging.h"
+
+namespace mojo {
+namespace system {
+
+void DispatcherTransport::End() {
+ DCHECK(dispatcher_);
+ dispatcher_->mutex_.Unlock();
+ dispatcher_ = nullptr;
+}
+
+} // namespace system
+} // namespace mojo
diff --git a/mojo/edk/system/handle_transport.h b/mojo/edk/system/handle_transport.h
new file mode 100644
index 0000000..eb60001
--- /dev/null
+++ b/mojo/edk/system/handle_transport.h
@@ -0,0 +1,59 @@
+// Copyright 2016 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 MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_
+#define MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_
+
+#include "mojo/edk/system/dispatcher.h"
+#include "mojo/edk/util/ref_ptr.h"
+#include "mojo/edk/util/thread_annotations.h"
+
+namespace mojo {
+namespace system {
+
+class MessagePipe;
+
+// Wrapper around a |Dispatcher| pointer, while it's being processed to be
+// passed in a message pipe. See the comment about
+// |Dispatcher::HandleTableAccess| for more details.
+//
+// Note: This class is deliberately "thin" -- no more expensive than a
+// |Dispatcher*|.
+//
+// TODO(vtl): Add handle rights to this, and rename it to HandleTransport.
+class DispatcherTransport final {
+ public:
+ DispatcherTransport() : dispatcher_(nullptr) {}
+
+ void End() MOJO_NOT_THREAD_SAFE;
+
+ Dispatcher::Type GetType() const { return dispatcher_->GetType(); }
+ bool IsBusy() const MOJO_NOT_THREAD_SAFE {
+ return dispatcher_->IsBusyNoLock();
+ }
+ void Close() MOJO_NOT_THREAD_SAFE { dispatcher_->CloseNoLock(); }
+ util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndClose(
+ MessagePipe* message_pipe,
+ unsigned port) MOJO_NOT_THREAD_SAFE {
+ return dispatcher_->CreateEquivalentDispatcherAndCloseNoLock(message_pipe,
+ port);
+ }
+
+ bool is_valid() const { return !!dispatcher_; }
+
+ private:
+ friend class Dispatcher::HandleTableAccess;
+
+ explicit DispatcherTransport(Dispatcher* dispatcher)
+ : dispatcher_(dispatcher) {}
+
+ Dispatcher* dispatcher_;
+
+ // Copy and assign allowed.
+};
+
+} // namespace system
+} // namespace mojo
+
+#endif // MOJO_EDK_SYSTEM_HANDLE_TRANSPORT_H_
diff --git a/mojo/edk/system/ipc_support_unittest.cc b/mojo/edk/system/ipc_support_unittest.cc
index 2d1b73c..6978a46 100644
--- a/mojo/edk/system/ipc_support_unittest.cc
+++ b/mojo/edk/system/ipc_support_unittest.cc
@@ -16,6 +16,7 @@
#include "mojo/edk/system/channel_manager.h"
#include "mojo/edk/system/connection_identifier.h"
#include "mojo/edk/system/dispatcher.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/message_pipe.h"
#include "mojo/edk/system/message_pipe_dispatcher.h"
#include "mojo/edk/system/process_identifier.h"
diff --git a/mojo/edk/system/message_pipe.cc b/mojo/edk/system/message_pipe.cc
index cb8fc23..4303f3f 100644
--- a/mojo/edk/system/message_pipe.cc
+++ b/mojo/edk/system/message_pipe.cc
@@ -11,6 +11,7 @@
#include "mojo/edk/system/channel.h"
#include "mojo/edk/system/channel_endpoint.h"
#include "mojo/edk/system/channel_endpoint_id.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/incoming_endpoint.h"
#include "mojo/edk/system/local_message_pipe_endpoint.h"
#include "mojo/edk/system/message_in_transit.h"
@@ -317,8 +318,7 @@
Close(port);
}
-MessagePipe::MessagePipe() {
-}
+MessagePipe::MessagePipe() {}
MessagePipe::~MessagePipe() {
// Owned by the dispatchers. The owning dispatchers should only release us via
diff --git a/mojo/edk/system/message_pipe_dispatcher.cc b/mojo/edk/system/message_pipe_dispatcher.cc
index a0d5d02..172cfc2 100644
--- a/mojo/edk/system/message_pipe_dispatcher.cc
+++ b/mojo/edk/system/message_pipe_dispatcher.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "mojo/edk/system/configuration.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/local_message_pipe_endpoint.h"
#include "mojo/edk/system/memory.h"
#include "mojo/edk/system/message_pipe.h"
diff --git a/mojo/edk/system/multiprocess_message_pipe_unittest.cc b/mojo/edk/system/multiprocess_message_pipe_unittest.cc
index 79d7113..6154680 100644
--- a/mojo/edk/system/multiprocess_message_pipe_unittest.cc
+++ b/mojo/edk/system/multiprocess_message_pipe_unittest.cc
@@ -19,6 +19,7 @@
#include "mojo/edk/platform/scoped_platform_handle.h"
#include "mojo/edk/system/channel.h"
#include "mojo/edk/system/dispatcher.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/message_pipe.h"
#include "mojo/edk/system/message_pipe_test_utils.h"
#include "mojo/edk/system/platform_handle_dispatcher.h"
diff --git a/mojo/edk/system/platform_handle_dispatcher_unittest.cc b/mojo/edk/system/platform_handle_dispatcher_unittest.cc
index 938c220..eb7ebed 100644
--- a/mojo/edk/system/platform_handle_dispatcher_unittest.cc
+++ b/mojo/edk/system/platform_handle_dispatcher_unittest.cc
@@ -9,6 +9,7 @@
#include <utility>
#include "mojo/edk/platform/platform_handle_utils_posix.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/test/scoped_test_dir.h"
#include "mojo/edk/util/scoped_file.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/mojo/edk/system/remote_data_pipe_impl_unittest.cc b/mojo/edk/system/remote_data_pipe_impl_unittest.cc
index c0880fb..36e426e 100644
--- a/mojo/edk/system/remote_data_pipe_impl_unittest.cc
+++ b/mojo/edk/system/remote_data_pipe_impl_unittest.cc
@@ -18,6 +18,7 @@
#include "mojo/edk/system/data_pipe.h"
#include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
#include "mojo/edk/system/data_pipe_producer_dispatcher.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/memory.h"
#include "mojo/edk/system/message_pipe.h"
#include "mojo/edk/system/raw_channel.h"
diff --git a/mojo/edk/system/remote_message_pipe_unittest.cc b/mojo/edk/system/remote_message_pipe_unittest.cc
index 251b432..a528043 100644
--- a/mojo/edk/system/remote_message_pipe_unittest.cc
+++ b/mojo/edk/system/remote_message_pipe_unittest.cc
@@ -20,6 +20,7 @@
#include "mojo/edk/system/channel.h"
#include "mojo/edk/system/channel_endpoint.h"
#include "mojo/edk/system/channel_endpoint_id.h"
+#include "mojo/edk/system/handle_transport.h"
#include "mojo/edk/system/incoming_endpoint.h"
#include "mojo/edk/system/message_pipe.h"
#include "mojo/edk/system/message_pipe_dispatcher.h"