| 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 #ifndef REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_IMPL_H_ | 5 #ifndef REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_IMPL_H_ |
| 6 #define REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_IMPL_H_ | 6 #define REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/files/file.h" | 11 #include "base/files/file.h" |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 14 #include "remoting/host/security_key/remote_security_key_message_reader.h" | 15 #include "remoting/host/security_key/remote_security_key_message_reader.h" |
| 15 #include "remoting/host/security_key/security_key_message.h" | 16 #include "remoting/host/security_key/security_key_message.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 class SingleThreadTaskRunner; | 19 class SingleThreadTaskRunner; |
| 19 } // namespace base | 20 } // namespace base |
| 20 | 21 |
| 21 namespace remoting { | 22 namespace remoting { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 private: | 36 private: |
| 36 // Reads a message from the remote security key process and passes it to | 37 // Reads a message from the remote security key process and passes it to |
| 37 // |message_callback_| on the originating thread. Run on |read_task_runner_|. | 38 // |message_callback_| on the originating thread. Run on |read_task_runner_|. |
| 38 void ReadMessage(); | 39 void ReadMessage(); |
| 39 | 40 |
| 40 // Callback run on |read_task_runner_| when an error occurs or EOF is reached. | 41 // Callback run on |read_task_runner_| when an error occurs or EOF is reached. |
| 41 void NotifyError(); | 42 void NotifyError(); |
| 42 | 43 |
| 43 // Used for callbacks on the appropriate task runner to signal status changes. | 44 // Used for callbacks on the appropriate task runner to signal status changes. |
| 44 // These callbacks are invoked on |main_task_runner_|. | 45 // These callbacks are invoked on |main_task_runner_|. |
| 45 void InvokeMessageCallback(scoped_ptr<SecurityKeyMessage> message); | 46 void InvokeMessageCallback(std::unique_ptr<SecurityKeyMessage> message); |
| 46 void InvokeErrorCallback(); | 47 void InvokeErrorCallback(); |
| 47 | 48 |
| 48 base::File read_stream_; | 49 base::File read_stream_; |
| 49 | 50 |
| 50 // Caller-supplied message and error callbacks. | 51 // Caller-supplied message and error callbacks. |
| 51 SecurityKeyMessageCallback message_callback_; | 52 SecurityKeyMessageCallback message_callback_; |
| 52 base::Closure error_callback_; | 53 base::Closure error_callback_; |
| 53 | 54 |
| 54 // Thread used for blocking IO operations. | 55 // Thread used for blocking IO operations. |
| 55 base::Thread reader_thread_; | 56 base::Thread reader_thread_; |
| 56 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 57 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 57 scoped_refptr<base::SingleThreadTaskRunner> read_task_runner_; | 58 scoped_refptr<base::SingleThreadTaskRunner> read_task_runner_; |
| 58 | 59 |
| 59 base::WeakPtr<RemoteSecurityKeyMessageReaderImpl> reader_; | 60 base::WeakPtr<RemoteSecurityKeyMessageReaderImpl> reader_; |
| 60 base::WeakPtrFactory<RemoteSecurityKeyMessageReaderImpl> weak_factory_; | 61 base::WeakPtrFactory<RemoteSecurityKeyMessageReaderImpl> weak_factory_; |
| 61 | 62 |
| 62 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageReaderImpl); | 63 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageReaderImpl); |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 } // namespace remoting | 66 } // namespace remoting |
| 66 | 67 |
| 67 #endif // REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_IMPL_H_ | 68 #endif // REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_IMPL_H_ |
| OLD | NEW |