| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/host/security_key/remote_security_key_message_reader_impl.h" | 5 #include "remoting/host/security_key/remote_security_key_message_reader_impl.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 options.message_loop_type = base::MessageLoop::TYPE_IO; | 27 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 28 reader_thread_.StartWithOptions(options); | 28 reader_thread_.StartWithOptions(options); |
| 29 | 29 |
| 30 read_task_runner_ = reader_thread_.task_runner(); | 30 read_task_runner_ = reader_thread_.task_runner(); |
| 31 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 31 main_task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 RemoteSecurityKeyMessageReaderImpl::~RemoteSecurityKeyMessageReaderImpl() { | 34 RemoteSecurityKeyMessageReaderImpl::~RemoteSecurityKeyMessageReaderImpl() { |
| 35 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); | 35 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); |
| 36 | 36 |
| 37 // In order to ensure the reader thread is stopped cleanly, we close the | 37 // In order to ensure the reader thread is stopped cleanly, we want to stop |
| 38 // stream it is blocking on and then wait for the thread to exit. | 38 // the thread before the task runners and weak pointers are invalidated. |
| 39 read_stream_.Close(); | |
| 40 reader_thread_.Stop(); | 39 reader_thread_.Stop(); |
| 41 } | 40 } |
| 42 | 41 |
| 43 void RemoteSecurityKeyMessageReaderImpl::Start( | 42 void RemoteSecurityKeyMessageReaderImpl::Start( |
| 44 const SecurityKeyMessageCallback& message_callback, | 43 const SecurityKeyMessageCallback& message_callback, |
| 45 const base::Closure& error_callback) { | 44 const base::Closure& error_callback) { |
| 46 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); | 45 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); |
| 47 | 46 |
| 48 message_callback_ = message_callback; | 47 message_callback_ = message_callback; |
| 49 error_callback_ = error_callback; | 48 error_callback_ = error_callback; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); | 124 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); |
| 126 message_callback_.Run(std::move(message)); | 125 message_callback_.Run(std::move(message)); |
| 127 } | 126 } |
| 128 | 127 |
| 129 void RemoteSecurityKeyMessageReaderImpl::InvokeErrorCallback() { | 128 void RemoteSecurityKeyMessageReaderImpl::InvokeErrorCallback() { |
| 130 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); | 129 DCHECK(main_task_runner_->RunsTasksOnCurrentThread()); |
| 131 error_callback_.Run(); | 130 error_callback_.Run(); |
| 132 } | 131 } |
| 133 | 132 |
| 134 } // namespace remoting | 133 } // namespace remoting |
| OLD | NEW |