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

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

Issue 2170563002: Revert of Renaming Gnubby and RemoteSecurityKey files/classes/members (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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_SECURITY_KEY_MESSAGE_READER_IMPL_H_
6 #define REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_MESSAGE_READER_IMPL_H_
7
8 #include <memory>
9
10 #include "base/callback.h"
11 #include "base/files/file.h"
12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread.h"
15 #include "remoting/host/security_key/security_key_message.h"
16 #include "remoting/host/security_key/security_key_message_reader.h"
17
18 namespace base {
19 class SingleThreadTaskRunner;
20 } // namespace base
21
22 namespace remoting {
23
24 // SecurityKeyMessageReader implementation that receives messages from
25 // a pipe.
26 class SecurityKeyMessageReaderImpl : public SecurityKeyMessageReader {
27 public:
28 explicit SecurityKeyMessageReaderImpl(base::File input_file);
29 ~SecurityKeyMessageReaderImpl() override;
30
31 // SecurityKeyMessageReader interface.
32 void Start(const SecurityKeyMessageCallback& message_callback,
33 const base::Closure& error_callback) override;
34
35 private:
36 // 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 void ReadMessage();
39
40 // Reads the nubmer of bytes indicated by |bytes_to_read| into |buffer| from
41 // |read_stream_|. Returns true if all bytes were retrieved successfully.
42 bool ReadFromStream(char* buffer, size_t bytes_to_read);
43
44 // Callback run on |read_task_runner_| when an error occurs or EOF is reached.
45 void NotifyError();
46
47 // Used for callbacks on the appropriate task runner to signal status changes.
48 // These callbacks are invoked on |main_task_runner_|.
49 void InvokeMessageCallback(std::unique_ptr<SecurityKeyMessage> message);
50 void InvokeErrorCallback();
51
52 base::File read_stream_;
53
54 // Caller-supplied message and error callbacks.
55 SecurityKeyMessageCallback message_callback_;
56 base::Closure error_callback_;
57
58 // Thread used for blocking IO operations.
59 base::Thread reader_thread_;
60 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
61 scoped_refptr<base::SingleThreadTaskRunner> read_task_runner_;
62
63 base::WeakPtr<SecurityKeyMessageReaderImpl> reader_;
64 base::WeakPtrFactory<SecurityKeyMessageReaderImpl> weak_factory_;
65
66 DISALLOW_COPY_AND_ASSIGN(SecurityKeyMessageReaderImpl);
67 };
68
69 } // namespace remoting
70
71 #endif // REMOTING_HOST_SECURITY_KEY_SECURITY_KEY_MESSAGE_READER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698