| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 323 } |
| 324 } | 324 } |
| 325 | 325 |
| 326 if (!target_thread_outlives_current) | 326 if (!target_thread_outlives_current) |
| 327 globals.lock.Release(); | 327 globals.lock.Release(); |
| 328 | 328 |
| 329 return !!message_loop; | 329 return !!message_loop; |
| 330 } | 330 } |
| 331 | 331 |
| 332 // static | 332 // static |
| 333 bool WebThread::PostBlockingPoolTask(const tracked_objects::Location& from_here, |
| 334 base::OnceClosure task) { |
| 335 return g_globals.Get().blocking_pool->PostWorkerTask(from_here, |
| 336 std::move(task)); |
| 337 } |
| 338 |
| 339 // static |
| 340 bool WebThread::PostBlockingPoolTaskAndReply( |
| 341 const tracked_objects::Location& from_here, |
| 342 base::OnceClosure task, |
| 343 base::OnceClosure reply) { |
| 344 return g_globals.Get().blocking_pool->PostTaskAndReply( |
| 345 from_here, std::move(task), std::move(reply)); |
| 346 } |
| 347 |
| 348 // static |
| 349 bool WebThread::PostBlockingPoolSequencedTask( |
| 350 const std::string& sequence_token_name, |
| 351 const tracked_objects::Location& from_here, |
| 352 base::OnceClosure task) { |
| 353 return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask( |
| 354 sequence_token_name, from_here, std::move(task)); |
| 355 } |
| 356 |
| 357 // static |
| 333 base::SequencedWorkerPool* WebThread::GetBlockingPool() { | 358 base::SequencedWorkerPool* WebThread::GetBlockingPool() { |
| 334 return g_globals.Get().blocking_pool.get(); | 359 return g_globals.Get().blocking_pool.get(); |
| 335 } | 360 } |
| 336 | 361 |
| 337 // static | 362 // static |
| 338 bool WebThread::IsThreadInitialized(ID identifier) { | 363 bool WebThread::IsThreadInitialized(ID identifier) { |
| 339 if (g_globals == nullptr) | 364 if (g_globals == nullptr) |
| 340 return false; | 365 return false; |
| 341 | 366 |
| 342 WebThreadGlobals& globals = g_globals.Get(); | 367 WebThreadGlobals& globals = g_globals.Get(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 AtomicWord* storage = | 481 AtomicWord* storage = |
| 457 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); | 482 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); |
| 458 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 483 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 459 storage, reinterpret_cast<AtomicWord>(delegate)); | 484 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 460 | 485 |
| 461 // This catches registration when previously registered. | 486 // This catches registration when previously registered. |
| 462 DCHECK(!delegate || !old_pointer); | 487 DCHECK(!delegate || !old_pointer); |
| 463 } | 488 } |
| 464 | 489 |
| 465 } // namespace web | 490 } // namespace web |
| OLD | NEW |