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

Side by Side Diff: ios/web/web_thread_impl.cc

Issue 2136563002: Remove calls to MessageLoop::current() in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: restore dns_config_service_posix_unittest.cc Created 4 years, 5 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 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/web_thread_impl.h" 5 #include "ios/web/web_thread_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/atomicops.h" 9 #include "base/atomicops.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/threading/sequenced_worker_pool.h" 17 #include "base/threading/sequenced_worker_pool.h"
17 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
18 #include "ios/web/public/web_thread_delegate.h" 19 #include "ios/web/public/web_thread_delegate.h"
19 #include "net/disk_cache/simple/simple_backend_impl.h" 20 #include "net/disk_cache/simple/simple_backend_impl.h"
20 #include "net/url_request/url_fetcher.h" 21 #include "net/url_request/url_fetcher.h"
21 22
22 namespace web { 23 namespace web {
23 24
24 namespace { 25 namespace {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 162
162 if (WebThread::CurrentlyOn(WebThread::IO)) { 163 if (WebThread::CurrentlyOn(WebThread::IO)) {
163 // Though this thread is called the "IO" thread, it actually just routes 164 // Though this thread is called the "IO" thread, it actually just routes
164 // messages around; it shouldn't be allowed to perform any blocking disk 165 // messages around; it shouldn't be allowed to perform any blocking disk
165 // I/O. 166 // I/O.
166 base::ThreadRestrictions::SetIOAllowed(false); 167 base::ThreadRestrictions::SetIOAllowed(false);
167 base::ThreadRestrictions::DisallowWaiting(); 168 base::ThreadRestrictions::DisallowWaiting();
168 } 169 }
169 } 170 }
170 171
171 NOINLINE void WebThreadImpl::UIThreadRun(base::MessageLoop* message_loop) { 172 NOINLINE void WebThreadImpl::UIThreadRun(base::RunLoop* run_loop) {
172 volatile int line_number = __LINE__; 173 volatile int line_number = __LINE__;
173 Thread::Run(message_loop); 174 Thread::Run(run_loop);
174 CHECK_GT(line_number, 0); 175 CHECK_GT(line_number, 0);
175 } 176 }
176 177
177 NOINLINE void WebThreadImpl::DBThreadRun(base::MessageLoop* message_loop) { 178 NOINLINE void WebThreadImpl::DBThreadRun(base::RunLoop* run_loop) {
178 volatile int line_number = __LINE__; 179 volatile int line_number = __LINE__;
179 Thread::Run(message_loop); 180 Thread::Run(run_loop);
180 CHECK_GT(line_number, 0); 181 CHECK_GT(line_number, 0);
181 } 182 }
182 183
183 NOINLINE void WebThreadImpl::FileThreadRun(base::MessageLoop* message_loop) { 184 NOINLINE void WebThreadImpl::FileThreadRun(base::RunLoop* run_loop) {
184 volatile int line_number = __LINE__; 185 volatile int line_number = __LINE__;
185 Thread::Run(message_loop); 186 Thread::Run(run_loop);
186 CHECK_GT(line_number, 0); 187 CHECK_GT(line_number, 0);
187 } 188 }
188 189
189 NOINLINE void WebThreadImpl::FileUserBlockingThreadRun( 190 NOINLINE void WebThreadImpl::FileUserBlockingThreadRun(
190 base::MessageLoop* message_loop) { 191 base::RunLoop* run_loop) {
191 volatile int line_number = __LINE__; 192 volatile int line_number = __LINE__;
192 Thread::Run(message_loop); 193 Thread::Run(run_loop);
193 CHECK_GT(line_number, 0); 194 CHECK_GT(line_number, 0);
194 } 195 }
195 196
196 NOINLINE void WebThreadImpl::CacheThreadRun(base::MessageLoop* message_loop) { 197 NOINLINE void WebThreadImpl::CacheThreadRun(base::RunLoop* run_loop) {
197 volatile int line_number = __LINE__; 198 volatile int line_number = __LINE__;
198 Thread::Run(message_loop); 199 Thread::Run(run_loop);
199 CHECK_GT(line_number, 0); 200 CHECK_GT(line_number, 0);
200 } 201 }
201 202
202 NOINLINE void WebThreadImpl::IOThreadRun(base::MessageLoop* message_loop) { 203 NOINLINE void WebThreadImpl::IOThreadRun(base::RunLoop* run_loop) {
203 volatile int line_number = __LINE__; 204 volatile int line_number = __LINE__;
204 Thread::Run(message_loop); 205 Thread::Run(run_loop);
205 CHECK_GT(line_number, 0); 206 CHECK_GT(line_number, 0);
206 } 207 }
207 208
208 void WebThreadImpl::Run(base::MessageLoop* message_loop) { 209 void WebThreadImpl::Run(base::RunLoop* run_loop) {
209 WebThread::ID thread_id = ID_COUNT; 210 WebThread::ID thread_id = ID_COUNT;
210 if (!GetCurrentThreadIdentifier(&thread_id)) 211 if (!GetCurrentThreadIdentifier(&thread_id))
211 return Thread::Run(message_loop); 212 return Thread::Run(run_loop);
212 213
213 switch (thread_id) { 214 switch (thread_id) {
214 case WebThread::UI: 215 case WebThread::UI:
215 return UIThreadRun(message_loop); 216 return UIThreadRun(run_loop);
216 case WebThread::DB: 217 case WebThread::DB:
217 return DBThreadRun(message_loop); 218 return DBThreadRun(run_loop);
218 case WebThread::FILE: 219 case WebThread::FILE:
219 return FileThreadRun(message_loop); 220 return FileThreadRun(run_loop);
220 case WebThread::FILE_USER_BLOCKING: 221 case WebThread::FILE_USER_BLOCKING:
221 return FileUserBlockingThreadRun(message_loop); 222 return FileUserBlockingThreadRun(run_loop);
222 case WebThread::CACHE: 223 case WebThread::CACHE:
223 return CacheThreadRun(message_loop); 224 return CacheThreadRun(run_loop);
224 case WebThread::IO: 225 case WebThread::IO:
225 return IOThreadRun(message_loop); 226 return IOThreadRun(run_loop);
226 case WebThread::ID_COUNT: 227 case WebThread::ID_COUNT:
227 CHECK(false); // This shouldn't actually be reached! 228 CHECK(false); // This shouldn't actually be reached!
228 break; 229 break;
229 } 230 }
230 Thread::Run(message_loop); 231 Thread::Run(run_loop);
231 } 232 }
232 233
233 void WebThreadImpl::CleanUp() { 234 void WebThreadImpl::CleanUp() {
234 if (WebThread::CurrentlyOn(WebThread::IO)) 235 if (WebThread::CurrentlyOn(WebThread::IO))
235 IOThreadPreCleanUp(); 236 IOThreadPreCleanUp();
236 237
237 WebThreadGlobals& globals = g_globals.Get(); 238 WebThreadGlobals& globals = g_globals.Get();
238 239
239 using base::subtle::AtomicWord; 240 using base::subtle::AtomicWord;
240 AtomicWord* storage = 241 AtomicWord* storage =
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 AtomicWord* storage = 496 AtomicWord* storage =
496 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); 497 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]);
497 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( 498 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange(
498 storage, reinterpret_cast<AtomicWord>(delegate)); 499 storage, reinterpret_cast<AtomicWord>(delegate));
499 500
500 // This catches registration when previously registered. 501 // This catches registration when previously registered.
501 DCHECK(!delegate || !old_pointer); 502 DCHECK(!delegate || !old_pointer);
502 } 503 }
503 504
504 } // namespace web 505 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698