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