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

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

Issue 2241703002: Add an experiment to redirect SequencedWorkerPool tasks to TaskScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b3_delay_metrics_blocking
Patch Set: Created 4 years, 4 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 23 matching lines...) Expand all
34 #include "base/strings/string_piece.h" 34 #include "base/strings/string_piece.h"
35 #include "base/strings/string_split.h" 35 #include "base/strings/string_split.h"
36 #include "base/strings/sys_string_conversions.h" 36 #include "base/strings/sys_string_conversions.h"
37 #include "base/strings/utf_string_conversions.h" 37 #include "base/strings/utf_string_conversions.h"
38 #include "base/sys_info.h" 38 #include "base/sys_info.h"
39 #include "base/task_scheduler/scheduler_worker_pool_params.h" 39 #include "base/task_scheduler/scheduler_worker_pool_params.h"
40 #include "base/task_scheduler/switches.h" 40 #include "base/task_scheduler/switches.h"
41 #include "base/task_scheduler/task_scheduler.h" 41 #include "base/task_scheduler/task_scheduler.h"
42 #include "base/task_scheduler/task_traits.h" 42 #include "base/task_scheduler/task_traits.h"
43 #include "base/threading/platform_thread.h" 43 #include "base/threading/platform_thread.h"
44 #include "base/threading/sequenced_worker_pool.h"
44 #include "base/time/default_tick_clock.h" 45 #include "base/time/default_tick_clock.h"
45 #include "base/time/time.h" 46 #include "base/time/time.h"
46 #include "base/trace_event/trace_event.h" 47 #include "base/trace_event/trace_event.h"
47 #include "base/values.h" 48 #include "base/values.h"
48 #include "build/build_config.h" 49 #include "build/build_config.h"
49 #include "cc/base/switches.h" 50 #include "cc/base/switches.h"
50 #include "chrome/browser/about_flags.h" 51 #include "chrome/browser/about_flags.h"
51 #include "chrome/browser/after_startup_task_utils.h" 52 #include "chrome/browser/after_startup_task_utils.h"
52 #include "chrome/browser/browser_process.h" 53 #include "chrome/browser/browser_process.h"
53 #include "chrome/browser/browser_process_impl.h" 54 #include "chrome/browser/browser_process_impl.h"
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 predefined_params.priority_hint, 446 predefined_params.priority_hint,
446 predefined_params.io_restriction, 447 predefined_params.io_restriction,
447 variation_values.threads, 448 variation_values.threads,
448 variation_values.detach_period); 449 variation_values.detach_period);
449 } 450 }
450 451
451 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size()); 452 DCHECK_EQ(WORKER_POOL_COUNT, params_vector.size());
452 453
453 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( 454 base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
454 params_vector, base::Bind(WorkerPoolIndexForTraits)); 455 params_vector, base::Bind(WorkerPoolIndexForTraits));
456
457 const auto sequenced_worker_pool_param =
brettw 2016/08/12 19:30:00 This should have a reference to a bug to remove it
gab 2016/08/12 23:27:46 Done.
458 variation_params.find("RedirectSequencedWorkerPools");
459 if (sequenced_worker_pool_param != variation_params.end() &&
460 sequenced_worker_pool_param->second == "true") {
461 base::SequencedWorkerPool::
462 RedirectSequencedWorkerPoolsToTaskSchedulerForProcess();
463 }
455 } 464 }
456 465
457 // Returns the new local state object, guaranteed non-NULL. 466 // Returns the new local state object, guaranteed non-NULL.
458 // |local_state_task_runner| must be a shutdown-blocking task runner. 467 // |local_state_task_runner| must be a shutdown-blocking task runner.
459 PrefService* InitializeLocalState( 468 PrefService* InitializeLocalState(
460 base::SequencedTaskRunner* local_state_task_runner, 469 base::SequencedTaskRunner* local_state_task_runner,
461 const base::CommandLine& parsed_command_line) { 470 const base::CommandLine& parsed_command_line) {
462 TRACE_EVENT0("startup", "ChromeBrowserMainParts::InitializeLocalState") 471 TRACE_EVENT0("startup", "ChromeBrowserMainParts::InitializeLocalState")
463 472
464 // Load local state. This includes the application locale so we know which 473 // Load local state. This includes the application locale so we know which
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 chromeos::CrosSettings::Initialize(); 1349 chromeos::CrosSettings::Initialize();
1341 #endif // defined(OS_CHROMEOS) 1350 #endif // defined(OS_CHROMEOS)
1342 1351
1343 SetupOriginTrialsCommandLine(); 1352 SetupOriginTrialsCommandLine();
1344 1353
1345 // Now the command line has been mutated based on about:flags, we can setup 1354 // Now the command line has been mutated based on about:flags, we can setup
1346 // metrics and initialize field trials. The field trials are needed by 1355 // metrics and initialize field trials. The field trials are needed by
1347 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads. 1356 // IOThread's initialization which happens in BrowserProcess:PreCreateThreads.
1348 SetupMetricsAndFieldTrials(); 1357 SetupMetricsAndFieldTrials();
1349 1358
1350 MaybeInitializeTaskScheduler();
1351
1352 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this. 1359 // ChromeOS needs ResourceBundle::InitSharedInstance to be called before this.
1353 browser_process_->PreCreateThreads(); 1360 browser_process_->PreCreateThreads();
1354 1361
1355 device::GeolocationProvider::SetGeolocationDelegate( 1362 device::GeolocationProvider::SetGeolocationDelegate(
1356 new ChromeGeolocationDelegate()); 1363 new ChromeGeolocationDelegate());
1357 1364
1365 // This needs to be the last thing in PreCreateThreads() because the
1366 // TaskScheduler needs to be created before any other threads are (by
1367 // contract) but it creates threads itself so instantiating it earlier is also
1368 // incorrect. It also has to be after SetupMetricsAndFieldTrials() to allow it
1369 // to use field trials. Note: it could also be the first thing in
1370 // CreateThreads() but being in chrome/ is convenient for now as the
1371 // initialization uses variations parameters extensively.
1372 MaybeInitializeTaskScheduler();
1373
1358 return content::RESULT_CODE_NORMAL_EXIT; 1374 return content::RESULT_CODE_NORMAL_EXIT;
1359 } 1375 }
1360 1376
1361 void ChromeBrowserMainParts::MojoShellConnectionStarted( 1377 void ChromeBrowserMainParts::MojoShellConnectionStarted(
1362 content::MojoShellConnection* connection) { 1378 content::MojoShellConnection* connection) {
1363 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1379 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1364 chrome_extra_parts_[i]->MojoShellConnectionStarted(connection); 1380 chrome_extra_parts_[i]->MojoShellConnectionStarted(connection);
1365 } 1381 }
1366 1382
1367 void ChromeBrowserMainParts::PreMainMessageLoopRun() { 1383 void ChromeBrowserMainParts::PreMainMessageLoopRun() {
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 chromeos::CrosSettings::Shutdown(); 2225 chromeos::CrosSettings::Shutdown();
2210 #endif // defined(OS_CHROMEOS) 2226 #endif // defined(OS_CHROMEOS)
2211 #endif // defined(OS_ANDROID) 2227 #endif // defined(OS_ANDROID)
2212 } 2228 }
2213 2229
2214 // Public members: 2230 // Public members:
2215 2231
2216 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 2232 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
2217 chrome_extra_parts_.push_back(parts); 2233 chrome_extra_parts_.push_back(parts);
2218 } 2234 }
OLDNEW
« base/threading/sequenced_worker_pool.cc ('K') | « base/threading/sequenced_worker_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698