| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 scoped_refptr<base::SingleThreadTaskRunner> task_runners[WebThread::ID_COUNT]; | 82 scoped_refptr<base::SingleThreadTaskRunner> task_runners[WebThread::ID_COUNT]; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 base::LazyInstance<WebThreadTaskRunners>::Leaky g_task_runners = | 85 base::LazyInstance<WebThreadTaskRunners>::Leaky g_task_runners = |
| 86 LAZY_INSTANCE_INITIALIZER; | 86 LAZY_INSTANCE_INITIALIZER; |
| 87 | 87 |
| 88 struct WebThreadGlobals { | 88 struct WebThreadGlobals { |
| 89 WebThreadGlobals() | 89 WebThreadGlobals() |
| 90 : blocking_pool(new base::SequencedWorkerPool(3, "WebBlocking")) { | 90 : blocking_pool( |
| 91 new base::SequencedWorkerPool(3, |
| 92 "WebBlocking", |
| 93 base::TaskPriority::USER_VISIBLE)) { |
| 91 memset(threads, 0, WebThread::ID_COUNT * sizeof(threads[0])); | 94 memset(threads, 0, WebThread::ID_COUNT * sizeof(threads[0])); |
| 92 memset(thread_delegates, 0, | 95 memset(thread_delegates, 0, |
| 93 WebThread::ID_COUNT * sizeof(thread_delegates[0])); | 96 WebThread::ID_COUNT * sizeof(thread_delegates[0])); |
| 94 } | 97 } |
| 95 | 98 |
| 96 // This lock protects |threads|. Do not read or modify that array | 99 // This lock protects |threads|. Do not read or modify that array |
| 97 // without holding this lock. Do not block while holding this lock. | 100 // without holding this lock. Do not block while holding this lock. |
| 98 base::Lock lock; | 101 base::Lock lock; |
| 99 | 102 |
| 100 // This array is protected by |lock|. The threads are not owned by this | 103 // This array is protected by |lock|. The threads are not owned by this |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 AtomicWord* storage = | 498 AtomicWord* storage = |
| 496 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); | 499 reinterpret_cast<AtomicWord*>(&globals.thread_delegates[identifier]); |
| 497 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 500 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
| 498 storage, reinterpret_cast<AtomicWord>(delegate)); | 501 storage, reinterpret_cast<AtomicWord>(delegate)); |
| 499 | 502 |
| 500 // This catches registration when previously registered. | 503 // This catches registration when previously registered. |
| 501 DCHECK(!delegate || !old_pointer); | 504 DCHECK(!delegate || !old_pointer); |
| 502 } | 505 } |
| 503 | 506 |
| 504 } // namespace web | 507 } // namespace web |
| OLD | NEW |