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

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: rebase 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
11 #include "base/at_exit.h" 11 #include "base/at_exit.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/debug/trace_event.h" 14 #include "base/debug/trace_event.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/metrics/field_trial.h" 17 #include "base/metrics/field_trial.h"
18 #include "base/metrics/histogram.h" 18 #include "base/metrics/histogram.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/process_info.h" 20 #include "base/process_info.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/run_loop.h" 22 #include "base/run_loop.h"
23 #include "base/string_number_conversions.h" 23 #include "base/string_number_conversions.h"
24 #include "base/string_piece.h" 24 #include "base/string_piece.h"
25 #include "base/string_split.h" 25 #include "base/string_split.h"
26 #include "base/sys_string_conversions.h" 26 #include "base/sys_string_conversions.h"
27 #include "base/threading/platform_thread.h" 27 #include "base/threading/platform_thread.h"
28 #include "base/threading/sequenced_worker_pool.h"
28 #include "base/time.h" 29 #include "base/time.h"
29 #include "base/utf_string_conversions.h" 30 #include "base/utf_string_conversions.h"
30 #include "base/values.h" 31 #include "base/values.h"
31 #include "build/build_config.h" 32 #include "build/build_config.h"
32 #include "chrome/browser/about_flags.h" 33 #include "chrome/browser/about_flags.h"
33 #include "chrome/browser/browser_process.h" 34 #include "chrome/browser/browser_process.h"
34 #include "chrome/browser/browser_process_impl.h" 35 #include "chrome/browser/browser_process_impl.h"
35 #include "chrome/browser/browser_shutdown.h" 36 #include "chrome/browser/browser_shutdown.h"
36 #include "chrome/browser/chrome_browser_main_extra_parts.h" 37 #include "chrome/browser/chrome_browser_main_extra_parts.h"
37 #include "chrome/browser/chrome_gpu_util.h" 38 #include "chrome/browser/chrome_gpu_util.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 used_spdy_switch = true; 261 used_spdy_switch = true;
261 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { 262 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) {
262 net::HttpStreamFactory::EnableNpnHttpOnly(); 263 net::HttpStreamFactory::EnableNpnHttpOnly();
263 used_spdy_switch = true; 264 used_spdy_switch = true;
264 } 265 }
265 if (!used_spdy_switch) { 266 if (!used_spdy_switch) {
266 net::HttpStreamFactory::EnableNpnSpdy3(); 267 net::HttpStreamFactory::EnableNpnSpdy3();
267 } 268 }
268 } 269 }
269 270
270 // Returns the new local state object, guaranteed non-NULL. 271 // Returns the new local state object, guaranteed non-NULL.
akalin 2012/10/18 23:52:24 add a comment saying that local_state_task_runner
zel 2012/10/19 01:20:32 Done.
271 PrefService* InitializeLocalState(const CommandLine& parsed_command_line, 272 PrefService* InitializeLocalState(
272 bool is_first_run) { 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 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner =
akalin 2012/10/18 23:52:24 can you instead get the local state path here and
zel 2012/10/19 01:20:32 Done.
713 BrowserThread::GetBlockingPool()->
714 GetSequencedTaskRunnerWithShutdownBehavior(
715 BrowserThread::GetBlockingPool()->GetNamedSequenceToken(
716 "local_state_pool"),
717 base::SequencedWorkerPool::BLOCK_SHUTDOWN);
718
719 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner,
720 parsed_command_line()));
708 721
709 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { 722 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) {
710 // User wants to override default tracking status. 723 // User wants to override default tracking status.
711 std::string flag = 724 std::string flag =
712 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); 725 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling);
713 // Default to basic profiling (no parent child support). 726 // Default to basic profiling (no parent child support).
714 tracked_objects::ThreadData::Status status = 727 tracked_objects::ThreadData::Status status =
715 tracked_objects::ThreadData::PROFILING_ACTIVE; 728 tracked_objects::ThreadData::PROFILING_ACTIVE;
716 if (flag.compare("0") != 0) 729 if (flag.compare("0") != 0)
717 status = tracked_objects::ThreadData::DEACTIVATED; 730 status = tracked_objects::ThreadData::DEACTIVATED;
718 else if (flag.compare("child") != 0) 731 else if (flag.compare("child") != 0)
719 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE; 732 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE;
720 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); 733 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status);
721 } 734 }
722 735
723 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) { 736 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) {
724 tracking_objects_.set_output_file_path( 737 tracking_objects_.set_output_file_path(
725 parsed_command_line().GetSwitchValuePath( 738 parsed_command_line().GetSwitchValuePath(
726 switches::kProfilingOutputFile)); 739 switches::kProfilingOutputFile));
727 } 740 }
728 741
729 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_); 742 local_state_ = InitializeLocalState(local_state_task_runner,
743 parsed_command_line(),
744 is_first_run_);
730 745
731 // These members must be initialized before returning from this function. 746 // These members must be initialized before returning from this function.
732 master_prefs_.reset(new first_run::MasterPrefs); 747 master_prefs_.reset(new first_run::MasterPrefs);
733 748
734 #if !defined(OS_ANDROID) 749 #if !defined(OS_ANDROID)
735 // Android doesn't use StartupBrowserCreator. 750 // Android doesn't use StartupBrowserCreator.
736 browser_creator_.reset(new StartupBrowserCreator); 751 browser_creator_.reset(new StartupBrowserCreator);
737 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver 752 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver
738 chrome::UMABrowsingActivityObserver::Init(); 753 chrome::UMABrowsingActivityObserver::Init();
739 #endif 754 #endif
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 if (base::win::GetVersion() <= base::win::VERSION_XP) 1656 if (base::win::GetVersion() <= base::win::VERSION_XP)
1642 uma_name += "_XP"; 1657 uma_name += "_XP";
1643 1658
1644 uma_name += "_PreRead_"; 1659 uma_name += "_PreRead_";
1645 uma_name += pre_read_percentage; 1660 uma_name += pre_read_percentage;
1646 AddPreReadHistogramTime(uma_name.c_str(), time); 1661 AddPreReadHistogramTime(uma_name.c_str(), time);
1647 } 1662 }
1648 #endif 1663 #endif
1649 #endif 1664 #endif
1650 } 1665 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698