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

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

Powered by Google App Engine
This is Rietveld 408576698