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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 11027070: Moved JsonPrefStore to use SequencedWorkerPool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes for LoginUtils* test flakes 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
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.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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { 267 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) {
268 net::HttpStreamFactory::EnableNpnHttpOnly(); 268 net::HttpStreamFactory::EnableNpnHttpOnly();
269 used_spdy_switch = true; 269 used_spdy_switch = true;
270 } 270 }
271 if (!used_spdy_switch) { 271 if (!used_spdy_switch) {
272 net::HttpStreamFactory::EnableNpnSpdy3(); 272 net::HttpStreamFactory::EnableNpnSpdy3();
273 } 273 }
274 } 274 }
275 275
276 // Returns the new local state object, guaranteed non-NULL. 276 // Returns the new local state object, guaranteed non-NULL.
277 PrefService* InitializeLocalState(const CommandLine& parsed_command_line, 277 // |local_state_task_runner| must be a shutdown-blocking task runner.
278 bool is_first_run) { 278 PrefService* InitializeLocalState(
279 base::SequencedTaskRunner* local_state_task_runner,
280 const CommandLine& parsed_command_line,
281 bool is_first_run) {
279 FilePath local_state_path; 282 FilePath local_state_path;
280 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); 283 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
281 bool local_state_file_exists = file_util::PathExists(local_state_path); 284 bool local_state_file_exists = file_util::PathExists(local_state_path);
282 285
283 // Load local state. This includes the application locale so we know which 286 // Load local state. This includes the application locale so we know which
284 // locale dll to load. 287 // locale dll to load.
285 PrefService* local_state = g_browser_process->local_state(); 288 PrefService* local_state = g_browser_process->local_state();
286 DCHECK(local_state); 289 DCHECK(local_state);
287 290
288 // TODO(brettw,*): this comment about ResourceBundle was here since 291 // TODO(brettw,*): this comment about ResourceBundle was here since
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // Checking that the local state file for the current profile doesn't exist 325 // Checking that the local state file for the current profile doesn't exist
323 // is the most robust way to determine whether we need to inherit or not 326 // is the most robust way to determine whether we need to inherit or not
324 // since the parent profile command line flag can be present even when the 327 // since the parent profile command line flag can be present even when the
325 // current profile is not a new one, and in that case we do not want to 328 // current profile is not a new one, and in that case we do not want to
326 // inherit and reset the user's setting. 329 // inherit and reset the user's setting.
327 if (!local_state_file_exists && 330 if (!local_state_file_exists &&
328 parsed_command_line.HasSwitch(switches::kParentProfile)) { 331 parsed_command_line.HasSwitch(switches::kParentProfile)) {
329 FilePath parent_profile = 332 FilePath parent_profile =
330 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); 333 parsed_command_line.GetSwitchValuePath(switches::kParentProfile);
331 scoped_ptr<PrefService> parent_local_state( 334 scoped_ptr<PrefService> parent_local_state(
332 PrefService::CreatePrefService(parent_profile, 335 PrefService::CreatePrefService(parent_profile, local_state_task_runner,
333 g_browser_process->policy_service(), 336 g_browser_process->policy_service(),
334 NULL, false)); 337 NULL, false));
335 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, 338 parent_local_state->RegisterStringPref(prefs::kApplicationLocale,
336 std::string()); 339 std::string());
337 // Right now, we only inherit the locale setting from the parent profile. 340 // Right now, we only inherit the locale setting from the parent profile.
338 local_state->SetString( 341 local_state->SetString(
339 prefs::kApplicationLocale, 342 prefs::kApplicationLocale,
340 parent_local_state->GetString(prefs::kApplicationLocale)); 343 parent_local_state->GetString(prefs::kApplicationLocale));
341 } 344 }
342 345
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); 705 process_singleton_.reset(new ProcessSingleton(user_data_dir_));
703 // Ensure ProcessSingleton won't process messages too early. It will be 706 // Ensure ProcessSingleton won't process messages too early. It will be
704 // unlocked in PostBrowserStart(). 707 // unlocked in PostBrowserStart().
705 process_singleton_->Lock(NULL); 708 process_singleton_->Lock(NULL);
706 709
707 is_first_run_ = 710 is_first_run_ =
708 (first_run::IsChromeFirstRun() || 711 (first_run::IsChromeFirstRun() ||
709 parsed_command_line().HasSwitch(switches::kFirstRun)) && 712 parsed_command_line().HasSwitch(switches::kFirstRun)) &&
710 !HasImportSwitch(parsed_command_line()); 713 !HasImportSwitch(parsed_command_line());
711 #endif 714 #endif
712 browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); 715
716 FilePath local_state_path;
717 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path));
718 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner =
719 JsonPrefStore::GetTaskRunnerForFile(local_state_path,
720 BrowserThread::GetBlockingPool());
721 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner,
722 parsed_command_line()));
713 723
714 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { 724 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) {
715 // User wants to override default tracking status. 725 // User wants to override default tracking status.
716 std::string flag = 726 std::string flag =
717 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); 727 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling);
718 // Default to basic profiling (no parent child support). 728 // Default to basic profiling (no parent child support).
719 tracked_objects::ThreadData::Status status = 729 tracked_objects::ThreadData::Status status =
720 tracked_objects::ThreadData::PROFILING_ACTIVE; 730 tracked_objects::ThreadData::PROFILING_ACTIVE;
721 if (flag.compare("0") != 0) 731 if (flag.compare("0") != 0)
722 status = tracked_objects::ThreadData::DEACTIVATED; 732 status = tracked_objects::ThreadData::DEACTIVATED;
723 else if (flag.compare("child") != 0) 733 else if (flag.compare("child") != 0)
724 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE; 734 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE;
725 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); 735 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status);
726 } 736 }
727 737
728 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) { 738 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) {
729 tracking_objects_.set_output_file_path( 739 tracking_objects_.set_output_file_path(
730 parsed_command_line().GetSwitchValuePath( 740 parsed_command_line().GetSwitchValuePath(
731 switches::kProfilingOutputFile)); 741 switches::kProfilingOutputFile));
732 } 742 }
733 743
734 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_); 744 local_state_ = InitializeLocalState(local_state_task_runner,
745 parsed_command_line(),
746 is_first_run_);
735 747
736 // These members must be initialized before returning from this function. 748 // These members must be initialized before returning from this function.
737 master_prefs_.reset(new first_run::MasterPrefs); 749 master_prefs_.reset(new first_run::MasterPrefs);
738 750
739 #if !defined(OS_ANDROID) 751 #if !defined(OS_ANDROID)
740 // Android doesn't use StartupBrowserCreator. 752 // Android doesn't use StartupBrowserCreator.
741 browser_creator_.reset(new StartupBrowserCreator); 753 browser_creator_.reset(new StartupBrowserCreator);
742 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver 754 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver
743 chrome::UMABrowsingActivityObserver::Init(); 755 chrome::UMABrowsingActivityObserver::Init();
744 #endif 756 #endif
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 if (base::win::GetVersion() <= base::win::VERSION_XP) 1696 if (base::win::GetVersion() <= base::win::VERSION_XP)
1685 uma_name += "_XP"; 1697 uma_name += "_XP";
1686 1698
1687 uma_name += "_PreRead_"; 1699 uma_name += "_PreRead_";
1688 uma_name += pre_read_percentage; 1700 uma_name += pre_read_percentage;
1689 AddPreReadHistogramTime(uma_name.c_str(), time); 1701 AddPreReadHistogramTime(uma_name.c_str(), time);
1690 } 1702 }
1691 #endif 1703 #endif
1692 #endif 1704 #endif
1693 } 1705 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698