| OLD | NEW |
| 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 "content/browser/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 result_code_(RESULT_CODE_NORMAL_EXIT), | 524 result_code_(RESULT_CODE_NORMAL_EXIT), |
| 525 created_threads_(false), | 525 created_threads_(false), |
| 526 // ContentMainRunner should have enabled tracing of the browser process | 526 // ContentMainRunner should have enabled tracing of the browser process |
| 527 // when kTraceStartup or kTraceConfigFile is in the command line. | 527 // when kTraceStartup or kTraceConfigFile is in the command line. |
| 528 is_tracing_startup_for_duration_( | 528 is_tracing_startup_for_duration_( |
| 529 parameters.command_line.HasSwitch(switches::kTraceStartup) || | 529 parameters.command_line.HasSwitch(switches::kTraceStartup) || |
| 530 (tracing::TraceConfigFile::GetInstance()->IsEnabled() && | 530 (tracing::TraceConfigFile::GetInstance()->IsEnabled() && |
| 531 tracing::TraceConfigFile::GetInstance()->GetStartupDuration() > 0)) { | 531 tracing::TraceConfigFile::GetInstance()->GetStartupDuration() > 0)) { |
| 532 DCHECK(!g_current_browser_main_loop); | 532 DCHECK(!g_current_browser_main_loop); |
| 533 g_current_browser_main_loop = this; | 533 g_current_browser_main_loop = this; |
| 534 |
| 535 // Use an empty string as TaskScheduler name to match the suffix of browser |
| 536 // process TaskScheduler histograms. |
| 537 base::TaskScheduler::Create(""); |
| 534 } | 538 } |
| 535 | 539 |
| 536 BrowserMainLoop::~BrowserMainLoop() { | 540 BrowserMainLoop::~BrowserMainLoop() { |
| 537 DCHECK_EQ(this, g_current_browser_main_loop); | 541 DCHECK_EQ(this, g_current_browser_main_loop); |
| 538 ui::Clipboard::DestroyClipboardForCurrentThread(); | 542 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 539 g_current_browser_main_loop = NULL; | 543 g_current_browser_main_loop = NULL; |
| 540 } | 544 } |
| 541 | 545 |
| 542 void BrowserMainLoop::Init() { | 546 void BrowserMainLoop::Init() { |
| 543 TRACE_EVENT0("startup", "BrowserMainLoop::Init"); | 547 TRACE_EVENT0("startup", "BrowserMainLoop::Init"); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 startup_task_runner_->RunAllTasksNow(); | 948 startup_task_runner_->RunAllTasksNow(); |
| 945 } | 949 } |
| 946 #else | 950 #else |
| 947 startup_task_runner_->RunAllTasksNow(); | 951 startup_task_runner_->RunAllTasksNow(); |
| 948 #endif | 952 #endif |
| 949 } | 953 } |
| 950 | 954 |
| 951 int BrowserMainLoop::CreateThreads() { | 955 int BrowserMainLoop::CreateThreads() { |
| 952 TRACE_EVENT0("startup,rail", "BrowserMainLoop::CreateThreads"); | 956 TRACE_EVENT0("startup,rail", "BrowserMainLoop::CreateThreads"); |
| 953 | 957 |
| 954 auto task_scheduler_init_params = | 958 { |
| 955 GetContentClient()->browser()->GetTaskSchedulerInitParams(); | 959 auto task_scheduler_init_params = |
| 956 if (!task_scheduler_init_params) | 960 GetContentClient()->browser()->GetTaskSchedulerInitParams(); |
| 957 task_scheduler_init_params = GetDefaultTaskSchedulerInitParams(); | 961 if (!task_scheduler_init_params) |
| 958 DCHECK(task_scheduler_init_params); | 962 task_scheduler_init_params = GetDefaultTaskSchedulerInitParams(); |
| 959 | 963 DCHECK(task_scheduler_init_params); |
| 960 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( | 964 base::TaskScheduler::GetInstance()->Start( |
| 961 "", *task_scheduler_init_params.get()); | 965 *task_scheduler_init_params.get()); |
| 966 } |
| 962 | 967 |
| 963 GetContentClient()->browser()->PerformExperimentalTaskSchedulerRedirections(); | 968 GetContentClient()->browser()->PerformExperimentalTaskSchedulerRedirections(); |
| 964 | 969 |
| 965 base::Thread::Options io_message_loop_options; | 970 base::Thread::Options io_message_loop_options; |
| 966 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO; | 971 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 967 base::Thread::Options ui_message_loop_options; | 972 base::Thread::Options ui_message_loop_options; |
| 968 ui_message_loop_options.message_loop_type = base::MessageLoop::TYPE_UI; | 973 ui_message_loop_options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 969 | 974 |
| 970 const bool redirect_nonUInonIO_browser_threads = | 975 const bool redirect_nonUInonIO_browser_threads = |
| 971 GetContentClient() | 976 GetContentClient() |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 1756 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
| 1752 MediaInternals::GetInstance()); | 1757 MediaInternals::GetInstance()); |
| 1753 } | 1758 } |
| 1754 CHECK(audio_manager_); | 1759 CHECK(audio_manager_); |
| 1755 | 1760 |
| 1756 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); | 1761 audio_system_ = media::AudioSystemImpl::Create(audio_manager_.get()); |
| 1757 CHECK(audio_system_); | 1762 CHECK(audio_system_); |
| 1758 } | 1763 } |
| 1759 | 1764 |
| 1760 } // namespace content | 1765 } // namespace content |
| OLD | NEW |