Chromium Code Reviews| Index: remoting/host/security_key/remote_security_key_message_reader.h |
| diff --git a/remoting/host/security_key/remote_security_key_message_reader.h b/remoting/host/security_key/remote_security_key_message_reader.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8383ce2065cc684a427f7a8187568c9f8f13b344 |
| --- /dev/null |
| +++ b/remoting/host/security_key/remote_security_key_message_reader.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_H_ |
| +#define REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_H_ |
| + |
| +#include <stdint.h> |
|
Sergey Ulanov
2016/03/28 18:52:46
don't need this include
joedow
2016/03/30 19:39:00
Done.
|
| + |
| +#include "base/callback.h" |
| +#include "base/files/file.h" |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/threading/thread.h" |
| +#include "remoting/host/security_key/security_key_message.h" |
| + |
| +namespace base { |
| +class SequencedTaskRunner; |
| +} // namespace base |
| + |
| +namespace remoting { |
| + |
| +// Used for receiving remote security key messages using a file handle. |
| +class RemoteSecurityKeyMessageReader { |
| + public: |
| + explicit RemoteSecurityKeyMessageReader(base::File input_file); |
| + ~RemoteSecurityKeyMessageReader(); |
| + |
| + // Starts reading messages from the input file provided in the C'Tor. |
| + // |message_callback| is called for each received message. |
| + // |error_callback| is called in case of an error or the file is closed. |
| + // This method is asynchronous, callbacks will be called on the thread this |
| + // method is called on. These callbacks can be called up to the point this |
| + // instance is destroyed and may be destroyed as a result of the callback |
| + // being invoked. |
| + void Start(SecurityKeyMessage::Callback message_callback, |
| + base::Closure error_callback); |
| + |
| + private: |
| + class Core; |
| + friend class Core; |
| + |
| + // Used by the |core_| class to post callbacks on the appropriate task runner. |
| + void InvokeMessageCallback(scoped_ptr<SecurityKeyMessage> message); |
| + void InvokeErrorCallback(); |
| + |
| + // Used to execute blocking IO operations. |
| + scoped_ptr<Core> core_; |
|
Sergey Ulanov
2016/03/28 18:52:46
This class owns the target thread, so you don't re
joedow
2016/03/30 19:39:00
Done.
|
| + |
| + // Caller-supplied message and error callbacks. |
| + SecurityKeyMessage::Callback message_callback_; |
| + base::Closure error_callback_; |
| + |
| + // Thread used for blocking IO operations. |
| + base::Thread reader_thread_; |
| + scoped_refptr<base::SequencedTaskRunner> read_task_runner_; |
| + |
| + base::WeakPtrFactory<RemoteSecurityKeyMessageReader> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageReader); |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_H_ |