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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { | 270 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { |
271 net::HttpStreamFactory::EnableNpnHttpOnly(); | 271 net::HttpStreamFactory::EnableNpnHttpOnly(); |
272 used_spdy_switch = true; | 272 used_spdy_switch = true; |
273 } | 273 } |
274 if (!used_spdy_switch) { | 274 if (!used_spdy_switch) { |
275 net::HttpStreamFactory::EnableNpnSpdy3(); | 275 net::HttpStreamFactory::EnableNpnSpdy3(); |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 // Returns the new local state object, guaranteed non-NULL. | 279 // Returns the new local state object, guaranteed non-NULL. |
280 PrefService* InitializeLocalState(const CommandLine& parsed_command_line, | 280 // |local_state_task_runner| must be a shutdown-blocking task runner. |
281 bool is_first_run) { | 281 PrefService* InitializeLocalState( |
| 282 base::SequencedTaskRunner* local_state_task_runner, |
| 283 const CommandLine& parsed_command_line, |
| 284 bool is_first_run) { |
282 FilePath local_state_path; | 285 FilePath local_state_path; |
283 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 286 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
284 bool local_state_file_exists = file_util::PathExists(local_state_path); | 287 bool local_state_file_exists = file_util::PathExists(local_state_path); |
285 | 288 |
286 // Load local state. This includes the application locale so we know which | 289 // Load local state. This includes the application locale so we know which |
287 // locale dll to load. | 290 // locale dll to load. |
288 PrefService* local_state = g_browser_process->local_state(); | 291 PrefService* local_state = g_browser_process->local_state(); |
289 DCHECK(local_state); | 292 DCHECK(local_state); |
290 | 293 |
291 // TODO(brettw,*): this comment about ResourceBundle was here since | 294 // TODO(brettw,*): this comment about ResourceBundle was here since |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // Checking that the local state file for the current profile doesn't exist | 328 // Checking that the local state file for the current profile doesn't exist |
326 // is the most robust way to determine whether we need to inherit or not | 329 // is the most robust way to determine whether we need to inherit or not |
327 // since the parent profile command line flag can be present even when the | 330 // since the parent profile command line flag can be present even when the |
328 // current profile is not a new one, and in that case we do not want to | 331 // current profile is not a new one, and in that case we do not want to |
329 // inherit and reset the user's setting. | 332 // inherit and reset the user's setting. |
330 if (!local_state_file_exists && | 333 if (!local_state_file_exists && |
331 parsed_command_line.HasSwitch(switches::kParentProfile)) { | 334 parsed_command_line.HasSwitch(switches::kParentProfile)) { |
332 FilePath parent_profile = | 335 FilePath parent_profile = |
333 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); | 336 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); |
334 scoped_ptr<PrefService> parent_local_state( | 337 scoped_ptr<PrefService> parent_local_state( |
335 PrefService::CreatePrefService(parent_profile, | 338 PrefService::CreatePrefService(parent_profile, local_state_task_runner, |
336 g_browser_process->policy_service(), | 339 g_browser_process->policy_service(), |
337 NULL, false)); | 340 NULL, false)); |
338 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, | 341 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, |
339 std::string()); | 342 std::string()); |
340 // Right now, we only inherit the locale setting from the parent profile. | 343 // Right now, we only inherit the locale setting from the parent profile. |
341 local_state->SetString( | 344 local_state->SetString( |
342 prefs::kApplicationLocale, | 345 prefs::kApplicationLocale, |
343 parent_local_state->GetString(prefs::kApplicationLocale)); | 346 parent_local_state->GetString(prefs::kApplicationLocale)); |
344 } | 347 } |
345 | 348 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); | 719 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); |
717 // Ensure ProcessSingleton won't process messages too early. It will be | 720 // Ensure ProcessSingleton won't process messages too early. It will be |
718 // unlocked in PostBrowserStart(). | 721 // unlocked in PostBrowserStart(). |
719 process_singleton_->Lock(NULL); | 722 process_singleton_->Lock(NULL); |
720 | 723 |
721 is_first_run_ = | 724 is_first_run_ = |
722 (first_run::IsChromeFirstRun() || | 725 (first_run::IsChromeFirstRun() || |
723 parsed_command_line().HasSwitch(switches::kFirstRun)) && | 726 parsed_command_line().HasSwitch(switches::kFirstRun)) && |
724 !HasImportSwitch(parsed_command_line()); | 727 !HasImportSwitch(parsed_command_line()); |
725 #endif | 728 #endif |
726 browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); | 729 |
| 730 FilePath local_state_path; |
| 731 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path)); |
| 732 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = |
| 733 JsonPrefStore::GetTaskRunnerForFile(local_state_path, |
| 734 BrowserThread::GetBlockingPool()); |
| 735 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner, |
| 736 parsed_command_line())); |
727 | 737 |
728 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { | 738 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { |
729 // User wants to override default tracking status. | 739 // User wants to override default tracking status. |
730 std::string flag = | 740 std::string flag = |
731 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); | 741 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); |
732 // Default to basic profiling (no parent child support). | 742 // Default to basic profiling (no parent child support). |
733 tracked_objects::ThreadData::Status status = | 743 tracked_objects::ThreadData::Status status = |
734 tracked_objects::ThreadData::PROFILING_ACTIVE; | 744 tracked_objects::ThreadData::PROFILING_ACTIVE; |
735 if (flag.compare("0") != 0) | 745 if (flag.compare("0") != 0) |
736 status = tracked_objects::ThreadData::DEACTIVATED; | 746 status = tracked_objects::ThreadData::DEACTIVATED; |
737 else if (flag.compare("child") != 0) | 747 else if (flag.compare("child") != 0) |
738 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE; | 748 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE; |
739 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); | 749 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); |
740 } | 750 } |
741 | 751 |
742 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) { | 752 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) { |
743 tracking_objects_.set_output_file_path( | 753 tracking_objects_.set_output_file_path( |
744 parsed_command_line().GetSwitchValuePath( | 754 parsed_command_line().GetSwitchValuePath( |
745 switches::kProfilingOutputFile)); | 755 switches::kProfilingOutputFile)); |
746 } | 756 } |
747 | 757 |
748 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_); | 758 local_state_ = InitializeLocalState(local_state_task_runner, |
| 759 parsed_command_line(), |
| 760 is_first_run_); |
749 | 761 |
750 // These members must be initialized before returning from this function. | 762 // These members must be initialized before returning from this function. |
751 master_prefs_.reset(new first_run::MasterPrefs); | 763 master_prefs_.reset(new first_run::MasterPrefs); |
752 | 764 |
753 #if !defined(OS_ANDROID) | 765 #if !defined(OS_ANDROID) |
754 // Android doesn't use StartupBrowserCreator. | 766 // Android doesn't use StartupBrowserCreator. |
755 browser_creator_.reset(new StartupBrowserCreator); | 767 browser_creator_.reset(new StartupBrowserCreator); |
756 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver | 768 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver |
757 chrome::UMABrowsingActivityObserver::Init(); | 769 chrome::UMABrowsingActivityObserver::Init(); |
758 #endif | 770 #endif |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1712 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1701 uma_name += "_XP"; | 1713 uma_name += "_XP"; |
1702 | 1714 |
1703 uma_name += "_PreRead_"; | 1715 uma_name += "_PreRead_"; |
1704 uma_name += pre_read_percentage; | 1716 uma_name += pre_read_percentage; |
1705 AddPreReadHistogramTime(uma_name.c_str(), time); | 1717 AddPreReadHistogramTime(uma_name.c_str(), time); |
1706 } | 1718 } |
1707 #endif | 1719 #endif |
1708 #endif | 1720 #endif |
1709 } | 1721 } |
OLD | NEW |