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