OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/web/app/web_main_loop.h" | 5 #include "ios/web/app/web_main_loop.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 // The currently-running WebMainLoop. There can be one or zero. | 65 // The currently-running WebMainLoop. There can be one or zero. |
66 // TODO(rohitrao): Desktop uses this to implement | 66 // TODO(rohitrao): Desktop uses this to implement |
67 // ImmediateShutdownAndExitProcess. If we don't need that functionality, we can | 67 // ImmediateShutdownAndExitProcess. If we don't need that functionality, we can |
68 // remove this. | 68 // remove this. |
69 WebMainLoop* g_current_web_main_loop = nullptr; | 69 WebMainLoop* g_current_web_main_loop = nullptr; |
70 | 70 |
71 WebMainLoop::WebMainLoop() : result_code_(0), created_threads_(false) { | 71 WebMainLoop::WebMainLoop() : result_code_(0), created_threads_(false) { |
72 DCHECK(!g_current_web_main_loop); | 72 DCHECK(!g_current_web_main_loop); |
73 g_current_web_main_loop = this; | 73 g_current_web_main_loop = this; |
| 74 |
| 75 // Use an empty string as TaskScheduler name to match the suffix of browser |
| 76 // process TaskScheduler histograms. |
| 77 base::TaskScheduler::Create(""); |
74 } | 78 } |
75 | 79 |
76 WebMainLoop::~WebMainLoop() { | 80 WebMainLoop::~WebMainLoop() { |
77 DCHECK_EQ(this, g_current_web_main_loop); | 81 DCHECK_EQ(this, g_current_web_main_loop); |
78 g_current_web_main_loop = nullptr; | 82 g_current_web_main_loop = nullptr; |
79 } | 83 } |
80 | 84 |
81 void WebMainLoop::Init() { | 85 void WebMainLoop::Init() { |
82 parts_.reset(web::GetWebClient()->CreateWebMainParts()); | 86 parts_.reset(web::GetWebClient()->CreateWebMainParts()); |
83 } | 87 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 142 |
139 int WebMainLoop::PreCreateThreads() { | 143 int WebMainLoop::PreCreateThreads() { |
140 if (parts_) { | 144 if (parts_) { |
141 parts_->PreCreateThreads(); | 145 parts_->PreCreateThreads(); |
142 } | 146 } |
143 | 147 |
144 return result_code_; | 148 return result_code_; |
145 } | 149 } |
146 | 150 |
147 int WebMainLoop::CreateThreads() { | 151 int WebMainLoop::CreateThreads() { |
148 auto task_scheduler_init_params = | 152 { |
149 GetWebClient()->GetTaskSchedulerInitParams(); | 153 auto task_scheduler_init_params = |
150 if (!task_scheduler_init_params) | 154 GetWebClient()->GetTaskSchedulerInitParams(); |
151 task_scheduler_init_params = GetDefaultTaskSchedulerInitParams(); | 155 if (!task_scheduler_init_params) |
152 DCHECK(task_scheduler_init_params); | 156 task_scheduler_init_params = GetDefaultTaskSchedulerInitParams(); |
153 | 157 DCHECK(task_scheduler_init_params); |
154 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( | 158 base::TaskScheduler::GetInstance()->Start( |
155 "", *task_scheduler_init_params.get()); | 159 *task_scheduler_init_params.get()); |
| 160 } |
156 | 161 |
157 GetWebClient()->PerformExperimentalTaskSchedulerRedirections(); | 162 GetWebClient()->PerformExperimentalTaskSchedulerRedirections(); |
158 | 163 |
159 base::Thread::Options io_message_loop_options; | 164 base::Thread::Options io_message_loop_options; |
160 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO; | 165 io_message_loop_options.message_loop_type = base::MessageLoop::TYPE_IO; |
161 | 166 |
162 // Start threads in the order they occur in the WebThread::ID | 167 // Start threads in the order they occur in the WebThread::ID |
163 // enumeration, except for WebThread::UI which is the main | 168 // enumeration, except for WebThread::UI which is the main |
164 // thread. | 169 // thread. |
165 // | 170 // |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 main_thread_.reset( | 311 main_thread_.reset( |
307 new WebThreadImpl(WebThread::UI, base::MessageLoop::current())); | 312 new WebThreadImpl(WebThread::UI, base::MessageLoop::current())); |
308 } | 313 } |
309 | 314 |
310 int WebMainLoop::WebThreadsStarted() { | 315 int WebMainLoop::WebThreadsStarted() { |
311 cookie_notification_bridge_.reset(new CookieNotificationBridge); | 316 cookie_notification_bridge_.reset(new CookieNotificationBridge); |
312 return result_code_; | 317 return result_code_; |
313 } | 318 } |
314 | 319 |
315 } // namespace web | 320 } // namespace web |
OLD | NEW |