Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / sandbox_ipc_linux.h
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 // http://code.google.com/p/chromium/wiki/LinuxSandboxIPC
6
7 #ifndef CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_
8 #define CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_
9
10 #include <vector>
11
12 #include "base/files/scoped_file.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/pickle.h"
15 #include "base/threading/simple_thread.h"
16 #include "content/child/blink_platform_impl.h"
17 #include "skia/ext/skia_utils_base.h"
18
19 namespace content {
20
21 class SandboxIPCHandler : public base::DelegateSimpleThread::Delegate {
22  public:
23   // lifeline_fd: the read end of a pipe which the main thread holds
24   // the other end of.
25   // browser_socket: the browser's end of the sandbox IPC socketpair.
26   SandboxIPCHandler(int lifeline_fd, int browser_socket);
27   ~SandboxIPCHandler() override;
28
29   void Run() override;
30
31  private:
32   void EnsureWebKitInitialized();
33
34   int FindOrAddPath(const SkString& path);
35
36   void HandleRequestFromRenderer(int fd);
37
38   void HandleFontMatchRequest(int fd,
39                               const Pickle& pickle,
40                               PickleIterator iter,
41                               const std::vector<base::ScopedFD*>& fds);
42
43   void HandleFontOpenRequest(int fd,
44                              const Pickle& pickle,
45                              PickleIterator iter,
46                              const std::vector<base::ScopedFD*>& fds);
47
48   void HandleGetFallbackFontForChar(int fd,
49                                   const Pickle& pickle,
50                                   PickleIterator iter,
51                                   const std::vector<base::ScopedFD*>& fds);
52
53   void HandleGetStyleForStrike(int fd,
54                                const Pickle& pickle,
55                                PickleIterator iter,
56                                const std::vector<base::ScopedFD*>& fds);
57
58   void HandleLocaltime(int fd,
59                        const Pickle& pickle,
60                        PickleIterator iter,
61                        const std::vector<base::ScopedFD*>& fds);
62
63   void HandleMakeSharedMemorySegment(int fd,
64                                      const Pickle& pickle,
65                                      PickleIterator iter,
66                                      const std::vector<base::ScopedFD*>& fds);
67
68   void HandleMatchWithFallback(int fd,
69                                const Pickle& pickle,
70                                PickleIterator iter,
71                                const std::vector<base::ScopedFD*>& fds);
72
73   void SendRendererReply(const std::vector<base::ScopedFD*>& fds,
74                          const Pickle& reply,
75                          int reply_fd);
76
77   const int lifeline_fd_;
78   const int browser_socket_;
79   scoped_ptr<BlinkPlatformImpl> blink_platform_impl_;
80   SkTDArray<SkString*> paths_;
81
82   DISALLOW_COPY_AND_ASSIGN(SandboxIPCHandler);
83 };
84
85 }  // namespace content
86
87 #endif  // CONTENT_BROWSER_RENDERER_HOST_SANDBOX_IPC_H_