| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 scoped_refptr<base::SequencedTaskRunner> runner) | 125 scoped_refptr<base::SequencedTaskRunner> runner) |
| 126 : arming_policy_(arming_policy), | 126 : arming_policy_(arming_policy), |
| 127 task_runner_(std::move(runner)), | 127 task_runner_(std::move(runner)), |
| 128 is_default_task_runner_(base::ThreadTaskRunnerHandle::IsSet() && | 128 is_default_task_runner_(base::ThreadTaskRunnerHandle::IsSet() && |
| 129 task_runner_ == | 129 task_runner_ == |
| 130 base::ThreadTaskRunnerHandle::Get()), | 130 base::ThreadTaskRunnerHandle::Get()), |
| 131 heap_profiler_tag_(from_here.file_name()), | 131 heap_profiler_tag_(from_here.file_name()), |
| 132 weak_factory_(this) { | 132 weak_factory_(this) { |
| 133 MojoResult rv = CreateWatcher(&Context::CallNotify, &watcher_handle_); | 133 MojoResult rv = CreateWatcher(&Context::CallNotify, &watcher_handle_); |
| 134 DCHECK_EQ(MOJO_RESULT_OK, rv); | 134 DCHECK_EQ(MOJO_RESULT_OK, rv); |
| 135 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 135 DCHECK(task_runner_->RunsTasksInCurrentSequence()); |
| 136 } | 136 } |
| 137 | 137 |
| 138 SimpleWatcher::~SimpleWatcher() { | 138 SimpleWatcher::~SimpleWatcher() { |
| 139 if (IsWatching()) | 139 if (IsWatching()) |
| 140 Cancel(); | 140 Cancel(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool SimpleWatcher::IsWatching() const { | 143 bool SimpleWatcher::IsWatching() const { |
| 144 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 144 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 145 return context_ != nullptr; | 145 return context_ != nullptr; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // at most once in AUTOMATIC arming mode. | 274 // at most once in AUTOMATIC arming mode. |
| 275 if (result == MOJO_RESULT_FAILED_PRECONDITION) | 275 if (result == MOJO_RESULT_FAILED_PRECONDITION) |
| 276 unsatisfiable_ = true; | 276 unsatisfiable_ = true; |
| 277 | 277 |
| 278 if (arming_policy_ == ArmingPolicy::AUTOMATIC && IsWatching()) | 278 if (arming_policy_ == ArmingPolicy::AUTOMATIC && IsWatching()) |
| 279 ArmOrNotify(); | 279 ArmOrNotify(); |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace mojo | 283 } // namespace mojo |
| OLD | NEW |