| 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" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 bool WebThread::CurrentlyOn(ID identifier) { | 366 bool WebThread::CurrentlyOn(ID identifier) { |
| 367 // This shouldn't use MessageLoop::current() since it uses LazyInstance which | 367 // This shouldn't use MessageLoop::current() since it uses LazyInstance which |
| 368 // may be deleted by ~AtExitManager when a WorkerPool thread calls this | 368 // may be deleted by ~AtExitManager when a WorkerPool thread calls this |
| 369 // function. | 369 // function. |
| 370 // http://crbug.com/63678 | 370 // http://crbug.com/63678 |
| 371 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; | 371 base::ThreadRestrictions::ScopedAllowSingleton allow_singleton; |
| 372 WebThreadGlobals& globals = g_globals.Get(); | 372 WebThreadGlobals& globals = g_globals.Get(); |
| 373 base::AutoLock lock(globals.lock); | 373 base::AutoLock lock(globals.lock); |
| 374 DCHECK(identifier >= 0 && identifier < ID_COUNT); | 374 DCHECK(identifier >= 0 && identifier < ID_COUNT); |
| 375 return globals.threads[identifier] && | 375 return globals.threads[identifier] && |
| 376 globals.threads[identifier]->task_runner()->BelongsToCurrentThread(); | 376 globals.threads[identifier]->message_loop() == |
| 377 base::MessageLoop::current(); |
| 377 } | 378 } |
| 378 | 379 |
| 379 // static | 380 // static |
| 380 std::string WebThread::GetDCheckCurrentlyOnErrorMessage(ID expected) { | 381 std::string WebThread::GetDCheckCurrentlyOnErrorMessage(ID expected) { |
| 381 std::string actual_name = base::PlatformThread::GetName(); | 382 std::string actual_name = base::PlatformThread::GetName(); |
| 382 if (actual_name.empty()) | 383 if (actual_name.empty()) |
| 383 actual_name = "Unknown Thread"; | 384 actual_name = "Unknown Thread"; |
| 384 | 385 |
| 385 std::string result = "Must be called on "; | 386 std::string result = "Must be called on "; |
| 386 result += GetThreadName(expected); | 387 result += GetThreadName(expected); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |