| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/public/cpp/system/simple_watcher.h" | 5 #include "mojo/public/cpp/system/simple_watcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // TODO(rockot): This shouldn't really be necessary, but there are already | 88 // TODO(rockot): This shouldn't really be necessary, but there are already |
| 89 // instances today where bindings object may be bound and subsequently | 89 // instances today where bindings object may be bound and subsequently |
| 90 // closed due to pipe error, all before the thread's TaskRunner has been | 90 // closed due to pipe error, all before the thread's TaskRunner has been |
| 91 // properly initialized. | 91 // properly initialized. |
| 92 base::AutoLock lock(lock_); | 92 base::AutoLock lock(lock_); |
| 93 if (!enable_cancellation_notifications_) | 93 if (!enable_cancellation_notifications_) |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 | 96 |
| 97 if ((flags & MOJO_WATCHER_NOTIFICATION_FLAG_FROM_SYSTEM) && | 97 if ((flags & MOJO_WATCHER_NOTIFICATION_FLAG_FROM_SYSTEM) && |
| 98 task_runner_->RunsTasksOnCurrentThread() && weak_watcher_ && | 98 task_runner_->RunsTasksInCurrentSequence() && weak_watcher_ && |
| 99 weak_watcher_->is_default_task_runner_) { | 99 weak_watcher_->is_default_task_runner_) { |
| 100 // System notifications will trigger from the task runner passed to | 100 // System notifications will trigger from the task runner passed to |
| 101 // mojo::edk::InitIPCSupport(). In Chrome this happens to always be the | 101 // mojo::edk::InitIPCSupport(). In Chrome this happens to always be the |
| 102 // default task runner for the IO thread. | 102 // default task runner for the IO thread. |
| 103 weak_watcher_->OnHandleReady(watch_id_, result); | 103 weak_watcher_->OnHandleReady(watch_id_, result); |
| 104 } else { | 104 } else { |
| 105 task_runner_->PostTask( | 105 task_runner_->PostTask( |
| 106 FROM_HERE, base::Bind(&SimpleWatcher::OnHandleReady, weak_watcher_, | 106 FROM_HERE, base::Bind(&SimpleWatcher::OnHandleReady, weak_watcher_, |
| 107 watch_id_, result)); | 107 watch_id_, result)); |
| 108 } | 108 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // at most once in AUTOMATIC arming mode. | 270 // at most once in AUTOMATIC arming mode. |
| 271 if (result == MOJO_RESULT_FAILED_PRECONDITION) | 271 if (result == MOJO_RESULT_FAILED_PRECONDITION) |
| 272 unsatisfiable_ = true; | 272 unsatisfiable_ = true; |
| 273 | 273 |
| 274 if (arming_policy_ == ArmingPolicy::AUTOMATIC && IsWatching()) | 274 if (arming_policy_ == ArmingPolicy::AUTOMATIC && IsWatching()) |
| 275 ArmOrNotify(); | 275 ArmOrNotify(); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace mojo | 279 } // namespace mojo |
| OLD | NEW |