Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/chrome_browser_main_mac.mm

Issue 11369186: Merge trunk r166585 to the 24.0.1312 branch. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/browser/chrome_browser_main_mac.h" 5 #include "chrome/browser/chrome_browser_main_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <sys/sysctl.h>
8 9
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/debug/debugger.h" 11 #include "base/debug/debugger.h"
11 #include "base/file_path.h" 12 #include "base/file_path.h"
12 #include "base/mac/bundle_locations.h" 13 #include "base/mac/bundle_locations.h"
13 #include "base/mac/mac_util.h" 14 #include "base/mac/mac_util.h"
14 #include "base/memory/scoped_nsobject.h" 15 #include "base/memory/scoped_nsobject.h"
16 #include "base/metrics/histogram.h"
15 #include "base/path_service.h" 17 #include "base/path_service.h"
16 #include "chrome/app/breakpad_mac.h" 18 #include "chrome/app/breakpad_mac.h"
17 #import "chrome/browser/app_controller_mac.h" 19 #import "chrome/browser/app_controller_mac.h"
18 #import "chrome/browser/chrome_browser_application_mac.h" 20 #import "chrome/browser/chrome_browser_application_mac.h"
19 #include "chrome/browser/mac/install_from_dmg.h" 21 #include "chrome/browser/mac/install_from_dmg.h"
20 #include "chrome/browser/mac/keychain_reauthorize.h" 22 #include "chrome/browser/mac/keychain_reauthorize.h"
21 #import "chrome/browser/mac/keystone_glue.h" 23 #import "chrome/browser/mac/keystone_glue.h"
22 #include "chrome/browser/metrics/metrics_service.h" 24 #include "chrome/browser/metrics/metrics_service.h"
23 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h" 25 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h"
24 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
(...skipping 17 matching lines...) Expand all
42 // the at-launch KeychainReauthorize. To account for them, there's also an 44 // the at-launch KeychainReauthorize. To account for them, there's also an
43 // at-update KeychainReauthorize option, which runs from .keystone_install for 45 // at-update KeychainReauthorize option, which runs from .keystone_install for
44 // users on a user Keystone ticket. This operation may make sense for a period 46 // users on a user Keystone ticket. This operation may make sense for a period
45 // of time after the application switches to being signed by the new 47 // of time after the application switches to being signed by the new
46 // certificate, as long as the at-update stub executable is still signed by 48 // certificate, as long as the at-update stub executable is still signed by
47 // the old one. 49 // the old one.
48 NSString* const kKeychainReauthorizeAtUpdatePref = 50 NSString* const kKeychainReauthorizeAtUpdatePref =
49 @"KeychainReauthorizeAtUpdateMay2012"; 51 @"KeychainReauthorizeAtUpdateMay2012";
50 const int kKeychainReauthorizeAtUpdateMaxTries = 3; 52 const int kKeychainReauthorizeAtUpdateMaxTries = 3;
51 53
54 // This is one enum instead of two so that the values can be correlated in a
55 // histogram.
56 enum CatSixtyFour {
57 // Older than any expected cat.
58 SABER_TOOTHED_CAT_32 = 0,
59 SABER_TOOTHED_CAT_64,
60
61 // Known cats.
62 SNOW_LEOPARD_32,
63 SNOW_LEOPARD_64,
64 LION_32, // Unexpected, Lion requires a 64-bit CPU.
65 LION_64,
66 MOUNTAIN_LION_32, // Unexpected, Mountain Lion requires a 64-bit CPU.
67 MOUNTAIN_LION_64,
68
69 // DON'T add new constants here. It's important to keep the constant values,
70 // um, constant. Add new constants at the bottom.
71
72 // Newer than any known cat.
73 FUTURE_CAT_32, // Unexpected, it's unlikely Apple will un-obsolete old CPUs.
74 FUTURE_CAT_64,
75
76 // What if the bitsiness of the CPU can't be determined?
77 SABER_TOOTHED_CAT_DUNNO,
78 SNOW_LEOPARD_DUNNO,
79 LION_DUNNO,
80 MOUNTAIN_LION_DUNNO,
81 FUTURE_CAT_DUNNO,
82
83 // Add new constants here.
84
85 CAT_SIXTY_FOUR_MAX
86 };
87
88 CatSixtyFour CatSixtyFourValue() {
89 #if defined(ARCH_CPU_64_BITS)
90 // If 64-bit code is running, then it's established that this CPU can run
91 // 64-bit code, and no further inquiry is necessary.
92 int cpu64 = 1;
93 bool cpu64_known = true;
94 #else
95 // Check a sysctl conveniently provided by the kernel that identifies
96 // whether the CPU supports 64-bit operation. Note that this tests the
97 // actual hardware capabilities, not the bitsiness of the running process,
98 // and not the bitsiness of the running kernel. The value thus determines
99 // whether the CPU is capable of running 64-bit programs (in the presence of
100 // proper OS runtime support) without regard to whether the current program
101 // is 64-bit (it may not be) or whether the current kernel is (the kernel
102 // can launch cross-bitted user-space tasks).
103
104 int cpu64;
105 size_t len = sizeof(cpu64);
106 const char kSysctlName[] = "hw.cpu64bit_capable";
107 bool cpu64_known = sysctlbyname(kSysctlName, &cpu64, &len, NULL, 0) == 0;
108 if (!cpu64_known) {
109 PLOG(WARNING) << "sysctlbyname(\"" << kSysctlName << "\")";
110 }
111 #endif
112
113 if (base::mac::IsOSSnowLeopard()) {
114 return cpu64_known ? (cpu64 ? SNOW_LEOPARD_64 : SNOW_LEOPARD_32) :
115 SNOW_LEOPARD_DUNNO;
116 }
117 if (base::mac::IsOSLion()) {
118 return cpu64_known ? (cpu64 ? LION_64 : LION_32) :
119 LION_DUNNO;
120 }
121 if (base::mac::IsOSMountainLion()) {
122 return cpu64_known ? (cpu64 ? MOUNTAIN_LION_64 : MOUNTAIN_LION_32) :
123 MOUNTAIN_LION_DUNNO;
124 }
125 if (base::mac::IsOSLaterThanMountainLion_DontCallThis()) {
126 return cpu64_known ? (cpu64 ? FUTURE_CAT_64 : FUTURE_CAT_32) :
127 FUTURE_CAT_DUNNO;
128 }
129
130 // If it's not any of the expected OS versions or later than them, it must
131 // be prehistoric.
132 return cpu64_known ? (cpu64 ? SABER_TOOTHED_CAT_64 : SABER_TOOTHED_CAT_32) :
133 SABER_TOOTHED_CAT_DUNNO;
134 }
135
136 void RecordCatSixtyFour() {
137 CatSixtyFour cat_sixty_four = CatSixtyFourValue();
138
139 // Set this higher than the highest value in the CatSixtyFour enum to
140 // provide some headroom and then leave it alone. See HISTOGRAM_ENUMERATION
141 // in base/metrics/histogram.h.
142 const int kMaxCatsAndSixtyFours = 32;
143 COMPILE_ASSERT(kMaxCatsAndSixtyFours >= CAT_SIXTY_FOUR_MAX,
144 CatSixtyFour_enum_grew_too_large);
145
146 UMA_HISTOGRAM_ENUMERATION("OSX.CatSixtyFour",
147 cat_sixty_four,
148 kMaxCatsAndSixtyFours);
149 }
150
52 } // namespace 151 } // namespace
53 152
54 void RecordBreakpadStatusUMA(MetricsService* metrics) { 153 void RecordBreakpadStatusUMA(MetricsService* metrics) {
55 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled()); 154 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled());
56 metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged()); 155 metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged());
57 } 156 }
58 157
59 void WarnAboutMinimumSystemRequirements() { 158 void WarnAboutMinimumSystemRequirements() {
60 // Nothing to check for on Mac right now. 159 // Nothing to check for on Mac right now.
61 } 160 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 194
96 exit(0); 195 exit(0);
97 } 196 }
98 197
99 ChromeBrowserMainPartsPosix::PreEarlyInitialization(); 198 ChromeBrowserMainPartsPosix::PreEarlyInitialization();
100 199
101 if (base::mac::WasLaunchedAsHiddenLoginItem()) { 200 if (base::mac::WasLaunchedAsHiddenLoginItem()) {
102 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); 201 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess();
103 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); 202 singleton_command_line->AppendSwitch(switches::kNoStartupWindow);
104 } 203 }
204
205 RecordCatSixtyFour();
105 } 206 }
106 207
107 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { 208 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() {
108 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart(); 209 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart();
109 210
110 // Tell Cooca to finish its initialization, which we want to do manually 211 // Tell Cooca to finish its initialization, which we want to do manually
111 // instead of calling NSApplicationMain(). The primary reason is that NSAM() 212 // instead of calling NSApplicationMain(). The primary reason is that NSAM()
112 // never returns, which would leave all the objects currently on the stack 213 // never returns, which would leave all the objects currently on the stack
113 // in scoped_ptrs hanging and never cleaned up. We then load the main nib 214 // in scoped_ptrs hanging and never cleaned up. We then load the main nib
114 // directly. The main event loop is run from common code using the 215 // directly. The main event loop is run from common code using the
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 void ChromeBrowserMainPartsMac::PreProfileInit() { 283 void ChromeBrowserMainPartsMac::PreProfileInit() {
183 removable_device_notifications_mac_ = 284 removable_device_notifications_mac_ =
184 new chrome::RemovableDeviceNotificationsMac(); 285 new chrome::RemovableDeviceNotificationsMac();
185 ChromeBrowserMainPartsPosix::PreProfileInit(); 286 ChromeBrowserMainPartsPosix::PreProfileInit();
186 } 287 }
187 288
188 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { 289 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() {
189 AppController* appController = [NSApp delegate]; 290 AppController* appController = [NSApp delegate];
190 [appController didEndMainMessageLoop]; 291 [appController didEndMainMessageLoop];
191 } 292 }
OLDNEW
« no previous file with comments | « base/process_util_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698