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

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

Issue 11348360: Speculatively reverting 166585 to see if it fixes issue 160300 - 6% startup regression on Mac 10.6 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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>
9 8
10 #include "base/command_line.h" 9 #include "base/command_line.h"
11 #include "base/debug/debugger.h" 10 #include "base/debug/debugger.h"
12 #include "base/file_path.h" 11 #include "base/file_path.h"
13 #include "base/mac/bundle_locations.h" 12 #include "base/mac/bundle_locations.h"
14 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
15 #include "base/memory/scoped_nsobject.h" 14 #include "base/memory/scoped_nsobject.h"
16 #include "base/metrics/histogram.h"
17 #include "base/path_service.h" 15 #include "base/path_service.h"
18 #include "chrome/app/breakpad_mac.h" 16 #include "chrome/app/breakpad_mac.h"
19 #import "chrome/browser/app_controller_mac.h" 17 #import "chrome/browser/app_controller_mac.h"
20 #import "chrome/browser/chrome_browser_application_mac.h" 18 #import "chrome/browser/chrome_browser_application_mac.h"
21 #include "chrome/browser/mac/install_from_dmg.h" 19 #include "chrome/browser/mac/install_from_dmg.h"
22 #include "chrome/browser/mac/keychain_reauthorize.h" 20 #include "chrome/browser/mac/keychain_reauthorize.h"
23 #import "chrome/browser/mac/keystone_glue.h" 21 #import "chrome/browser/mac/keystone_glue.h"
24 #include "chrome/browser/metrics/metrics_service.h" 22 #include "chrome/browser/metrics/metrics_service.h"
25 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h" 23 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h"
26 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
(...skipping 17 matching lines...) Expand all
44 // the at-launch KeychainReauthorize. To account for them, there's also an 42 // the at-launch KeychainReauthorize. To account for them, there's also an
45 // at-update KeychainReauthorize option, which runs from .keystone_install for 43 // at-update KeychainReauthorize option, which runs from .keystone_install for
46 // users on a user Keystone ticket. This operation may make sense for a period 44 // users on a user Keystone ticket. This operation may make sense for a period
47 // of time after the application switches to being signed by the new 45 // of time after the application switches to being signed by the new
48 // certificate, as long as the at-update stub executable is still signed by 46 // certificate, as long as the at-update stub executable is still signed by
49 // the old one. 47 // the old one.
50 NSString* const kKeychainReauthorizeAtUpdatePref = 48 NSString* const kKeychainReauthorizeAtUpdatePref =
51 @"KeychainReauthorizeAtUpdateMay2012"; 49 @"KeychainReauthorizeAtUpdateMay2012";
52 const int kKeychainReauthorizeAtUpdateMaxTries = 3; 50 const int kKeychainReauthorizeAtUpdateMaxTries = 3;
53 51
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
151 } // namespace 52 } // namespace
152 53
153 void RecordBreakpadStatusUMA(MetricsService* metrics) { 54 void RecordBreakpadStatusUMA(MetricsService* metrics) {
154 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled()); 55 metrics->RecordBreakpadRegistration(IsCrashReporterEnabled());
155 metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged()); 56 metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged());
156 } 57 }
157 58
158 void WarnAboutMinimumSystemRequirements() { 59 void WarnAboutMinimumSystemRequirements() {
159 // Nothing to check for on Mac right now. 60 // Nothing to check for on Mac right now.
160 } 61 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 95
195 exit(0); 96 exit(0);
196 } 97 }
197 98
198 ChromeBrowserMainPartsPosix::PreEarlyInitialization(); 99 ChromeBrowserMainPartsPosix::PreEarlyInitialization();
199 100
200 if (base::mac::WasLaunchedAsHiddenLoginItem()) { 101 if (base::mac::WasLaunchedAsHiddenLoginItem()) {
201 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); 102 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess();
202 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); 103 singleton_command_line->AppendSwitch(switches::kNoStartupWindow);
203 } 104 }
204
205 RecordCatSixtyFour();
206 } 105 }
207 106
208 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { 107 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() {
209 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart(); 108 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart();
210 109
211 // Tell Cooca to finish its initialization, which we want to do manually 110 // Tell Cooca to finish its initialization, which we want to do manually
212 // instead of calling NSApplicationMain(). The primary reason is that NSAM() 111 // instead of calling NSApplicationMain(). The primary reason is that NSAM()
213 // never returns, which would leave all the objects currently on the stack 112 // never returns, which would leave all the objects currently on the stack
214 // in scoped_ptrs hanging and never cleaned up. We then load the main nib 113 // in scoped_ptrs hanging and never cleaned up. We then load the main nib
215 // directly. The main event loop is run from common code using the 114 // directly. The main event loop is run from common code using the
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 void ChromeBrowserMainPartsMac::PreProfileInit() { 182 void ChromeBrowserMainPartsMac::PreProfileInit() {
284 removable_device_notifications_mac_ = 183 removable_device_notifications_mac_ =
285 new chrome::RemovableDeviceNotificationsMac(); 184 new chrome::RemovableDeviceNotificationsMac();
286 ChromeBrowserMainPartsPosix::PreProfileInit(); 185 ChromeBrowserMainPartsPosix::PreProfileInit();
287 } 186 }
288 187
289 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { 188 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() {
290 AppController* appController = [NSApp delegate]; 189 AppController* appController = [NSApp delegate];
291 [appController didEndMainMessageLoop]; 190 [appController didEndMainMessageLoop];
292 } 191 }
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