Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: remoting/host/security_key/remote_security_key_message_reader.h

Issue 1818233005: Adding the message reading class used for remote_security_key STDIN communication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@writer
Patch Set: Integrating security message changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_H_
6 #define REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_H_
7
8 #include <stdint.h>
Sergey Ulanov 2016/03/28 18:52:46 don't need this include
joedow 2016/03/30 19:39:00 Done.
9
10 #include "base/callback.h"
11 #include "base/files/file.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread.h"
16 #include "remoting/host/security_key/security_key_message.h"
17
18 namespace base {
19 class SequencedTaskRunner;
20 } // namespace base
21
22 namespace remoting {
23
24 // Used for receiving remote security key messages using a file handle.
25 class RemoteSecurityKeyMessageReader {
26 public:
27 explicit RemoteSecurityKeyMessageReader(base::File input_file);
28 ~RemoteSecurityKeyMessageReader();
29
30 // Starts reading messages from the input file provided in the C'Tor.
31 // |message_callback| is called for each received message.
32 // |error_callback| is called in case of an error or the file is closed.
33 // This method is asynchronous, callbacks will be called on the thread this
34 // method is called on. These callbacks can be called up to the point this
35 // instance is destroyed and may be destroyed as a result of the callback
36 // being invoked.
37 void Start(SecurityKeyMessage::Callback message_callback,
38 base::Closure error_callback);
39
40 private:
41 class Core;
42 friend class Core;
43
44 // Used by the |core_| class to post callbacks on the appropriate task runner.
45 void InvokeMessageCallback(scoped_ptr<SecurityKeyMessage> message);
46 void InvokeErrorCallback();
47
48 // Used to execute blocking IO operations.
49 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.
50
51 // Caller-supplied message and error callbacks.
52 SecurityKeyMessage::Callback message_callback_;
53 base::Closure error_callback_;
54
55 // Thread used for blocking IO operations.
56 base::Thread reader_thread_;
57 scoped_refptr<base::SequencedTaskRunner> read_task_runner_;
58
59 base::WeakPtrFactory<RemoteSecurityKeyMessageReader> weak_factory_;
60
61 DISALLOW_COPY_AND_ASSIGN(RemoteSecurityKeyMessageReader);
62 };
63
64 } // namespace remoting
65
66 #endif // REMOTING_HOST_SECURITY_KEY_REMOTE_SECURITY_KEY_MESSAGE_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698