OLD | NEW |
---|---|
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.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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { | 265 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { |
266 net::HttpStreamFactory::EnableNpnHttpOnly(); | 266 net::HttpStreamFactory::EnableNpnHttpOnly(); |
267 used_spdy_switch = true; | 267 used_spdy_switch = true; |
268 } | 268 } |
269 if (!used_spdy_switch) { | 269 if (!used_spdy_switch) { |
270 net::HttpStreamFactory::EnableNpnSpdy3(); | 270 net::HttpStreamFactory::EnableNpnSpdy3(); |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 // Returns the new local state object, guaranteed non-NULL. | 274 // Returns the new local state object, guaranteed non-NULL. |
275 PrefService* InitializeLocalState(const CommandLine& parsed_command_line, | 275 // |local_state_task_runner| must be a shutdown-blocking task runner. |
276 bool is_first_run) { | 276 PrefService* InitializeLocalState( |
277 base::SequencedTaskRunner* local_state_task_runner, | |
278 const CommandLine& parsed_command_line, | |
279 bool is_first_run) { | |
277 FilePath local_state_path; | 280 FilePath local_state_path; |
278 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 281 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
279 bool local_state_file_exists = file_util::PathExists(local_state_path); | 282 bool local_state_file_exists = file_util::PathExists(local_state_path); |
280 | 283 |
281 // Load local state. This includes the application locale so we know which | 284 // Load local state. This includes the application locale so we know which |
282 // locale dll to load. | 285 // locale dll to load. |
283 PrefService* local_state = g_browser_process->local_state(); | 286 PrefService* local_state = g_browser_process->local_state(); |
284 DCHECK(local_state); | 287 DCHECK(local_state); |
285 | 288 |
286 // TODO(brettw,*): this comment about ResourceBundle was here since | 289 // TODO(brettw,*): this comment about ResourceBundle was here since |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 // since the parent profile command line flag can be present even when the | 325 // since the parent profile command line flag can be present even when the |
323 // current profile is not a new one, and in that case we do not want to | 326 // current profile is not a new one, and in that case we do not want to |
324 // inherit and reset the user's setting. | 327 // inherit and reset the user's setting. |
325 if (!local_state_file_exists && | 328 if (!local_state_file_exists && |
326 parsed_command_line.HasSwitch(switches::kParentProfile)) { | 329 parsed_command_line.HasSwitch(switches::kParentProfile)) { |
327 FilePath parent_profile = | 330 FilePath parent_profile = |
328 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); | 331 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); |
329 scoped_ptr<PrefService> parent_local_state( | 332 scoped_ptr<PrefService> parent_local_state( |
330 PrefService::CreatePrefService(parent_profile, | 333 PrefService::CreatePrefService(parent_profile, |
331 g_browser_process->policy_service(), | 334 g_browser_process->policy_service(), |
332 NULL, false)); | 335 NULL, false, local_state_task_runner)); |
333 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, | 336 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, |
334 std::string()); | 337 std::string()); |
335 // Right now, we only inherit the locale setting from the parent profile. | 338 // Right now, we only inherit the locale setting from the parent profile. |
336 local_state->SetString( | 339 local_state->SetString( |
337 prefs::kApplicationLocale, | 340 prefs::kApplicationLocale, |
338 parent_local_state->GetString(prefs::kApplicationLocale)); | 341 parent_local_state->GetString(prefs::kApplicationLocale)); |
339 } | 342 } |
340 | 343 |
341 #if defined(OS_CHROMEOS) | 344 #if defined(OS_CHROMEOS) |
342 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { | 345 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); | 711 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); |
709 // Ensure ProcessSingleton won't process messages too early. It will be | 712 // Ensure ProcessSingleton won't process messages too early. It will be |
710 // unlocked in PostBrowserStart(). | 713 // unlocked in PostBrowserStart(). |
711 process_singleton_->Lock(NULL); | 714 process_singleton_->Lock(NULL); |
712 | 715 |
713 is_first_run_ = | 716 is_first_run_ = |
714 (first_run::IsChromeFirstRun() || | 717 (first_run::IsChromeFirstRun() || |
715 parsed_command_line().HasSwitch(switches::kFirstRun)) && | 718 parsed_command_line().HasSwitch(switches::kFirstRun)) && |
716 !HasImportSwitch(parsed_command_line()); | 719 !HasImportSwitch(parsed_command_line()); |
717 #endif | 720 #endif |
718 browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); | 721 |
Mattias Nissler (ping if slow)
2012/10/22 17:28:21
nit: remove extra blank line.
zel
2012/10/24 02:20:11
Done.
| |
722 | |
723 FilePath local_state_path; | |
724 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path)); | |
725 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = | |
726 JsonPrefStore::GetTaskRunnerForFile(local_state_path, | |
727 BrowserThread::GetBlockingPool()); | |
728 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner, | |
729 parsed_command_line())); | |
719 | 730 |
720 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { | 731 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { |
721 // User wants to override default tracking status. | 732 // User wants to override default tracking status. |
722 std::string flag = | 733 std::string flag = |
723 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); | 734 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); |
724 // Default to basic profiling (no parent child support). | 735 // Default to basic profiling (no parent child support). |
725 tracked_objects::ThreadData::Status status = | 736 tracked_objects::ThreadData::Status status = |
726 tracked_objects::ThreadData::PROFILING_ACTIVE; | 737 tracked_objects::ThreadData::PROFILING_ACTIVE; |
727 if (flag.compare("0") != 0) | 738 if (flag.compare("0") != 0) |
728 status = tracked_objects::ThreadData::DEACTIVATED; | 739 status = tracked_objects::ThreadData::DEACTIVATED; |
729 else if (flag.compare("child") != 0) | 740 else if (flag.compare("child") != 0) |
730 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE; | 741 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE; |
731 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); | 742 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); |
732 } | 743 } |
733 | 744 |
734 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) { | 745 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) { |
735 tracking_objects_.set_output_file_path( | 746 tracking_objects_.set_output_file_path( |
736 parsed_command_line().GetSwitchValuePath( | 747 parsed_command_line().GetSwitchValuePath( |
737 switches::kProfilingOutputFile)); | 748 switches::kProfilingOutputFile)); |
738 } | 749 } |
739 | 750 |
740 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_); | 751 local_state_ = InitializeLocalState(local_state_task_runner, |
752 parsed_command_line(), | |
753 is_first_run_); | |
741 | 754 |
742 // These members must be initialized before returning from this function. | 755 // These members must be initialized before returning from this function. |
743 master_prefs_.reset(new first_run::MasterPrefs); | 756 master_prefs_.reset(new first_run::MasterPrefs); |
744 | 757 |
745 #if !defined(OS_ANDROID) | 758 #if !defined(OS_ANDROID) |
746 // Android doesn't use StartupBrowserCreator. | 759 // Android doesn't use StartupBrowserCreator. |
747 browser_creator_.reset(new StartupBrowserCreator); | 760 browser_creator_.reset(new StartupBrowserCreator); |
748 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver | 761 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver |
749 chrome::UMABrowsingActivityObserver::Init(); | 762 chrome::UMABrowsingActivityObserver::Init(); |
750 #endif | 763 #endif |
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1652 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1665 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1653 uma_name += "_XP"; | 1666 uma_name += "_XP"; |
1654 | 1667 |
1655 uma_name += "_PreRead_"; | 1668 uma_name += "_PreRead_"; |
1656 uma_name += pre_read_percentage; | 1669 uma_name += pre_read_percentage; |
1657 AddPreReadHistogramTime(uma_name.c_str(), time); | 1670 AddPreReadHistogramTime(uma_name.c_str(), time); |
1658 } | 1671 } |
1659 #endif | 1672 #endif |
1660 #endif | 1673 #endif |
1661 } | 1674 } |
OLD | NEW |