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 "mojo/runner/child_process.h" | 5 #include "mojo/runner/child_process.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 // Copy and assign allowed. | 60 // Copy and assign allowed. |
61 }; | 61 }; |
62 | 62 |
63 Blocker() : event_(true, false) {} | 63 Blocker() : event_(true, false) {} |
64 ~Blocker() {} | 64 ~Blocker() {} |
65 | 65 |
66 void Block() { | 66 void Block() { |
67 DCHECK(run_after_.is_null()); | 67 DCHECK(run_after_.is_null()); |
68 event_.Wait(); | 68 event_.Wait(); |
69 run_after_.Run(); | 69 if (!run_after_.is_null()) |
| 70 run_after_.Run(); |
70 } | 71 } |
71 | 72 |
72 Unblocker GetUnblocker() { return Unblocker(this); } | 73 Unblocker GetUnblocker() { return Unblocker(this); } |
73 | 74 |
74 private: | 75 private: |
75 base::WaitableEvent event_; | 76 base::WaitableEvent event_; |
76 base::Closure run_after_; | 77 base::Closure run_after_; |
77 | 78 |
78 DISALLOW_COPY_AND_ASSIGN(Blocker); | 79 DISALLOW_COPY_AND_ASSIGN(Blocker); |
79 }; | 80 }; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // This will block, then run whatever the controller wants. | 299 // This will block, then run whatever the controller wants. |
299 blocker.Block(); | 300 blocker.Block(); |
300 | 301 |
301 app_context.Shutdown(); | 302 app_context.Shutdown(); |
302 | 303 |
303 return 0; | 304 return 0; |
304 } | 305 } |
305 | 306 |
306 } // namespace runner | 307 } // namespace runner |
307 } // namespace mojo | 308 } // namespace mojo |
OLD | NEW |