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

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: Created 8 years, 2 months 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { 261 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) {
262 net::HttpStreamFactory::EnableNpnHttpOnly(); 262 net::HttpStreamFactory::EnableNpnHttpOnly();
263 used_spdy_switch = true; 263 used_spdy_switch = true;
264 } 264 }
265 if (!used_spdy_switch) { 265 if (!used_spdy_switch) {
266 net::HttpStreamFactory::EnableNpnSpdy3(); 266 net::HttpStreamFactory::EnableNpnSpdy3();
267 } 267 }
268 } 268 }
269 269
270 // Returns the new local state object, guaranteed non-NULL. 270 // Returns the new local state object, guaranteed non-NULL.
271 PrefService* InitializeLocalState(const CommandLine& parsed_command_line, 271 // |local_state_task_runner| must be a shutdown-blocking task runner.
272 bool is_first_run) { 272 PrefService* InitializeLocalState(
273 base::SequencedTaskRunner* local_state_task_runner,
274 const CommandLine& parsed_command_line,
275 bool is_first_run) {
273 FilePath local_state_path; 276 FilePath local_state_path;
274 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); 277 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
275 bool local_state_file_exists = file_util::PathExists(local_state_path); 278 bool local_state_file_exists = file_util::PathExists(local_state_path);
276 279
277 // Load local state. This includes the application locale so we know which 280 // Load local state. This includes the application locale so we know which
278 // locale dll to load. 281 // locale dll to load.
279 PrefService* local_state = g_browser_process->local_state(); 282 PrefService* local_state = g_browser_process->local_state();
280 DCHECK(local_state); 283 DCHECK(local_state);
281 284
282 // TODO(brettw,*): this comment about ResourceBundle was here since 285 // TODO(brettw,*): this comment about ResourceBundle was here since
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // since the parent profile command line flag can be present even when the 321 // since the parent profile command line flag can be present even when the
319 // current profile is not a new one, and in that case we do not want to 322 // current profile is not a new one, and in that case we do not want to
320 // inherit and reset the user's setting. 323 // inherit and reset the user's setting.
321 if (!local_state_file_exists && 324 if (!local_state_file_exists &&
322 parsed_command_line.HasSwitch(switches::kParentProfile)) { 325 parsed_command_line.HasSwitch(switches::kParentProfile)) {
323 FilePath parent_profile = 326 FilePath parent_profile =
324 parsed_command_line.GetSwitchValuePath(switches::kParentProfile); 327 parsed_command_line.GetSwitchValuePath(switches::kParentProfile);
325 scoped_ptr<PrefService> parent_local_state( 328 scoped_ptr<PrefService> parent_local_state(
326 PrefService::CreatePrefService(parent_profile, 329 PrefService::CreatePrefService(parent_profile,
327 g_browser_process->policy_service(), 330 g_browser_process->policy_service(),
328 NULL, false)); 331 NULL, false, local_state_task_runner));
329 parent_local_state->RegisterStringPref(prefs::kApplicationLocale, 332 parent_local_state->RegisterStringPref(prefs::kApplicationLocale,
330 std::string()); 333 std::string());
331 // Right now, we only inherit the locale setting from the parent profile. 334 // Right now, we only inherit the locale setting from the parent profile.
332 local_state->SetString( 335 local_state->SetString(
333 prefs::kApplicationLocale, 336 prefs::kApplicationLocale,
334 parent_local_state->GetString(prefs::kApplicationLocale)); 337 parent_local_state->GetString(prefs::kApplicationLocale));
335 } 338 }
336 339
337 #if defined(OS_CHROMEOS) 340 #if defined(OS_CHROMEOS)
338 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { 341 if (parsed_command_line.HasSwitch(switches::kLoginManager)) {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); 700 process_singleton_.reset(new ProcessSingleton(user_data_dir_));
698 // Ensure ProcessSingleton won't process messages too early. It will be 701 // Ensure ProcessSingleton won't process messages too early. It will be
699 // unlocked in PostBrowserStart(). 702 // unlocked in PostBrowserStart().
700 process_singleton_->Lock(NULL); 703 process_singleton_->Lock(NULL);
701 704
702 is_first_run_ = 705 is_first_run_ =
703 (first_run::IsChromeFirstRun() || 706 (first_run::IsChromeFirstRun() ||
704 parsed_command_line().HasSwitch(switches::kFirstRun)) && 707 parsed_command_line().HasSwitch(switches::kFirstRun)) &&
705 !HasImportSwitch(parsed_command_line()); 708 !HasImportSwitch(parsed_command_line());
706 #endif 709 #endif
707 browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); 710
711
712 FilePath local_state_path;
713 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
akalin 2012/10/19 23:12:21 hmm. CHECK or otherwise handle if Get() returns fa
zel 2012/10/21 20:03:19 Done.
714 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner =
715 JsonPrefStore::GetTaskRunnerForFile(local_state_path,
716 BrowserThread::GetBlockingPool());
717 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner,
718 parsed_command_line()));
708 719
709 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { 720 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) {
710 // User wants to override default tracking status. 721 // User wants to override default tracking status.
711 std::string flag = 722 std::string flag =
712 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); 723 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling);
713 // Default to basic profiling (no parent child support). 724 // Default to basic profiling (no parent child support).
714 tracked_objects::ThreadData::Status status = 725 tracked_objects::ThreadData::Status status =
715 tracked_objects::ThreadData::PROFILING_ACTIVE; 726 tracked_objects::ThreadData::PROFILING_ACTIVE;
716 if (flag.compare("0") != 0) 727 if (flag.compare("0") != 0)
717 status = tracked_objects::ThreadData::DEACTIVATED; 728 status = tracked_objects::ThreadData::DEACTIVATED;
718 else if (flag.compare("child") != 0) 729 else if (flag.compare("child") != 0)
719 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE; 730 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE;
720 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); 731 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status);
721 } 732 }
722 733
723 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) { 734 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) {
724 tracking_objects_.set_output_file_path( 735 tracking_objects_.set_output_file_path(
725 parsed_command_line().GetSwitchValuePath( 736 parsed_command_line().GetSwitchValuePath(
726 switches::kProfilingOutputFile)); 737 switches::kProfilingOutputFile));
727 } 738 }
728 739
729 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_); 740 local_state_ = InitializeLocalState(local_state_task_runner,
741 parsed_command_line(),
742 is_first_run_);
730 743
731 // These members must be initialized before returning from this function. 744 // These members must be initialized before returning from this function.
732 master_prefs_.reset(new first_run::MasterPrefs); 745 master_prefs_.reset(new first_run::MasterPrefs);
733 746
734 #if !defined(OS_ANDROID) 747 #if !defined(OS_ANDROID)
735 // Android doesn't use StartupBrowserCreator. 748 // Android doesn't use StartupBrowserCreator.
736 browser_creator_.reset(new StartupBrowserCreator); 749 browser_creator_.reset(new StartupBrowserCreator);
737 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver 750 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver
738 chrome::UMABrowsingActivityObserver::Init(); 751 chrome::UMABrowsingActivityObserver::Init();
739 #endif 752 #endif
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 if (base::win::GetVersion() <= base::win::VERSION_XP) 1654 if (base::win::GetVersion() <= base::win::VERSION_XP)
1642 uma_name += "_XP"; 1655 uma_name += "_XP";
1643 1656
1644 uma_name += "_PreRead_"; 1657 uma_name += "_PreRead_";
1645 uma_name += pre_read_percentage; 1658 uma_name += pre_read_percentage;
1646 AddPreReadHistogramTime(uma_name.c_str(), time); 1659 AddPreReadHistogramTime(uma_name.c_str(), time);
1647 } 1660 }
1648 #endif 1661 #endif
1649 #endif 1662 #endif
1650 } 1663 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698