• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_
7 
8 #include <string>
9 
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"
14 #include "content/common/content_export.h"
15 
16 template <typename T> struct DefaultSingletonTraits;
17 
18 namespace content {
19 
20 // This is a singleton object which handles sandbox requests from the
21 // renderers.
22 class CONTENT_EXPORT RenderSandboxHostLinux {
23  public:
24   // Returns the singleton instance.
25   static RenderSandboxHostLinux* GetInstance();
26 
27   // Get the file descriptor which renderers should be given in order to signal
28   // crashes to the browser.
GetRendererSocket()29   int GetRendererSocket() const {
30     DCHECK(initialized_);
31     return renderer_socket_;
32   }
33   void Init();
34 
35  private:
36   friend struct DefaultSingletonTraits<RenderSandboxHostLinux>;
37   // This object must be constructed on the main thread.
38   RenderSandboxHostLinux();
39   ~RenderSandboxHostLinux();
40 
41   bool ShutdownIPCChannel();
42 
43   // Whether Init() has been called yet.
44   bool initialized_;
45 
46   int renderer_socket_;
47   int childs_lifeline_fd_;
48 
49   scoped_ptr<SandboxIPCHandler> ipc_handler_;
50   scoped_ptr<base::DelegateSimpleThread> ipc_thread_;
51 
52   DISALLOW_COPY_AND_ASSIGN(RenderSandboxHostLinux);
53 };
54 
55 }  // namespace content
56 
57 #endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_
58