OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_ | 7 #ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_ |
8 #define CHROME_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_ | 8 #define CHROME_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/singleton.h" | 14 |
| 15 template <typename T> struct DefaultSingletonTraits; |
15 | 16 |
16 // This is a singleton object which handles sandbox requests from the | 17 // This is a singleton object which handles sandbox requests from the |
17 // renderers. | 18 // renderers. |
18 class RenderSandboxHostLinux { | 19 class RenderSandboxHostLinux { |
19 public: | 20 public: |
| 21 // Returns the singleton instance. |
| 22 static RenderSandboxHostLinux* GetInstance(); |
| 23 |
20 // Get the file descriptor which renderers should be given in order to signal | 24 // Get the file descriptor which renderers should be given in order to signal |
21 // crashes to the browser. | 25 // crashes to the browser. |
22 int GetRendererSocket() const { | 26 int GetRendererSocket() const { |
23 DCHECK(initialized_); | 27 DCHECK(initialized_); |
24 return renderer_socket_; | 28 return renderer_socket_; |
25 } | 29 } |
26 pid_t pid() const { | 30 pid_t pid() const { |
27 DCHECK(initialized_); | 31 DCHECK(initialized_); |
28 return pid_; | 32 return pid_; |
29 } | 33 } |
30 void Init(const std::string& sandbox_path); | 34 void Init(const std::string& sandbox_path); |
31 | 35 |
32 private: | 36 private: |
33 friend struct DefaultSingletonTraits<RenderSandboxHostLinux>; | 37 friend struct DefaultSingletonTraits<RenderSandboxHostLinux>; |
34 // This object must be constructed on the main thread. | 38 // This object must be constructed on the main thread. |
35 RenderSandboxHostLinux(); | 39 RenderSandboxHostLinux(); |
36 ~RenderSandboxHostLinux(); | 40 ~RenderSandboxHostLinux(); |
37 | 41 |
38 // Whether Init() has been called yet. | 42 // Whether Init() has been called yet. |
39 bool initialized_; | 43 bool initialized_; |
40 | 44 |
41 int renderer_socket_; | 45 int renderer_socket_; |
42 int childs_lifeline_fd_; | 46 int childs_lifeline_fd_; |
43 pid_t pid_; | 47 pid_t pid_; |
44 | 48 |
45 DISALLOW_COPY_AND_ASSIGN(RenderSandboxHostLinux); | 49 DISALLOW_COPY_AND_ASSIGN(RenderSandboxHostLinux); |
46 }; | 50 }; |
47 | 51 |
48 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_ | 52 #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_ |
OLD | NEW |