summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/render_sandbox_host_linux.h
blob: b9fad8821ec8701a4531fe4f7cd9c8068d270602 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_

#include <string>

#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/simple_thread.h"
#include "content/browser/renderer_host/sandbox_ipc_linux.h"
#include "content/common/content_export.h"

namespace base {
template <typename T> struct DefaultSingletonTraits;
}

namespace content {

// This is a singleton object which handles sandbox requests from the
// renderers.
class CONTENT_EXPORT RenderSandboxHostLinux {
 public:
  // Returns the singleton instance.
  static RenderSandboxHostLinux* GetInstance();

  // Get the file descriptor which renderers should be given in order to signal
  // crashes to the browser.
  int GetRendererSocket() const {
    DCHECK(initialized_);
    return renderer_socket_;
  }
  void Init();

 private:
  friend struct base::DefaultSingletonTraits<RenderSandboxHostLinux>;
  // This object must be constructed on the main thread.
  RenderSandboxHostLinux();
  ~RenderSandboxHostLinux();

  bool ShutdownIPCChannel();

  // Whether Init() has been called yet.
  bool initialized_;

  int renderer_socket_;
  int childs_lifeline_fd_;

  scoped_ptr<SandboxIPCHandler> ipc_handler_;
  scoped_ptr<base::DelegateSimpleThread> ipc_thread_;

  DISALLOW_COPY_AND_ASSIGN(RenderSandboxHostLinux);
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_RENDER_SANDBOX_HOST_LINUX_H_