arc: Move platform2/arc/network/ to platform2/patchpanel

Next step in the arc-networkd -> patchpanel rename, this patch moves the
location of the code.

BUG=b:151879931
TEST=units,flashed image to atlas
TEST=tasts arc.PlayStore, crostini.LaunchTerminal.download

Change-Id: I1b5cf8d670e1631d46f6449b725395157bf88dde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2115863
Tested-by: Garrick Evans <garrick@chromium.org>
Commit-Queue: Garrick Evans <garrick@chromium.org>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
diff --git a/patchpanel/message_dispatcher.h b/patchpanel/message_dispatcher.h
new file mode 100644
index 0000000..9f79bf3
--- /dev/null
+++ b/patchpanel/message_dispatcher.h
@@ -0,0 +1,55 @@
+// Copyright 2019 The Chromium OS 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 PATCHPANEL_MESSAGE_DISPATCHER_H_
+#define PATCHPANEL_MESSAGE_DISPATCHER_H_
+
+#include <memory>
+#include <string>
+
+#include <base/files/file_descriptor_watcher_posix.h>
+#include <base/files/scoped_file.h>
+#include <base/macros.h>
+#include <base/memory/weak_ptr.h>
+
+#include "patchpanel/ipc.pb.h"
+
+namespace patchpanel {
+
+// Helper message processor
+class MessageDispatcher {
+ public:
+  explicit MessageDispatcher(base::ScopedFD fd, bool start = true);
+
+  void Start();
+
+  void RegisterFailureHandler(const base::Callback<void()>& handler);
+
+  void RegisterGuestMessageHandler(
+      const base::Callback<void(const GuestMessage&)>& handler);
+
+  void RegisterDeviceMessageHandler(
+      const base::Callback<void(const DeviceMessage&)>& handler);
+
+  void SendMessage(const google::protobuf::MessageLite& proto) const;
+
+ private:
+  // Overrides MessageLoopForIO callbacks for new data on |control_fd_|.
+  void OnFileCanReadWithoutBlocking();
+
+  base::ScopedFD fd_;
+  std::unique_ptr<base::FileDescriptorWatcher::Controller> watcher_;
+  base::Callback<void()> failure_handler_;
+  base::Callback<void(const GuestMessage&)> guest_handler_;
+  base::Callback<void(const DeviceMessage&)> device_handler_;
+
+  IpHelperMessage msg_;
+
+  base::WeakPtrFactory<MessageDispatcher> weak_factory_{this};
+  DISALLOW_COPY_AND_ASSIGN(MessageDispatcher);
+};
+
+}  // namespace patchpanel
+
+#endif  // PATCHPANEL_MESSAGE_DISPATCHER_H_