| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ipc/mojo/async_handle_waiter.h" | 5 #include "ipc/mojo/async_handle_waiter.h" |
| 6 | 6 |
| 7 #include "base/atomic_ref_count.h" | 7 #include "base/atomic_ref_count.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 |
| 13 #if defined(USE_CHROME_EDK) |
| 14 #include "mojo/edk/embedder/embedder.h" |
| 15 #else |
| 12 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 16 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 17 #endif |
| 13 | 18 |
| 14 namespace IPC { | 19 namespace IPC { |
| 15 namespace internal { | 20 namespace internal { |
| 16 | 21 |
| 17 class AsyncHandleWaiterContextTraits { | 22 class AsyncHandleWaiterContextTraits { |
| 18 public: | 23 public: |
| 19 static void Destruct(const AsyncHandleWaiter::Context* context); | 24 static void Destruct(const AsyncHandleWaiter::Context* context); |
| 20 }; | 25 }; |
| 21 | 26 |
| 22 // The thread-safe part of |AsyncHandleWaiter|. | 27 // The thread-safe part of |AsyncHandleWaiter|. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 84 |
| 80 // IOObserver implementation: | 85 // IOObserver implementation: |
| 81 | 86 |
| 82 void WillProcessIOEvent() override { | 87 void WillProcessIOEvent() override { |
| 83 DCHECK(io_loop_level_ != 0 || !should_invoke_callback_); | 88 DCHECK(io_loop_level_ != 0 || !should_invoke_callback_); |
| 84 DCHECK_GE(io_loop_level_, 0); | 89 DCHECK_GE(io_loop_level_, 0); |
| 85 io_loop_level_++; | 90 io_loop_level_++; |
| 86 } | 91 } |
| 87 | 92 |
| 88 void DidProcessIOEvent() override { | 93 void DidProcessIOEvent() override { |
| 94 // This object could have been constructed in another's class's |
| 95 // DidProcessIOEvent. |
| 96 if (io_loop_level_== 0) |
| 97 return; |
| 98 |
| 89 DCHECK_GE(io_loop_level_, 1); | 99 DCHECK_GE(io_loop_level_, 1); |
| 90 | 100 |
| 91 // Leaving a nested loop. | 101 // Leaving a nested loop. |
| 92 if (io_loop_level_ > 1) { | 102 if (io_loop_level_ > 1) { |
| 93 io_loop_level_--; | 103 io_loop_level_--; |
| 94 return; | 104 return; |
| 95 } | 105 } |
| 96 | 106 |
| 97 // The zero |waiter_| indicates that |this| have lost the owner and can be | 107 // The zero |waiter_| indicates that |this| have lost the owner and can be |
| 98 // under destruction. So we cannot wrap it with a |scoped_refptr| anymore. | 108 // under destruction. So we cannot wrap it with a |scoped_refptr| anymore. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 void AsyncHandleWaiterContextTraits::Destruct( | 166 void AsyncHandleWaiterContextTraits::Destruct( |
| 157 const AsyncHandleWaiter::Context* context) { | 167 const AsyncHandleWaiter::Context* context) { |
| 158 context->io_runner_->PostTask( | 168 context->io_runner_->PostTask( |
| 159 FROM_HERE, | 169 FROM_HERE, |
| 160 base::Bind(&base::DeletePointer<const AsyncHandleWaiter::Context>, | 170 base::Bind(&base::DeletePointer<const AsyncHandleWaiter::Context>, |
| 161 base::Unretained(context))); | 171 base::Unretained(context))); |
| 162 } | 172 } |
| 163 | 173 |
| 164 } // namespace internal | 174 } // namespace internal |
| 165 } // namespace IPC | 175 } // namespace IPC |
| OLD | NEW |