OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC | 5 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC |
6 | 6 |
7 #ifndef CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_ | 7 #ifndef CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_ |
8 #define CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_ | 8 #define CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_ |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/files/scoped_file.h" | 12 #include "base/files/scoped_file.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
15 #include "base/threading/simple_thread.h" | |
16 #include "content/child/blink_platform_impl.h" | 15 #include "content/child/blink_platform_impl.h" |
17 #include "skia/ext/skia_utils_base.h" | 16 #include "skia/ext/skia_utils_base.h" |
18 | 17 |
19 namespace content { | 18 namespace content { |
20 | 19 |
21 class SandboxIPCHandler : public base::DelegateSimpleThread::Delegate { | 20 class SandboxIPCProcess { |
22 public: | 21 public: |
23 // browser_socket: the browser's end of the sandbox IPC socketpair. | 22 // lifeline_fd: this is the read end of a pipe which the browser process |
| 23 // holds the other end of. If the browser process dies, its descriptors are |
| 24 // closed and we will noticed an EOF on the pipe. That's our signal to exit. |
| 25 // browser_socket: the browser's end of the sandbox IPC socketpair. From the |
| 26 // point of view of the renderer, it's talking to the browser but this |
| 27 // object actually services the requests. |
24 // sandbox_cmd: the path of the sandbox executable. | 28 // sandbox_cmd: the path of the sandbox executable. |
25 SandboxIPCHandler(int browser_socket, | 29 SandboxIPCProcess(int lifeline_fd, |
| 30 int browser_socket, |
26 std::string sandbox_cmd); | 31 std::string sandbox_cmd); |
27 virtual ~SandboxIPCHandler(); | 32 ~SandboxIPCProcess(); |
28 | 33 |
29 virtual void Run() OVERRIDE; | 34 void Run(); |
30 | 35 |
31 private: | 36 private: |
32 void EnsureWebKitInitialized(); | 37 void EnsureWebKitInitialized(); |
33 | 38 |
34 int FindOrAddPath(const SkString& path); | 39 int FindOrAddPath(const SkString& path); |
35 | 40 |
36 void HandleRequestFromRenderer(int fd); | 41 void HandleRequestFromRenderer(int fd); |
37 | 42 |
38 void HandleFontMatchRequest(int fd, | 43 void HandleFontMatchRequest(int fd, |
39 const Pickle& pickle, | 44 const Pickle& pickle, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 77 |
73 void HandleMatchWithFallback(int fd, | 78 void HandleMatchWithFallback(int fd, |
74 const Pickle& pickle, | 79 const Pickle& pickle, |
75 PickleIterator iter, | 80 PickleIterator iter, |
76 const std::vector<base::ScopedFD*>& fds); | 81 const std::vector<base::ScopedFD*>& fds); |
77 | 82 |
78 void SendRendererReply(const std::vector<base::ScopedFD*>& fds, | 83 void SendRendererReply(const std::vector<base::ScopedFD*>& fds, |
79 const Pickle& reply, | 84 const Pickle& reply, |
80 int reply_fd); | 85 int reply_fd); |
81 | 86 |
| 87 const int lifeline_fd_; |
82 const int browser_socket_; | 88 const int browser_socket_; |
83 std::vector<std::string> sandbox_cmd_; | 89 std::vector<std::string> sandbox_cmd_; |
84 scoped_ptr<BlinkPlatformImpl> webkit_platform_support_; | 90 scoped_ptr<BlinkPlatformImpl> webkit_platform_support_; |
85 SkTDArray<SkString*> paths_; | 91 SkTDArray<SkString*> paths_; |
86 | 92 |
87 DISALLOW_COPY_AND_ASSIGN(SandboxIPCHandler); | 93 DISALLOW_COPY_AND_ASSIGN(SandboxIPCProcess); |
88 }; | 94 }; |
89 | 95 |
90 } // namespace content | 96 } // namespace content |
91 | 97 |
92 #endif // CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_ | 98 #endif // CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_ |
OLD | NEW |