OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/browser_thread_impl.h" | 5 #include "content/browser/browser_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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // An implementation of MessageLoopProxy to be used in conjunction | 39 // An implementation of MessageLoopProxy to be used in conjunction |
40 // with BrowserThread. | 40 // with BrowserThread. |
41 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { | 41 class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy { |
42 public: | 42 public: |
43 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) | 43 explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier) |
44 : id_(identifier) { | 44 : id_(identifier) { |
45 } | 45 } |
46 | 46 |
47 // MessageLoopProxy implementation. | 47 // MessageLoopProxy implementation. |
48 virtual bool PostDelayedTask( | 48 bool PostDelayedTask(const tracked_objects::Location& from_here, |
49 const tracked_objects::Location& from_here, | 49 const base::Closure& task, |
50 const base::Closure& task, base::TimeDelta delay) override { | 50 base::TimeDelta delay) override { |
51 return BrowserThread::PostDelayedTask(id_, from_here, task, delay); | 51 return BrowserThread::PostDelayedTask(id_, from_here, task, delay); |
52 } | 52 } |
53 | 53 |
54 virtual bool PostNonNestableDelayedTask( | 54 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, |
55 const tracked_objects::Location& from_here, | 55 const base::Closure& task, |
56 const base::Closure& task, | 56 base::TimeDelta delay) override { |
57 base::TimeDelta delay) override { | |
58 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, | 57 return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task, |
59 delay); | 58 delay); |
60 } | 59 } |
61 | 60 |
62 virtual bool RunsTasksOnCurrentThread() const override { | 61 bool RunsTasksOnCurrentThread() const override { |
63 return BrowserThread::CurrentlyOn(id_); | 62 return BrowserThread::CurrentlyOn(id_); |
64 } | 63 } |
65 | 64 |
66 protected: | 65 protected: |
67 virtual ~BrowserThreadMessageLoopProxy() {} | 66 ~BrowserThreadMessageLoopProxy() override {} |
68 | 67 |
69 private: | 68 private: |
70 BrowserThread::ID id_; | 69 BrowserThread::ID id_; |
71 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); | 70 DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy); |
72 }; | 71 }; |
73 | 72 |
74 // A separate helper is used just for the proxies, in order to avoid needing | 73 // A separate helper is used just for the proxies, in order to avoid needing |
75 // to initialize the globals to create a proxy. | 74 // to initialize the globals to create a proxy. |
76 struct BrowserThreadProxies { | 75 struct BrowserThreadProxies { |
77 BrowserThreadProxies() { | 76 BrowserThreadProxies() { |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 AtomicWord* storage = reinterpret_cast<AtomicWord*>( | 531 AtomicWord* storage = reinterpret_cast<AtomicWord*>( |
533 &globals.thread_delegates[identifier]); | 532 &globals.thread_delegates[identifier]); |
534 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( | 533 AtomicWord old_pointer = base::subtle::NoBarrier_AtomicExchange( |
535 storage, reinterpret_cast<AtomicWord>(delegate)); | 534 storage, reinterpret_cast<AtomicWord>(delegate)); |
536 | 535 |
537 // This catches registration when previously registered. | 536 // This catches registration when previously registered. |
538 DCHECK(!delegate || !old_pointer); | 537 DCHECK(!delegate || !old_pointer); |
539 } | 538 } |
540 | 539 |
541 } // namespace content | 540 } // namespace content |
OLD | NEW |