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