Chromium Code Reviews| 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/browser/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_browser_main.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 #include "chrome/browser/profiles/profile.h" | 67 #include "chrome/browser/profiles/profile.h" |
| 68 #include "chrome/browser/profiles/profile_manager.h" | 68 #include "chrome/browser/profiles/profile_manager.h" |
| 69 #include "chrome/browser/search_engines/search_engine_type.h" | 69 #include "chrome/browser/search_engines/search_engine_type.h" |
| 70 #include "chrome/browser/search_engines/template_url.h" | 70 #include "chrome/browser/search_engines/template_url.h" |
| 71 #include "chrome/browser/search_engines/template_url_service.h" | 71 #include "chrome/browser/search_engines/template_url_service.h" |
| 72 #include "chrome/browser/search_engines/template_url_service_factory.h" | 72 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 73 #include "chrome/browser/service/service_process_control.h" | 73 #include "chrome/browser/service/service_process_control.h" |
| 74 #include "chrome/browser/shell_integration.h" | 74 #include "chrome/browser/shell_integration.h" |
| 75 #include "chrome/browser/translate/translate_manager.h" | 75 #include "chrome/browser/translate/translate_manager.h" |
| 76 #include "chrome/browser/ui/browser.h" | 76 #include "chrome/browser/ui/browser.h" |
| 77 #include "chrome/browser/ui/browser_init.h" | |
| 78 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 77 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" |
| 79 #include "chrome/browser/web_resource/gpu_blacklist_updater.h" | 78 #include "chrome/browser/web_resource/gpu_blacklist_updater.h" |
| 80 #include "chrome/common/child_process_logging.h" | 79 #include "chrome/common/child_process_logging.h" |
| 81 #include "chrome/common/chrome_constants.h" | 80 #include "chrome/common/chrome_constants.h" |
| 82 #include "chrome/common/chrome_paths.h" | 81 #include "chrome/common/chrome_paths.h" |
| 83 #include "chrome/common/chrome_result_codes.h" | 82 #include "chrome/common/chrome_result_codes.h" |
| 84 #include "chrome/common/chrome_switches.h" | 83 #include "chrome/common/chrome_switches.h" |
| 85 #include "chrome/common/chrome_version_info.h" | 84 #include "chrome/common/chrome_version_info.h" |
| 86 #include "chrome/common/env_vars.h" | 85 #include "chrome/common/env_vars.h" |
| 87 #include "chrome/common/json_pref_store.h" | 86 #include "chrome/common/json_pref_store.h" |
| 88 #include "chrome/common/jstemplate_builder.h" | 87 #include "chrome/common/jstemplate_builder.h" |
| 89 #include "chrome/common/logging_chrome.h" | 88 #include "chrome/common/logging_chrome.h" |
| 90 #include "chrome/common/net/net_resource_provider.h" | 89 #include "chrome/common/net/net_resource_provider.h" |
| 91 #include "chrome/common/pref_names.h" | 90 #include "chrome/common/pref_names.h" |
| 92 #include "chrome/common/profiling.h" | 91 #include "chrome/common/profiling.h" |
| 93 #include "chrome/installer/util/google_update_settings.h" | 92 #include "chrome/installer/util/google_update_settings.h" |
| 94 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 93 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 95 #include "content/common/child_process.h" | 94 #include "content/common/child_process.h" |
| 96 #include "content/public/browser/browser_thread.h" | 95 #include "content/public/browser/browser_thread.h" |
| 96 #include "content/public/browser/io_thread_delegate.h" | |
| 97 #include "content/public/common/content_client.h" | 97 #include "content/public/common/content_client.h" |
| 98 #include "content/public/common/main_function_params.h" | 98 #include "content/public/common/main_function_params.h" |
| 99 #include "grit/app_locale_settings.h" | 99 #include "grit/app_locale_settings.h" |
| 100 #include "grit/chromium_strings.h" | 100 #include "grit/chromium_strings.h" |
| 101 #include "grit/generated_resources.h" | 101 #include "grit/generated_resources.h" |
| 102 #include "grit/platform_locale_settings.h" | 102 #include "grit/platform_locale_settings.h" |
| 103 #include "net/base/cookie_monster.h" | 103 #include "net/base/cookie_monster.h" |
| 104 #include "net/base/net_module.h" | 104 #include "net/base/net_module.h" |
| 105 #include "net/base/sdch_manager.h" | 105 #include "net/base/sdch_manager.h" |
| 106 #include "net/http/http_basic_stream.h" | 106 #include "net/http/http_basic_stream.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 net::URLRequestThrottlerManager::GetInstance()->set_enable_thread_checks( | 301 net::URLRequestThrottlerManager::GetInstance()->set_enable_thread_checks( |
| 302 true); | 302 true); |
| 303 | 303 |
| 304 // TODO(joi): Passing the NetLog here is temporary; once I switch the | 304 // TODO(joi): Passing the NetLog here is temporary; once I switch the |
| 305 // URLRequestThrottlerManager to be part of the URLRequestContext it will | 305 // URLRequestThrottlerManager to be part of the URLRequestContext it will |
| 306 // come from there. Doing it this way for now (2011/5/12) to try to fail | 306 // come from there. Doing it this way for now (2011/5/12) to try to fail |
| 307 // fast in case A/B experiment gives unexpected results. | 307 // fast in case A/B experiment gives unexpected results. |
| 308 net::URLRequestThrottlerManager::GetInstance()->set_net_log(net_log); | 308 net::URLRequestThrottlerManager::GetInstance()->set_net_log(net_log); |
| 309 } | 309 } |
| 310 | 310 |
| 311 // Creates key child threads. We need to do this explicitly since | |
| 312 // BrowserThread::PostTask silently deletes a posted task if the target message | |
| 313 // loop isn't created. | |
| 314 void CreateChildThreads(BrowserProcessImpl* process) { | |
| 315 process->db_thread(); | |
| 316 process->file_thread(); | |
| 317 process->process_launcher_thread(); | |
| 318 process->cache_thread(); | |
| 319 process->io_thread(); | |
| 320 #if defined(OS_CHROMEOS) | |
| 321 process->web_socket_proxy_thread(); | |
| 322 #endif | |
| 323 // Create watchdog thread after creating all other threads because it will | |
| 324 // watch the other threads and they must be running. | |
| 325 process->watchdog_thread(); | |
| 326 } | |
| 327 | |
| 328 // Returns the new local state object, guaranteed non-NULL. | 311 // Returns the new local state object, guaranteed non-NULL. |
| 329 PrefService* InitializeLocalState(const CommandLine& parsed_command_line, | 312 PrefService* InitializeLocalState(const CommandLine& parsed_command_line, |
| 330 bool is_first_run) { | 313 bool is_first_run) { |
| 331 FilePath local_state_path; | 314 FilePath local_state_path; |
| 332 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 315 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
| 333 bool local_state_file_exists = file_util::PathExists(local_state_path); | 316 bool local_state_file_exists = file_util::PathExists(local_state_path); |
| 334 | 317 |
| 335 // Load local state. This includes the application locale so we know which | 318 // Load local state. This includes the application locale so we know which |
| 336 // locale dll to load. | 319 // locale dll to load. |
| 337 PrefService* local_state = g_browser_process->local_state(); | 320 PrefService* local_state = g_browser_process->local_state(); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 ChromeBrowserMainParts::ChromeBrowserMainParts( | 651 ChromeBrowserMainParts::ChromeBrowserMainParts( |
| 669 const content::MainFunctionParams& parameters) | 652 const content::MainFunctionParams& parameters) |
| 670 : parameters_(parameters), | 653 : parameters_(parameters), |
| 671 parsed_command_line_(parameters.command_line), | 654 parsed_command_line_(parameters.command_line), |
| 672 result_code_(content::RESULT_CODE_NORMAL_EXIT), | 655 result_code_(content::RESULT_CODE_NORMAL_EXIT), |
| 673 shutdown_watcher_(new ShutdownWatcherHelper()), | 656 shutdown_watcher_(new ShutdownWatcherHelper()), |
| 674 record_search_engine_(false), | 657 record_search_engine_(false), |
| 675 translate_manager_(NULL), | 658 translate_manager_(NULL), |
| 676 profile_(NULL), | 659 profile_(NULL), |
| 677 run_message_loop_(true), | 660 run_message_loop_(true), |
| 678 notify_result_(ProcessSingleton::PROCESS_NONE) { | 661 notify_result_(ProcessSingleton::PROCESS_NONE), |
| 662 is_first_run_(false), | |
| 663 first_run_ui_bypass_(false), | |
| 664 metrics_(NULL), | |
| 665 local_state_(NULL), | |
| 666 restart_last_session_(false) { | |
| 679 // If we're running tests (ui_task is non-null). | 667 // If we're running tests (ui_task is non-null). |
| 680 if (parameters.ui_task) | 668 if (parameters.ui_task) |
| 681 browser_defaults::enable_help_app = false; | 669 browser_defaults::enable_help_app = false; |
| 682 } | 670 } |
| 683 | 671 |
| 684 ChromeBrowserMainParts::~ChromeBrowserMainParts() { | 672 ChromeBrowserMainParts::~ChromeBrowserMainParts() { |
| 685 } | 673 } |
| 686 | 674 |
| 687 // This will be called after the command-line has been mutated by about:flags | 675 // This will be called after the command-line has been mutated by about:flags |
| 688 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( | 676 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1171 | 1159 |
| 1172 void ChromeBrowserMainParts::ToolkitInitialized() { | 1160 void ChromeBrowserMainParts::ToolkitInitialized() { |
| 1173 } | 1161 } |
| 1174 | 1162 |
| 1175 void ChromeBrowserMainParts::PreMainMessageLoopStart() { | 1163 void ChromeBrowserMainParts::PreMainMessageLoopStart() { |
| 1176 } | 1164 } |
| 1177 | 1165 |
| 1178 void ChromeBrowserMainParts::PostMainMessageLoopStart() { | 1166 void ChromeBrowserMainParts::PostMainMessageLoopStart() { |
| 1179 } | 1167 } |
| 1180 | 1168 |
| 1181 void ChromeBrowserMainParts::PreMainMessageLoopRun() { | 1169 content::IOThreadDelegate* ChromeBrowserMainParts::PreMainMessageLoopRun() { |
| 1182 result_code_ = PreMainMessageLoopRunImpl(); | 1170 result_code_ = PreMainMessageLoopRunImpl(); |
| 1171 return browser_process_->io_thread(); | |
| 1172 } | |
| 1173 | |
| 1174 void ChromeBrowserMainParts::PreMainMessageLoopRunThreadsCreated() { | |
| 1175 result_code_ = PreMainMessageLoopRunThreadsCreatedImpl(); | |
| 1183 } | 1176 } |
| 1184 | 1177 |
| 1185 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { | 1178 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
| 1186 run_message_loop_ = false; | 1179 run_message_loop_ = false; |
| 1187 FilePath user_data_dir; | |
| 1188 #if defined(OS_WIN) | 1180 #if defined(OS_WIN) |
| 1189 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 1181 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_); |
| 1190 #else | 1182 #else |
| 1191 // Getting the user data dir can fail if the directory isn't | 1183 // Getting the user data dir can fail if the directory isn't |
| 1192 // creatable, for example; on Windows in code below we bring up a | 1184 // creatable, for example; on Windows in code below we bring up a |
| 1193 // dialog prompting the user to pick a different directory. | 1185 // dialog prompting the user to pick a different directory. |
| 1194 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, | 1186 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, |
| 1195 // so it's better to fail here than fail mysteriously elsewhere. | 1187 // so it's better to fail here than fail mysteriously elsewhere. |
| 1196 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | 1188 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) |
| 1197 << "Must be able to get user data directory!"; | 1189 << "Must be able to get user data directory!"; |
| 1198 #endif | 1190 #endif |
| 1199 | 1191 |
| 1200 process_singleton_.reset(new ProcessSingleton(user_data_dir)); | 1192 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); |
| 1201 | 1193 |
| 1202 bool is_first_run = FirstRun::IsChromeFirstRun() || | 1194 is_first_run_ = FirstRun::IsChromeFirstRun() || |
| 1203 parsed_command_line().HasSwitch(switches::kFirstRun); | 1195 parsed_command_line().HasSwitch(switches::kFirstRun); |
| 1204 | 1196 |
| 1205 #if defined(USE_AURA) | 1197 #if defined(USE_AURA) |
| 1206 // No first run on Aura. See crbug.com/99439. | 1198 // No first run on Aura. See crbug.com/99439. |
| 1207 is_first_run = false; | 1199 is_first_run_ = false; |
| 1208 #endif | 1200 #endif |
| 1209 | 1201 |
| 1210 if (parsed_command_line().HasSwitch(switches::kImport) || | 1202 if (parsed_command_line().HasSwitch(switches::kImport) || |
| 1211 parsed_command_line().HasSwitch(switches::kImportFromFile)) { | 1203 parsed_command_line().HasSwitch(switches::kImportFromFile)) { |
| 1212 // We use different BrowserProcess when importing so no GoogleURLTracker is | 1204 // We use different BrowserProcess when importing so no GoogleURLTracker is |
| 1213 // instantiated (as it makes a net::URLRequest and we don't have an IO | 1205 // instantiated (as it makes a net::URLRequest and we don't have an IO |
| 1214 // thread, see bug #1292702). | 1206 // thread, see bug #1292702). |
| 1215 browser_process_.reset(new FirstRunBrowserProcess(parsed_command_line())); | 1207 browser_process_.reset(new FirstRunBrowserProcess(parsed_command_line())); |
| 1216 is_first_run = false; | 1208 is_first_run_ = false; |
| 1217 } else { | 1209 } else { |
| 1218 browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); | 1210 browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); |
| 1219 } | 1211 } |
| 1220 | 1212 |
| 1221 if (parsed_command_line().HasSwitch(switches::kEnableTracking)) { | 1213 if (parsed_command_line().HasSwitch(switches::kEnableTracking)) { |
| 1222 // User wants to override default tracking status. | 1214 // User wants to override default tracking status. |
| 1223 std::string flag = | 1215 std::string flag = |
| 1224 parsed_command_line().GetSwitchValueASCII(switches::kEnableTracking); | 1216 parsed_command_line().GetSwitchValueASCII(switches::kEnableTracking); |
| 1225 bool enabled = flag.compare("0") != 0; | 1217 bool enabled = flag.compare("0") != 0; |
| 1226 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(enabled); | 1218 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(enabled); |
| 1227 } | 1219 } |
| 1228 | 1220 |
| 1229 // This forces the TabCloseableStateWatcher to be created and, on chromeos, | 1221 // This forces the TabCloseableStateWatcher to be created and, on chromeos, |
| 1230 // register for the notifications it needs to track the closeable state of | 1222 // register for the notifications it needs to track the closeable state of |
| 1231 // tabs. | 1223 // tabs. |
| 1232 g_browser_process->tab_closeable_state_watcher(); | 1224 g_browser_process->tab_closeable_state_watcher(); |
| 1233 | 1225 |
| 1234 PrefService* local_state = InitializeLocalState(parsed_command_line(), | 1226 local_state_ = InitializeLocalState(parsed_command_line(), |
| 1235 is_first_run); | 1227 is_first_run_); |
|
robertshield
2011/11/14 04:15:55
It looks like local_state_ and metrics_ will be da
| |
| 1236 | 1228 |
| 1237 #if defined(USE_LINUX_BREAKPAD) | 1229 #if defined(USE_LINUX_BREAKPAD) |
| 1238 // Needs to be called after we have chrome::DIR_USER_DATA and | 1230 // Needs to be called after we have chrome::DIR_USER_DATA and |
| 1239 // g_browser_process. | 1231 // g_browser_process. |
| 1240 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, | 1232 g_browser_process->file_thread()->message_loop()->PostTask(FROM_HERE, |
| 1241 new GetLinuxDistroTask()); | 1233 new GetLinuxDistroTask()); |
| 1242 | 1234 |
| 1243 if (IsCrashReportingEnabled(local_state)) | 1235 if (IsCrashReportingEnabled(local_state_)) |
| 1244 InitCrashReporter(); | 1236 InitCrashReporter(); |
| 1245 #endif | 1237 #endif |
| 1246 | 1238 |
| 1247 // If we're running tests (ui_task is non-null), then the ResourceBundle | 1239 // If we're running tests (ui_task is non-null), then the ResourceBundle |
| 1248 // has already been initialized. | 1240 // has already been initialized. |
| 1249 if (parameters().ui_task) { | 1241 if (parameters().ui_task) { |
| 1250 g_browser_process->SetApplicationLocale("en-US"); | 1242 g_browser_process->SetApplicationLocale("en-US"); |
| 1251 } else { | 1243 } else { |
| 1252 // Mac starts it earlier in |PreMainMessageLoopStart()| (because it is | 1244 // Mac starts it earlier in |PreMainMessageLoopStart()| (because it is |
| 1253 // needed when loading the MainMenu.nib and the language doesn't depend on | 1245 // needed when loading the MainMenu.nib and the language doesn't depend on |
| 1254 // anything since it comes from Cocoa. | 1246 // anything since it comes from Cocoa. |
| 1255 #if defined(OS_MACOSX) | 1247 #if defined(OS_MACOSX) |
| 1256 g_browser_process->SetApplicationLocale(l10n_util::GetLocaleOverride()); | 1248 g_browser_process->SetApplicationLocale(l10n_util::GetLocaleOverride()); |
| 1257 #else | 1249 #else |
| 1258 const std::string locale = | 1250 const std::string locale = |
| 1259 local_state->GetString(prefs::kApplicationLocale); | 1251 local_state_->GetString(prefs::kApplicationLocale); |
| 1260 // On a POSIX OS other than ChromeOS, the parameter that is passed to the | 1252 // On a POSIX OS other than ChromeOS, the parameter that is passed to the |
| 1261 // method InitSharedInstance is ignored. | 1253 // method InitSharedInstance is ignored. |
| 1262 const std::string loaded_locale = | 1254 const std::string loaded_locale = |
| 1263 ResourceBundle::InitSharedInstance(locale); | 1255 ResourceBundle::InitSharedInstance(locale); |
| 1264 if (loaded_locale.empty() && | 1256 if (loaded_locale.empty() && |
| 1265 !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { | 1257 !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { |
| 1266 ShowMissingLocaleMessageBox(); | 1258 ShowMissingLocaleMessageBox(); |
| 1267 return chrome::RESULT_CODE_MISSING_DATA; | 1259 return chrome::RESULT_CODE_MISSING_DATA; |
| 1268 } | 1260 } |
| 1269 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; | 1261 CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 // This needs to be called after the locale has been set. | 1301 // This needs to be called after the locale has been set. |
| 1310 RegisterTranslateableItems(); | 1302 RegisterTranslateableItems(); |
| 1311 #endif | 1303 #endif |
| 1312 | 1304 |
| 1313 browser_init_.reset(new BrowserInit); | 1305 browser_init_.reset(new BrowserInit); |
| 1314 | 1306 |
| 1315 // On first run, we need to process the predictor preferences before the | 1307 // On first run, we need to process the predictor preferences before the |
| 1316 // browser's profile_manager object is created, but after ResourceBundle | 1308 // browser's profile_manager object is created, but after ResourceBundle |
| 1317 // is initialized. | 1309 // is initialized. |
| 1318 master_prefs_.reset(new FirstRun::MasterPrefs); | 1310 master_prefs_.reset(new FirstRun::MasterPrefs); |
| 1319 bool first_run_ui_bypass = false; // True to skip first run UI. | 1311 first_run_ui_bypass_ = false; // True to skip first run UI. |
| 1320 if (is_first_run) { | 1312 if (is_first_run_) { |
| 1321 first_run_ui_bypass = | 1313 first_run_ui_bypass_ = !FirstRun::ProcessMasterPreferences( |
| 1322 !FirstRun::ProcessMasterPreferences(user_data_dir, master_prefs_.get()); | 1314 user_data_dir_, master_prefs_.get()); |
| 1323 AddFirstRunNewTabs(browser_init_.get(), master_prefs_->new_tabs); | 1315 AddFirstRunNewTabs(browser_init_.get(), master_prefs_->new_tabs); |
| 1324 | 1316 |
| 1325 // If we are running in App mode, we do not want to show the importer | 1317 // If we are running in App mode, we do not want to show the importer |
| 1326 // (first run) UI. | 1318 // (first run) UI. |
| 1327 if (!first_run_ui_bypass && | 1319 if (!first_run_ui_bypass_ && |
| 1328 (parsed_command_line().HasSwitch(switches::kApp) || | 1320 (parsed_command_line().HasSwitch(switches::kApp) || |
| 1329 parsed_command_line().HasSwitch(switches::kAppId) || | 1321 parsed_command_line().HasSwitch(switches::kAppId) || |
| 1330 parsed_command_line().HasSwitch(switches::kNoFirstRun))) | 1322 parsed_command_line().HasSwitch(switches::kNoFirstRun))) |
| 1331 first_run_ui_bypass = true; | 1323 first_run_ui_bypass_ = true; |
| 1332 } | 1324 } |
| 1333 | 1325 |
| 1334 // TODO(viettrungluu): why don't we run this earlier? | 1326 // TODO(viettrungluu): why don't we run this earlier? |
| 1335 if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) | 1327 if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) |
| 1336 WarnAboutMinimumSystemRequirements(); | 1328 WarnAboutMinimumSystemRequirements(); |
| 1337 | 1329 |
| 1338 // Enable print preview once for supported platforms. | 1330 // Enable print preview once for supported platforms. |
| 1339 #if defined(GOOGLE_CHROME_BUILD) | 1331 #if defined(GOOGLE_CHROME_BUILD) |
| 1340 local_state->RegisterBooleanPref(prefs::kPrintingPrintPreviewEnabledOnce, | 1332 local_state_->RegisterBooleanPref(prefs::kPrintingPrintPreviewEnabledOnce, |
| 1341 false, | 1333 false, |
| 1342 PrefService::UNSYNCABLE_PREF); | 1334 PrefService::UNSYNCABLE_PREF); |
| 1343 if (!local_state->GetBoolean(prefs::kPrintingPrintPreviewEnabledOnce)) { | 1335 if (!local_state_->GetBoolean(prefs::kPrintingPrintPreviewEnabledOnce)) { |
| 1344 local_state->SetBoolean(prefs::kPrintingPrintPreviewEnabledOnce, true); | 1336 local_state_->SetBoolean(prefs::kPrintingPrintPreviewEnabledOnce, true); |
| 1345 about_flags::SetExperimentEnabled(local_state, "print-preview", true); | 1337 about_flags::SetExperimentEnabled(local_state_, "print-preview", true); |
| 1346 } | 1338 } |
| 1347 #endif | 1339 #endif |
| 1348 | 1340 |
| 1349 #if defined(TOUCH_UI) | 1341 #if defined(TOUCH_UI) |
| 1350 // Always add the --views-desktop flag, if not already set. | 1342 // Always add the --views-desktop flag, if not already set. |
| 1351 // If the user disabled the flag from about:flags, it will get unset by the | 1343 // If the user disabled the flag from about:flags, it will get unset by the |
| 1352 // call to ConvertFlagsToSwitches in the following line. | 1344 // call to ConvertFlagsToSwitches in the following line. |
| 1353 if (!parsed_command_line().HasSwitch(switches::kViewsDesktop)) | 1345 if (!parsed_command_line().HasSwitch(switches::kViewsDesktop)) |
| 1354 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kViewsDesktop, | 1346 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switches::kViewsDesktop, |
| 1355 "other"); | 1347 "other"); |
| 1356 #endif | 1348 #endif |
| 1357 | 1349 |
| 1358 // Convert active labs into switches. Modifies the current command line. | 1350 // Convert active labs into switches. Modifies the current command line. |
| 1359 about_flags::ConvertFlagsToSwitches(local_state, | 1351 about_flags::ConvertFlagsToSwitches(local_state_, |
| 1360 CommandLine::ForCurrentProcess()); | 1352 CommandLine::ForCurrentProcess()); |
| 1361 | 1353 |
| 1362 // Reset the command line in the crash report details, since we may have | 1354 // Reset the command line in the crash report details, since we may have |
| 1363 // just changed it to include experiments. | 1355 // just changed it to include experiments. |
| 1364 child_process_logging::SetCommandLine(CommandLine::ForCurrentProcess()); | 1356 child_process_logging::SetCommandLine(CommandLine::ForCurrentProcess()); |
| 1365 | 1357 |
| 1366 InitializeNetworkOptions(parsed_command_line()); | 1358 InitializeNetworkOptions(parsed_command_line()); |
| 1367 InitializeURLRequestThrottlerManager(browser_process_->net_log()); | 1359 InitializeURLRequestThrottlerManager(browser_process_->net_log()); |
| 1368 | 1360 |
| 1369 // Initialize histogram synchronizer system. This is a singleton and is used | 1361 // Initialize histogram synchronizer system. This is a singleton and is used |
| 1370 // for posting tasks via NewRunnableMethod. Its deleted when it goes out of | 1362 // for posting tasks via NewRunnableMethod. Its deleted when it goes out of |
| 1371 // scope. Even though NewRunnableMethod does AddRef and Release, the object | 1363 // scope. Even though NewRunnableMethod does AddRef and Release, the object |
| 1372 // will not be deleted after the Task is executed. | 1364 // will not be deleted after the Task is executed. |
| 1373 histogram_synchronizer_ = new HistogramSynchronizer(); | 1365 histogram_synchronizer_ = new HistogramSynchronizer(); |
| 1374 tracking_synchronizer_ = new chrome_browser_metrics::TrackingSynchronizer(); | 1366 tracking_synchronizer_ = new chrome_browser_metrics::TrackingSynchronizer(); |
| 1375 | 1367 |
| 1376 // Now the command line has been mutated based on about:flags, we can | 1368 // Now the command line has been mutated based on about:flags, we can |
| 1377 // set up metrics and initialize field trials. | 1369 // set up metrics and initialize field trials. |
| 1378 MetricsService* metrics = SetupMetricsAndFieldTrials(local_state); | 1370 metrics_ = SetupMetricsAndFieldTrials(local_state_); |
| 1379 | 1371 |
| 1380 #if defined(USE_WEBKIT_COMPOSITOR) | 1372 #if defined(USE_WEBKIT_COMPOSITOR) |
| 1381 // We need to ensure WebKit has been initialized before we start the WebKit | 1373 // We need to ensure WebKit has been initialized before we start the WebKit |
| 1382 // compositor. This is done by the ResourceDispatcherHost on creation. | 1374 // compositor. This is done by the ResourceDispatcherHost on creation. |
| 1383 g_browser_process->resource_dispatcher_host(); | 1375 g_browser_process->resource_dispatcher_host(); |
| 1384 #endif | 1376 #endif |
| 1385 | 1377 |
| 1386 // Now that all preferences have been registered, set the install date | 1378 // Now that all preferences have been registered, set the install date |
| 1387 // for the uninstall metrics if this is our first run. This only actually | 1379 // for the uninstall metrics if this is our first run. This only actually |
| 1388 // gets used if the user has metrics reporting enabled at uninstall time. | 1380 // gets used if the user has metrics reporting enabled at uninstall time. |
| 1389 int64 install_date = | 1381 int64 install_date = |
| 1390 local_state->GetInt64(prefs::kUninstallMetricsInstallDate); | 1382 local_state_->GetInt64(prefs::kUninstallMetricsInstallDate); |
| 1391 if (install_date == 0) { | 1383 if (install_date == 0) { |
| 1392 local_state->SetInt64(prefs::kUninstallMetricsInstallDate, | 1384 local_state_->SetInt64(prefs::kUninstallMetricsInstallDate, |
| 1393 base::Time::Now().ToTimeT()); | 1385 base::Time::Now().ToTimeT()); |
| 1394 } | 1386 } |
| 1395 | 1387 |
| 1396 #if defined(OS_MACOSX) | 1388 #if defined(OS_MACOSX) |
| 1397 // Get the Keychain API to register for distributed notifications on the main | 1389 // Get the Keychain API to register for distributed notifications on the main |
| 1398 // thread, which has a proper CFRunloop, instead of later on the I/O thread, | 1390 // thread, which has a proper CFRunloop, instead of later on the I/O thread, |
| 1399 // which doesn't. This ensures those notifications will get delivered | 1391 // which doesn't. This ensures those notifications will get delivered |
| 1400 // properly. See issue 37766. | 1392 // properly. See issue 37766. |
| 1401 // (Note that the callback mask here is empty. I don't want to register for | 1393 // (Note that the callback mask here is empty. I don't want to register for |
| 1402 // any callbacks, I just want to initialize the mechanism.) | 1394 // any callbacks, I just want to initialize the mechanism.) |
| 1403 SecKeychainAddCallback(&KeychainCallback, 0, NULL); | 1395 SecKeychainAddCallback(&KeychainCallback, 0, NULL); |
| 1404 #endif | 1396 #endif |
| 1405 | 1397 |
| 1406 CreateChildThreads(browser_process_.get()); | 1398 // This initializes the IOThread object. This needs to happen |
| 1399 // before the thread itself is created. | |
| 1400 browser_process_->CreateIOThreadState(); | |
| 1401 | |
| 1402 return content::RESULT_CODE_NORMAL_EXIT; | |
| 1403 } | |
| 1404 | |
| 1405 int ChromeBrowserMainParts::PreMainMessageLoopRunThreadsCreatedImpl() { | |
| 1406 // Create watchdog thread after creating all other threads because it will | |
| 1407 // watch the other threads and they must be running. | |
| 1408 browser_process_->watchdog_thread(); | |
| 1407 | 1409 |
| 1408 #if defined(OS_CHROMEOS) | 1410 #if defined(OS_CHROMEOS) |
| 1409 // Now that the file thread exists we can record our stats. | 1411 // Now that the file thread exists we can record our stats. |
| 1410 chromeos::BootTimesLoader::Get()->RecordChromeMainStats(); | 1412 chromeos::BootTimesLoader::Get()->RecordChromeMainStats(); |
| 1411 | 1413 |
| 1412 #if defined(TOOLKIT_USES_GTK) | 1414 #if defined(TOOLKIT_USES_GTK) |
| 1413 // Read locale-specific GTK resource information. | 1415 // Read locale-specific GTK resource information. |
| 1414 std::string gtkrc = l10n_util::GetStringUTF8(IDS_LOCALE_GTKRC); | 1416 std::string gtkrc = l10n_util::GetStringUTF8(IDS_LOCALE_GTKRC); |
| 1415 if (!gtkrc.empty()) | 1417 if (!gtkrc.empty()) |
| 1416 gtk_rc_parse_string(gtkrc.c_str()); | 1418 gtk_rc_parse_string(gtkrc.c_str()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1538 // Redirects Chrome logging to the user data dir. | 1540 // Redirects Chrome logging to the user data dir. |
| 1539 logging::RedirectChromeLogging(parsed_command_line()); | 1541 logging::RedirectChromeLogging(parsed_command_line()); |
| 1540 | 1542 |
| 1541 // Initialize user policy before creating the profile so the profile | 1543 // Initialize user policy before creating the profile so the profile |
| 1542 // initialization code sees policy settings. | 1544 // initialization code sees policy settings. |
| 1543 g_browser_process->browser_policy_connector()->InitializeUserPolicy( | 1545 g_browser_process->browser_policy_connector()->InitializeUserPolicy( |
| 1544 username); | 1546 username); |
| 1545 } | 1547 } |
| 1546 #endif | 1548 #endif |
| 1547 | 1549 |
| 1548 if (is_first_run) { | 1550 if (is_first_run_) { |
| 1549 // Warn the ProfileManager that an import process will run, possibly | 1551 // Warn the ProfileManager that an import process will run, possibly |
| 1550 // locking the WebDataService directory of the next Profile created. | 1552 // locking the WebDataService directory of the next Profile created. |
| 1551 g_browser_process->profile_manager()->SetWillImport(); | 1553 g_browser_process->profile_manager()->SetWillImport(); |
| 1552 } | 1554 } |
| 1553 | 1555 |
| 1554 profile_ = CreateProfile(parameters(), user_data_dir, parsed_command_line()); | 1556 profile_ = CreateProfile(parameters(), user_data_dir_, parsed_command_line()); |
| 1555 if (!profile_) | 1557 if (!profile_) |
| 1556 return content::RESULT_CODE_NORMAL_EXIT; | 1558 return content::RESULT_CODE_NORMAL_EXIT; |
| 1557 | 1559 |
| 1558 // Autoload any profiles which are running background apps. | 1560 // Autoload any profiles which are running background apps. |
| 1559 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. | 1561 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. |
| 1560 if (!BackgroundModeManager::IsBackgroundModePermanentlyDisabled( | 1562 if (!BackgroundModeManager::IsBackgroundModePermanentlyDisabled( |
| 1561 &parsed_command_line())) { | 1563 &parsed_command_line())) { |
| 1562 g_browser_process->profile_manager()->AutoloadProfiles(); | 1564 g_browser_process->profile_manager()->AutoloadProfiles(); |
| 1563 } | 1565 } |
| 1564 // Post-profile init --------------------------------------------------------- | 1566 // Post-profile init --------------------------------------------------------- |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1623 return content::RESULT_CODE_NORMAL_EXIT; | 1625 return content::RESULT_CODE_NORMAL_EXIT; |
| 1624 } | 1626 } |
| 1625 } | 1627 } |
| 1626 #endif | 1628 #endif |
| 1627 | 1629 |
| 1628 // Show the First Run UI if this is the first time Chrome has been run on | 1630 // Show the First Run UI if this is the first time Chrome has been run on |
| 1629 // this computer, or we're being compelled to do so by a command line flag. | 1631 // this computer, or we're being compelled to do so by a command line flag. |
| 1630 // Note that this be done _after_ the PrefService is initialized and all | 1632 // Note that this be done _after_ the PrefService is initialized and all |
| 1631 // preferences are registered, since some of the code that the importer | 1633 // preferences are registered, since some of the code that the importer |
| 1632 // touches reads preferences. | 1634 // touches reads preferences. |
| 1633 if (is_first_run) { | 1635 if (is_first_run_) { |
| 1634 if (!first_run_ui_bypass) { | 1636 if (!first_run_ui_bypass_) { |
| 1635 FirstRun::AutoImport(profile_, | 1637 FirstRun::AutoImport(profile_, |
| 1636 master_prefs_->homepage_defined, | 1638 master_prefs_->homepage_defined, |
| 1637 master_prefs_->do_import_items, | 1639 master_prefs_->do_import_items, |
| 1638 master_prefs_->dont_import_items, | 1640 master_prefs_->dont_import_items, |
| 1639 master_prefs_->run_search_engine_experiment, | 1641 master_prefs_->run_search_engine_experiment, |
| 1640 master_prefs_->randomize_search_engine_experiment, | 1642 master_prefs_->randomize_search_engine_experiment, |
| 1641 master_prefs_->make_chrome_default, | 1643 master_prefs_->make_chrome_default, |
| 1642 process_singleton_.get()); | 1644 process_singleton_.get()); |
| 1643 #if defined(OS_POSIX) | 1645 #if defined(OS_POSIX) |
| 1644 // On Windows, the download is tagged with enable/disable stats so there | 1646 // On Windows, the download is tagged with enable/disable stats so there |
| 1645 // is no need for this code. | 1647 // is no need for this code. |
| 1646 | 1648 |
| 1647 // If stats reporting was turned on by the first run dialog then toggle | 1649 // If stats reporting was turned on by the first run dialog then toggle |
| 1648 // the pref. | 1650 // the pref. |
| 1649 if (GoogleUpdateSettings::GetCollectStatsConsent()) | 1651 if (GoogleUpdateSettings::GetCollectStatsConsent()) |
| 1650 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); | 1652 local_state_->SetBoolean(prefs::kMetricsReportingEnabled, true); |
| 1651 #endif // OS_POSIX | 1653 #endif // OS_POSIX |
| 1652 } // if (!first_run_ui_bypass) | 1654 } // if (!first_run_ui_bypass_) |
| 1653 | 1655 |
| 1654 Browser::SetNewHomePagePrefs(profile_->GetPrefs()); | 1656 Browser::SetNewHomePagePrefs(profile_->GetPrefs()); |
| 1655 g_browser_process->profile_manager()->OnImportFinished(profile_); | 1657 g_browser_process->profile_manager()->OnImportFinished(profile_); |
| 1656 } // if (is_first_run) | 1658 } // if (is_first_run) |
| 1657 | 1659 |
| 1658 #if defined(OS_WIN) | 1660 #if defined(OS_WIN) |
| 1659 // Sets things up so that if we crash from this point on, a dialog will | 1661 // Sets things up so that if we crash from this point on, a dialog will |
| 1660 // popup asking the user to restart chrome. It is done this late to avoid | 1662 // popup asking the user to restart chrome. It is done this late to avoid |
| 1661 // testing against a bunch of special cases that are taken care early on. | 1663 // testing against a bunch of special cases that are taken care early on. |
| 1662 ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment( | 1664 ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1761 | 1763 |
| 1762 #if defined(OS_WIN) && !defined(GOOGLE_CHROME_BUILD) | 1764 #if defined(OS_WIN) && !defined(GOOGLE_CHROME_BUILD) |
| 1763 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { | 1765 if (parsed_command_line().HasSwitch(switches::kDebugPrint)) { |
| 1764 FilePath path = | 1766 FilePath path = |
| 1765 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); | 1767 parsed_command_line().GetSwitchValuePath(switches::kDebugPrint); |
| 1766 printing::PrintedDocument::set_debug_dump_path(path); | 1768 printing::PrintedDocument::set_debug_dump_path(path); |
| 1767 } | 1769 } |
| 1768 #endif | 1770 #endif |
| 1769 | 1771 |
| 1770 HandleTestParameters(parsed_command_line()); | 1772 HandleTestParameters(parsed_command_line()); |
| 1771 RecordBreakpadStatusUMA(metrics); | 1773 RecordBreakpadStatusUMA(metrics_); |
| 1772 about_flags::RecordUMAStatistics(local_state); | 1774 about_flags::RecordUMAStatistics(local_state_); |
| 1773 LanguageUsageMetrics::RecordAcceptLanguages( | 1775 LanguageUsageMetrics::RecordAcceptLanguages( |
| 1774 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 1776 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 1775 LanguageUsageMetrics::RecordApplicationLanguage( | 1777 LanguageUsageMetrics::RecordApplicationLanguage( |
| 1776 g_browser_process->GetApplicationLocale()); | 1778 g_browser_process->GetApplicationLocale()); |
| 1777 | 1779 |
| 1778 #if defined(OS_WIN) | 1780 #if defined(OS_WIN) |
| 1779 fragmentation_checker::RecordFragmentationMetricForCurrentModule(); | 1781 fragmentation_checker::RecordFragmentationMetricForCurrentModule(); |
| 1780 #endif | 1782 #endif |
| 1781 | 1783 |
| 1782 #if defined(OS_CHROMEOS) | 1784 #if defined(OS_CHROMEOS) |
| 1783 metrics->StartExternalMetrics(); | 1785 metrics_->StartExternalMetrics(); |
| 1784 | 1786 |
| 1785 // Initialize the audio handler on ChromeOS. | 1787 // Initialize the audio handler on ChromeOS. |
| 1786 chromeos::AudioHandler::Initialize(); | 1788 chromeos::AudioHandler::Initialize(); |
| 1787 | 1789 |
| 1788 // Listen for system key events so that the user will be able to adjust the | 1790 // Listen for system key events so that the user will be able to adjust the |
| 1789 // volume on the login screen, if Chrome is running on Chrome OS | 1791 // volume on the login screen, if Chrome is running on Chrome OS |
| 1790 // (i.e. not Linux desktop), and in non-test mode. | 1792 // (i.e. not Linux desktop), and in non-test mode. |
| 1791 if (chromeos::system::runtime_environment::IsRunningOnChromeOS() && | 1793 if (chromeos::system::runtime_environment::IsRunningOnChromeOS() && |
| 1792 !parameters().ui_task) { // ui_task is non-NULL when running tests. | 1794 !parameters().ui_task) { // ui_task is non-NULL when running tests. |
| 1793 chromeos::SystemKeyEventListener::Initialize(); | 1795 chromeos::SystemKeyEventListener::Initialize(); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1806 return content::RESULT_CODE_NORMAL_EXIT; | 1808 return content::RESULT_CODE_NORMAL_EXIT; |
| 1807 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR; | 1809 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR; |
| 1808 } | 1810 } |
| 1809 | 1811 |
| 1810 // Start watching for a hang. | 1812 // Start watching for a hang. |
| 1811 MetricsService::LogNeedForCleanShutdown(); | 1813 MetricsService::LogNeedForCleanShutdown(); |
| 1812 | 1814 |
| 1813 #if defined(OS_WIN) | 1815 #if defined(OS_WIN) |
| 1814 // We check this here because if the profile is OTR (chromeos possibility) | 1816 // We check this here because if the profile is OTR (chromeos possibility) |
| 1815 // it won't still be accessible after browser is destroyed. | 1817 // it won't still be accessible after browser is destroyed. |
| 1816 record_search_engine_ = is_first_run && !profile_->IsOffTheRecord(); | 1818 record_search_engine_ = is_first_run_ && !profile_->IsOffTheRecord(); |
| 1817 #endif | 1819 #endif |
| 1818 | 1820 |
| 1819 // ChildProcess:: is a misnomer unless you consider context. Use | 1821 // ChildProcess:: is a misnomer unless you consider context. Use |
| 1820 // of --wait-for-debugger only makes sense when Chrome itself is a | 1822 // of --wait-for-debugger only makes sense when Chrome itself is a |
| 1821 // child process (e.g. when launched by PyAuto). | 1823 // child process (e.g. when launched by PyAuto). |
| 1822 if (parsed_command_line().HasSwitch(switches::kWaitForDebugger)) { | 1824 if (parsed_command_line().HasSwitch(switches::kWaitForDebugger)) { |
| 1823 ChildProcess::WaitForDebugger("Browser"); | 1825 ChildProcess::WaitForDebugger("Browser"); |
| 1824 } | 1826 } |
| 1825 | 1827 |
| 1826 #if defined(OS_CHROMEOS) | 1828 #if defined(OS_CHROMEOS) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1869 parameters().ui_task->Run(); | 1871 parameters().ui_task->Run(); |
| 1870 delete parameters().ui_task; | 1872 delete parameters().ui_task; |
| 1871 run_message_loop_ = false; | 1873 run_message_loop_ = false; |
| 1872 } else { | 1874 } else { |
| 1873 // Most general initialization is behind us, but opening a | 1875 // Most general initialization is behind us, but opening a |
| 1874 // tab and/or session restore and such is still to be done. | 1876 // tab and/or session restore and such is still to be done. |
| 1875 base::TimeTicks browser_open_start = base::TimeTicks::Now(); | 1877 base::TimeTicks browser_open_start = base::TimeTicks::Now(); |
| 1876 | 1878 |
| 1877 // We are in regular browser boot sequence. Open initial tabs and enter the | 1879 // We are in regular browser boot sequence. Open initial tabs and enter the |
| 1878 // main message loop. | 1880 // main message loop. |
| 1881 int result_code; | |
| 1879 if (browser_init_->Start(parsed_command_line(), FilePath(), profile_, | 1882 if (browser_init_->Start(parsed_command_line(), FilePath(), profile_, |
| 1880 &result_code_)) { | 1883 &result_code)) { |
| 1881 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | 1884 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 1882 // Initialize autoupdate timer. Timer callback costs basically nothing | 1885 // Initialize autoupdate timer. Timer callback costs basically nothing |
| 1883 // when browser is not in persistent mode, so it's OK to let it ride on | 1886 // when browser is not in persistent mode, so it's OK to let it ride on |
| 1884 // the main thread. This needs to be done here because we don't want | 1887 // the main thread. This needs to be done here because we don't want |
| 1885 // to start the timer when Chrome is run inside a test harness. | 1888 // to start the timer when Chrome is run inside a test harness. |
| 1886 g_browser_process->StartAutoupdateTimer(); | 1889 g_browser_process->StartAutoupdateTimer(); |
| 1887 #endif | 1890 #endif |
| 1888 | 1891 |
| 1889 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1892 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1890 // On Linux, the running exe will be updated if an upgrade becomes | 1893 // On Linux, the running exe will be updated if an upgrade becomes |
| 1891 // available while the browser is running. We need to save the last | 1894 // available while the browser is running. We need to save the last |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2042 // The XInput2 event listener needs to be shut down earlier than when | 2045 // The XInput2 event listener needs to be shut down earlier than when |
| 2043 // Singletons are finally destroyed in AtExitManager. | 2046 // Singletons are finally destroyed in AtExitManager. |
| 2044 chromeos::XInputHierarchyChangedEventListener::GetInstance()->Stop(); | 2047 chromeos::XInputHierarchyChangedEventListener::GetInstance()->Stop(); |
| 2045 | 2048 |
| 2046 // chromeos::SystemKeyEventListener::Shutdown() is always safe to call, | 2049 // chromeos::SystemKeyEventListener::Shutdown() is always safe to call, |
| 2047 // even if Initialize() wasn't called. | 2050 // even if Initialize() wasn't called. |
| 2048 chromeos::SystemKeyEventListener::Shutdown(); | 2051 chromeos::SystemKeyEventListener::Shutdown(); |
| 2049 chromeos::AudioHandler::Shutdown(); | 2052 chromeos::AudioHandler::Shutdown(); |
| 2050 #endif | 2053 #endif |
| 2051 | 2054 |
| 2055 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop(); | |
| 2056 browser_process_->StartTearDown(); | |
| 2057 } | |
| 2058 | |
| 2059 void ChromeBrowserMainParts::PreStopThread(BrowserThread::ID identifier) { | |
| 2060 browser_process_->PreStopThread(identifier); | |
| 2061 } | |
| 2062 | |
| 2063 void ChromeBrowserMainParts::PostStopThread(BrowserThread::ID identifier) { | |
| 2064 browser_process_->PostStopThread(identifier); | |
| 2065 } | |
| 2066 | |
| 2067 void ChromeBrowserMainParts::FinalCleanup() { | |
| 2052 // browser_shutdown takes care of deleting browser_process, so we need to | 2068 // browser_shutdown takes care of deleting browser_process, so we need to |
| 2053 // release it. | 2069 // release it. |
| 2054 ignore_result(browser_process_.release()); | 2070 ignore_result(browser_process_.release()); |
|
robertshield
2011/11/14 04:15:55
This isn't new to this CL, but why does ChromeBrow
| |
| 2055 browser_shutdown::Shutdown(); | 2071 browser_shutdown::ShutdownPostThreadsStop(restart_last_session_); |
| 2056 master_prefs_.reset(); | 2072 master_prefs_.reset(); |
| 2057 process_singleton_.reset(); | 2073 process_singleton_.reset(); |
| 2058 | 2074 |
| 2059 // We need to do this check as late as possible, but due to modularity, this | 2075 // We need to do this check as late as possible, but due to modularity, this |
| 2060 // may be the last point in Chrome. This would be more effective if done at | 2076 // may be the last point in Chrome. This would be more effective if done at |
| 2061 // a higher level on the stack, so that it is impossible for an early return | 2077 // a higher level on the stack, so that it is impossible for an early return |
| 2062 // to bypass this code. Perhaps we need a *final* hook that is called on all | 2078 // to bypass this code. Perhaps we need a *final* hook that is called on all |
| 2063 // paths from content/browser/browser_main. | 2079 // paths from content/browser/browser_main. |
| 2064 CHECK(MetricsService::UmaMetricsProperlyShutdown()); | 2080 CHECK(MetricsService::UmaMetricsProperlyShutdown()); |
| 2065 } | 2081 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2084 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 2100 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
| 2085 (pre_read == "0" || pre_read == "1")) { | 2101 (pre_read == "0" || pre_read == "1")) { |
| 2086 std::string uma_name(name); | 2102 std::string uma_name(name); |
| 2087 uma_name += "_PreRead"; | 2103 uma_name += "_PreRead"; |
| 2088 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2104 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 2089 AddPreReadHistogramTime(uma_name.c_str(), time); | 2105 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 2090 } | 2106 } |
| 2091 #endif | 2107 #endif |
| 2092 #endif | 2108 #endif |
| 2093 } | 2109 } |
| OLD | NEW |