OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/app/chrome_main_mac.h" | 5 #include "chrome/app/chrome_main_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <mach/mach.h> | |
9 #include <servers/bootstrap.h> | |
8 | 10 |
9 #include <string> | 11 #include <string> |
10 | 12 |
11 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
12 #include "base/file_path.h" | 14 #include "base/file_path.h" |
13 #include "base/logging.h" | 15 #include "base/logging.h" |
14 #import "base/mac/foundation_util.h" | 16 #import "base/mac/foundation_util.h" |
15 #import "base/mac/scoped_nsautorelease_pool.h" | 17 #import "base/mac/scoped_nsautorelease_pool.h" |
16 #include "base/sys_string_conversions.h" | 18 #include "base/sys_string_conversions.h" |
17 #include "chrome/browser/policy/policy_path_parser.h" | 19 #include "chrome/browser/policy/policy_path_parser.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
36 } | 38 } |
37 | 39 |
38 void SetUpBundleOverrides() { | 40 void SetUpBundleOverrides() { |
39 base::mac::ScopedNSAutoreleasePool pool; | 41 base::mac::ScopedNSAutoreleasePool pool; |
40 | 42 |
41 base::mac::SetOverrideAppBundlePath(chrome::GetFrameworkBundlePath()); | 43 base::mac::SetOverrideAppBundlePath(chrome::GetFrameworkBundlePath()); |
42 | 44 |
43 NSBundle* base_bundle = chrome::OuterAppBundle(); | 45 NSBundle* base_bundle = chrome::OuterAppBundle(); |
44 base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]); | 46 base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]); |
45 } | 47 } |
48 | |
49 void SwitchToMachBootstrapSubsetPort() { | |
50 // Testing tip: use launchctl bstree (as root) to make sure that the | |
51 // subset port is created properly and that new mappings wind up added to | |
52 // the subset port. | |
53 | |
54 #ifndef NDEBUG | |
55 static bool once_only; | |
Avi (use Gerrit)
2011/09/28 04:36:24
explicit false initialization?
Mark Mentovai
2011/09/28 04:41:31
Avi wrote:
| |
56 DCHECK(!once_only); | |
57 once_only = true; | |
58 #endif | |
59 | |
60 mach_port_t self_task = mach_task_self(); | |
61 | |
62 mach_port_t original_bootstrap_port; | |
63 kern_return_t kr = task_get_bootstrap_port(self_task, | |
64 &original_bootstrap_port); | |
65 if (kr != KERN_SUCCESS) { | |
66 LOG(ERROR) << "task_get_bootstrap_port: " << kr << " " | |
67 << mach_error_string(kr); | |
68 return; | |
69 } | |
70 | |
71 mach_port_t bootstrap_subset_port; | |
72 kr = bootstrap_subset(original_bootstrap_port, | |
73 self_task, | |
74 &bootstrap_subset_port); | |
75 if (kr != KERN_SUCCESS) { | |
76 LOG(ERROR) << "bootstrap_subset: " << kr << " " << bootstrap_strerror(kr); | |
77 return; | |
78 } | |
79 | |
80 kr = task_set_bootstrap_port(self_task, bootstrap_subset_port); | |
81 if (kr != KERN_SUCCESS) { | |
82 LOG(ERROR) << "task_set_bootstrap_port: " << kr << " " | |
83 << mach_error_string(kr); | |
84 return; | |
85 } | |
86 | |
87 // Users of the bootstrap port often access it through this global variable. | |
88 bootstrap_port = bootstrap_subset_port; | |
89 } | |
OLD | NEW |