| 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/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/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "ios/web/public/web_thread_delegate.h" | 18 #include "ios/web/public/web_thread_delegate.h" |
| 19 #include "net/disk_cache/simple/simple_backend_impl.h" | 19 #include "net/disk_cache/simple/simple_backend_impl.h" |
| 20 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" |
| 21 | 21 |
| 22 namespace web { | 22 namespace web { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Friendly names for the well-known threads. | 26 // Friendly names for the well-known threads. |
| 27 const char* g_web_thread_names[WebThread::ID_COUNT] = { | 27 const char* const g_web_thread_names[WebThread::ID_COUNT] = { |
| 28 "Web_UIThread", // UI | 28 "Web_UIThread", // UI |
| 29 "Web_DBThread", // DB | 29 "Web_DBThread", // DB |
| 30 "Web_FileThread", // FILE | 30 "Web_FileThread", // FILE |
| 31 "Web_FileUserBlockingThread", // FILE_USER_BLOCKING | 31 "Web_FileUserBlockingThread", // FILE_USER_BLOCKING |
| 32 "Web_CacheThread", // CACHE | 32 "Web_CacheThread", // CACHE |
| 33 "Web_IOThread", // IO | 33 "Web_IOThread", // IO |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 // An implementation of SingleThreadTaskRunner to be used in conjunction | 36 // An implementation of SingleThreadTaskRunner to be used in conjunction |
| 37 // with WebThread. | 37 // with WebThread. |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 296 |
| 297 WebThreadGlobals& globals = g_globals.Get(); | 297 WebThreadGlobals& globals = g_globals.Get(); |
| 298 if (!target_thread_outlives_current) | 298 if (!target_thread_outlives_current) |
| 299 globals.lock.Acquire(); | 299 globals.lock.Acquire(); |
| 300 | 300 |
| 301 base::MessageLoop* message_loop = | 301 base::MessageLoop* message_loop = |
| 302 globals.threads[identifier] ? globals.threads[identifier]->message_loop() | 302 globals.threads[identifier] ? globals.threads[identifier]->message_loop() |
| 303 : nullptr; | 303 : nullptr; |
| 304 if (message_loop) { | 304 if (message_loop) { |
| 305 if (nestable) { | 305 if (nestable) { |
| 306 message_loop->PostDelayedTask(from_here, task, delay); | 306 message_loop->task_runner()->PostDelayedTask(from_here, task, delay); |
| 307 } else { | 307 } else { |
| 308 message_loop->PostNonNestableDelayedTask(from_here, task, delay); | 308 message_loop->task_runner()->PostNonNestableDelayedTask(from_here, task, |
| 309 delay); |
| 309 } | 310 } |
| 310 } | 311 } |
| 311 | 312 |
| 312 if (!target_thread_outlives_current) | 313 if (!target_thread_outlives_current) |
| 313 globals.lock.Release(); | 314 globals.lock.Release(); |
| 314 | 315 |
| 315 return !!message_loop; | 316 return !!message_loop; |
| 316 } | 317 } |
| 317 | 318 |
| 318 // static | 319 // static |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 AtomicWord* storage = | 500 AtomicWord* storage = |
| 500 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); | 501 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); |
| 501 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 502 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 502 storage, reinterpret_cast<AtomicWord>(delegate)); | 503 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 503 | 504 |
| 504 // This catches registration when previously registered. | 505 // This catches registration when previously registered. |
| 505 DCHECK(!delegate || !old_pointer); | 506 DCHECK(!delegate || !old_pointer); |
| 506 } | 507 } |
| 507 | 508 |
| 508 } // namespace web | 509 } // namespace web |
| OLD | NEW |