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 <unistd.h> | 5 #include <unistd.h> |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 // Copy and assign allowed. | 59 // Copy and assign allowed. |
60 }; | 60 }; |
61 | 61 |
62 Blocker() : event_(true, false) {} | 62 Blocker() : event_(true, false) {} |
63 ~Blocker() {} | 63 ~Blocker() {} |
64 | 64 |
65 void Block() { | 65 void Block() { |
66 DCHECK(run_after_.is_null()); | 66 DCHECK(run_after_.is_null()); |
67 event_.Wait(); | 67 event_.Wait(); |
68 run_after_.Run(); | 68 if (!run_after_.is_null()) |
| 69 run_after_.Run(); |
69 } | 70 } |
70 | 71 |
71 Unblocker GetUnblocker() { return Unblocker(this); } | 72 Unblocker GetUnblocker() { return Unblocker(this); } |
72 | 73 |
73 private: | 74 private: |
74 base::WaitableEvent event_; | 75 base::WaitableEvent event_; |
75 base::Closure run_after_; | 76 base::Closure run_after_; |
76 | 77 |
77 DISALLOW_COPY_AND_ASSIGN(Blocker); | 78 DISALLOW_COPY_AND_ASSIGN(Blocker); |
78 }; | 79 }; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 base::Bind(&shell::ChildControllerImpl::Init, | 305 base::Bind(&shell::ChildControllerImpl::Init, |
305 base::Unretained(&app_context), | 306 base::Unretained(&app_context), |
306 base::Passed(&platform_channel), blocker.GetUnblocker())); | 307 base::Passed(&platform_channel), blocker.GetUnblocker())); |
307 // This will block, then run whatever the controller wants. | 308 // This will block, then run whatever the controller wants. |
308 blocker.Block(); | 309 blocker.Block(); |
309 | 310 |
310 app_context.Shutdown(); | 311 app_context.Shutdown(); |
311 | 312 |
312 return 0; | 313 return 0; |
313 } | 314 } |
OLD | NEW |