OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/bootstrap_sandbox_mac.h" | 5 #include "content/browser/bootstrap_sandbox_mac.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 public: | 24 public: |
25 static BootstrapSandboxPolicy* GetInstance(); | 25 static BootstrapSandboxPolicy* GetInstance(); |
26 | 26 |
27 sandbox::BootstrapSandbox* sandbox() const { | 27 sandbox::BootstrapSandbox* sandbox() const { |
28 return sandbox_.get(); | 28 return sandbox_.get(); |
29 } | 29 } |
30 | 30 |
31 // BrowserChildProcessObserver: | 31 // BrowserChildProcessObserver: |
32 void BrowserChildProcessHostDisconnected( | 32 void BrowserChildProcessHostDisconnected( |
33 const ChildProcessData& data) override; | 33 const ChildProcessData& data) override; |
34 void BrowserChildProcessCrashed(const ChildProcessData& data) override; | 34 void BrowserChildProcessCrashed( |
| 35 const ChildProcessData& data, |
| 36 int exit_code) override; |
35 | 37 |
36 private: | 38 private: |
37 friend struct DefaultSingletonTraits<BootstrapSandboxPolicy>; | 39 friend struct DefaultSingletonTraits<BootstrapSandboxPolicy>; |
38 BootstrapSandboxPolicy(); | 40 BootstrapSandboxPolicy(); |
39 ~BootstrapSandboxPolicy() override; | 41 ~BootstrapSandboxPolicy() override; |
40 | 42 |
41 void RegisterSandboxPolicies(); | 43 void RegisterSandboxPolicies(); |
42 | 44 |
43 scoped_ptr<sandbox::BootstrapSandbox> sandbox_; | 45 scoped_ptr<sandbox::BootstrapSandbox> sandbox_; |
44 }; | 46 }; |
45 | 47 |
46 BootstrapSandboxPolicy* BootstrapSandboxPolicy::GetInstance() { | 48 BootstrapSandboxPolicy* BootstrapSandboxPolicy::GetInstance() { |
47 return Singleton<BootstrapSandboxPolicy>::get(); | 49 return Singleton<BootstrapSandboxPolicy>::get(); |
48 } | 50 } |
49 | 51 |
50 void BootstrapSandboxPolicy::BrowserChildProcessHostDisconnected( | 52 void BootstrapSandboxPolicy::BrowserChildProcessHostDisconnected( |
51 const ChildProcessData& data) { | 53 const ChildProcessData& data) { |
52 sandbox()->ChildDied(data.handle); | 54 sandbox()->ChildDied(data.handle); |
53 } | 55 } |
54 | 56 |
55 void BootstrapSandboxPolicy::BrowserChildProcessCrashed( | 57 void BootstrapSandboxPolicy::BrowserChildProcessCrashed( |
56 const ChildProcessData& data) { | 58 const ChildProcessData& data, |
| 59 int exit_code) { |
57 sandbox()->ChildDied(data.handle); | 60 sandbox()->ChildDied(data.handle); |
58 } | 61 } |
59 | 62 |
60 BootstrapSandboxPolicy::BootstrapSandboxPolicy() | 63 BootstrapSandboxPolicy::BootstrapSandboxPolicy() |
61 : sandbox_(sandbox::BootstrapSandbox::Create()) { | 64 : sandbox_(sandbox::BootstrapSandbox::Create()) { |
62 CHECK(sandbox_.get()); | 65 CHECK(sandbox_.get()); |
63 BrowserChildProcessObserver::Add(this); | 66 BrowserChildProcessObserver::Add(this); |
64 RegisterSandboxPolicies(); | 67 RegisterSandboxPolicies(); |
65 } | 68 } |
66 | 69 |
67 BootstrapSandboxPolicy::~BootstrapSandboxPolicy() { | 70 BootstrapSandboxPolicy::~BootstrapSandboxPolicy() { |
68 BrowserChildProcessObserver::Remove(this); | 71 BrowserChildProcessObserver::Remove(this); |
69 } | 72 } |
70 | 73 |
71 void BootstrapSandboxPolicy::RegisterSandboxPolicies() { | 74 void BootstrapSandboxPolicy::RegisterSandboxPolicies() { |
72 } | 75 } |
73 | 76 |
74 } // namespace | 77 } // namespace |
75 | 78 |
76 bool ShouldEnableBootstrapSandbox() { | 79 bool ShouldEnableBootstrapSandbox() { |
77 return base::mac::IsOSMountainLionOrEarlier() || | 80 return base::mac::IsOSMountainLionOrEarlier() || |
78 base::mac::IsOSMavericks(); | 81 base::mac::IsOSMavericks(); |
79 } | 82 } |
80 | 83 |
81 sandbox::BootstrapSandbox* GetBootstrapSandbox() { | 84 sandbox::BootstrapSandbox* GetBootstrapSandbox() { |
82 return BootstrapSandboxPolicy::GetInstance()->sandbox(); | 85 return BootstrapSandboxPolicy::GetInstance()->sandbox(); |
83 } | 86 } |
84 | 87 |
85 } // namespace content | 88 } // namespace content |
OLD | NEW |