OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/common/one_shot_event.h" | 5 #include "extensions/common/one_shot_event.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/task_runner.h" | 10 #include "base/task_runner.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 tracked_objects::Location from_here; | 24 tracked_objects::Location from_here; |
25 scoped_refptr<TaskRunner> runner; | 25 scoped_refptr<TaskRunner> runner; |
26 base::Closure task; | 26 base::Closure task; |
27 }; | 27 }; |
28 | 28 |
29 OneShotEvent::OneShotEvent() : signaled_(false) { | 29 OneShotEvent::OneShotEvent() : signaled_(false) { |
30 // It's acceptable to construct the OneShotEvent on one thread, but | 30 // It's acceptable to construct the OneShotEvent on one thread, but |
31 // immediately move it to another thread. | 31 // immediately move it to another thread. |
32 thread_checker_.DetachFromThread(); | 32 thread_checker_.DetachFromThread(); |
33 } | 33 } |
| 34 OneShotEvent::OneShotEvent(bool signaled) : signaled_(signaled) { |
| 35 thread_checker_.DetachFromThread(); |
| 36 } |
34 OneShotEvent::~OneShotEvent() {} | 37 OneShotEvent::~OneShotEvent() {} |
35 | 38 |
36 void OneShotEvent::Post(const tracked_objects::Location& from_here, | 39 void OneShotEvent::Post(const tracked_objects::Location& from_here, |
37 const base::Closure& task) const { | 40 const base::Closure& task) const { |
38 Post(from_here, task, base::MessageLoopProxy::current()); | 41 Post(from_here, task, base::MessageLoopProxy::current()); |
39 } | 42 } |
40 | 43 |
41 void OneShotEvent::Post(const tracked_objects::Location& from_here, | 44 void OneShotEvent::Post(const tracked_objects::Location& from_here, |
42 const base::Closure& task, | 45 const base::Closure& task, |
43 const scoped_refptr<TaskRunner>& runner) const { | 46 const scoped_refptr<TaskRunner>& runner) const { |
(...skipping 17 matching lines...) Expand all Loading... |
61 // single-threaded prevents that from being relevant. | 64 // single-threaded prevents that from being relevant. |
62 | 65 |
63 // We could randomize tasks_ in debug mode in order to check that | 66 // We could randomize tasks_ in debug mode in order to check that |
64 // the order doesn't matter... | 67 // the order doesn't matter... |
65 for (size_t i = 0; i < tasks_.size(); ++i) { | 68 for (size_t i = 0; i < tasks_.size(); ++i) { |
66 tasks_[i].runner->PostTask(tasks_[i].from_here, tasks_[i].task); | 69 tasks_[i].runner->PostTask(tasks_[i].from_here, tasks_[i].task); |
67 } | 70 } |
68 } | 71 } |
69 | 72 |
70 } // namespace extensions | 73 } // namespace extensions |
OLD | NEW |