1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // https://chromium.googlesource.com/chromium/src/+/master/docs/linux/sandbox_ipc.md
6 
7 #ifndef CONTENT_BROWSER_SANDBOX_IPC_LINUX_H_
8 #define CONTENT_BROWSER_SANDBOX_IPC_LINUX_H_
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include "base/files/scoped_file.h"
15 #include "base/macros.h"
16 #include "base/pickle.h"
17 #include "base/threading/simple_thread.h"
18 #include "content/common/content_export.h"
19 #include "third_party/icu/source/common/unicode/uchar.h"
20 
21 namespace content {
22 
23 class SandboxIPCHandler : public base::DelegateSimpleThread::Delegate {
24  public:
25   // lifeline_fd: the read end of a pipe which the main thread holds
26   // the other end of.
27   // browser_socket: the browser's end of the sandbox IPC socketpair.
28   SandboxIPCHandler(int lifeline_fd, int browser_socket);
29   ~SandboxIPCHandler() override;
30 
31   void Run() override;
32 
33  private:
34   void HandleRequestFromChild(int fd);
35 
36   void HandleMakeSharedMemorySegment(int fd,
37                                      base::PickleIterator iter,
38                                      const std::vector<base::ScopedFD>& fds);
39 
40   void SendRendererReply(const std::vector<base::ScopedFD>& fds,
41                          const base::Pickle& reply,
42                          int reply_fd);
43 
44   const int lifeline_fd_;
45   const int browser_socket_;
46 
47   DISALLOW_COPY_AND_ASSIGN(SandboxIPCHandler);
48 };
49 
50 }  // namespace content
51 
52 #endif  // CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_LINUX_H_
53