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/helper_process.h b/patchpanel/helper_process.h
new file mode 100644
index 0000000..79609cd
--- /dev/null
+++ b/patchpanel/helper_process.h
@@ -0,0 +1,67 @@
+// Copyright 2016 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_HELPER_PROCESS_H_
+#define PATCHPANEL_HELPER_PROCESS_H_
+
+#include <sys/types.h>
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include <base/files/scoped_file.h>
+#include <base/macros.h>
+#include <google/protobuf/message_lite.h>
+
+#include "patchpanel/message_dispatcher.h"
+
+namespace patchpanel {
+
+// Tracks a helper subprocess.  Handles forking, cleaning up on termination,
+// and IPC.
+// This object is used by the main Manager process.
+class HelperProcess {
+ public:
+  HelperProcess() = default;
+  virtual ~HelperProcess() = default;
+
+  // Re-execs patchpanel with a new argument: "|fd_arg|=N", where N is the
+  // side of |control_fd|.  This tells the subprocess to start up a different
+  // mainloop.
+  void Start(int argc, char* argv[], const std::string& fd_arg);
+
+  // Attempts to restart the process with the original arguments.
+  // Returns false if the maximum number of restarts has been exceeded.
+  bool Restart();
+
+  // Serializes a protobuf and sends it to the helper process.
+  void SendMessage(const google::protobuf::MessageLite& proto) const;
+
+  // Start listening on messages from subprocess and dispatching them to
+  // handlers. This function can only be called after that the message loop of
+  // main process is initialized.
+  void Listen();
+
+  void RegisterDeviceMessageHandler(
+      const base::Callback<void(const DeviceMessage&)>& handler);
+
+  pid_t pid() const { return pid_; }
+  uint8_t restarts() const { return restarts_; }
+
+ private:
+  void Launch();
+
+  pid_t pid_{0};
+  uint8_t restarts_{0};
+  std::vector<std::string> argv_;
+  std::string fd_arg_;
+  std::unique_ptr<MessageDispatcher> msg_dispatcher_;
+
+  DISALLOW_COPY_AND_ASSIGN(HelperProcess);
+};
+
+}  // namespace patchpanel
+
+#endif  // PATCHPANEL_HELPER_PROCESS_H_