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

Side by Side Diff: remoting/host/native_messaging/pipe_messaging_channel.h

Issue 2911893003: Deprecate NonThreadSafe in remoting in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ 5 #ifndef REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_
6 #define REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ 6 #define REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/files/file.h" 11 #include "base/files/file.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/non_thread_safe.h" 15 #include "base/sequence_checker.h"
16 #include "extensions/browser/api/messaging/native_messaging_channel.h" 16 #include "extensions/browser/api/messaging/native_messaging_channel.h"
17 #include "remoting/host/native_messaging/native_messaging_reader.h" 17 #include "remoting/host/native_messaging/native_messaging_reader.h"
18 #include "remoting/host/native_messaging/native_messaging_writer.h" 18 #include "remoting/host/native_messaging/native_messaging_writer.h"
19 19
20 namespace base { 20 namespace base {
21 class Value; 21 class Value;
22 } // namespace base 22 } // namespace base
23 23
24 namespace remoting { 24 namespace remoting {
25 25
26 // An implementation of extensions::NativeMessagingChannel using a pipe. It 26 // An implementation of extensions::NativeMessagingChannel using a pipe. It
27 // is used by the It2MeNativeMessagingHost and Me2MeNativeMessagingHost to 27 // is used by the It2MeNativeMessagingHost and Me2MeNativeMessagingHost to
28 // communicate with the chrome process. 28 // communicate with the chrome process.
29 // TODO(kelvinp): Move this class to the extensions/browser/api/messaging 29 // TODO(kelvinp): Move this class to the extensions/browser/api/messaging
30 // directory. 30 // directory.
31 class PipeMessagingChannel : public extensions::NativeMessagingChannel, 31 class PipeMessagingChannel : public extensions::NativeMessagingChannel {
32 public base::NonThreadSafe {
33 public: 32 public:
34 typedef extensions::NativeMessagingChannel::EventHandler EventHandler; 33 typedef extensions::NativeMessagingChannel::EventHandler EventHandler;
35 34
36 // Constructs an object taking the ownership of |input| and |output|. Closes 35 // Constructs an object taking the ownership of |input| and |output|. Closes
37 // |input| and |output| to prevent the caller from using them. 36 // |input| and |output| to prevent the caller from using them.
38 PipeMessagingChannel(base::File input, base::File output); 37 PipeMessagingChannel(base::File input, base::File output);
39 ~PipeMessagingChannel() override; 38 ~PipeMessagingChannel() override;
40 39
41 // extensions::NativeMessagingChannel implementation. 40 // extensions::NativeMessagingChannel implementation.
42 void Start(EventHandler* event_handler) override; 41 void Start(EventHandler* event_handler) override;
43 void SendMessage(std::unique_ptr<base::Value> message) override; 42 void SendMessage(std::unique_ptr<base::Value> message) override;
44 43
45 private: 44 private:
46 // Processes a message received from the client app. 45 // Processes a message received from the client app.
47 void ProcessMessage(std::unique_ptr<base::Value> message); 46 void ProcessMessage(std::unique_ptr<base::Value> message);
48 47
49 // Initiates shutdown. 48 // Initiates shutdown.
50 void Shutdown(); 49 void Shutdown();
51 50
52 NativeMessagingReader native_messaging_reader_; 51 NativeMessagingReader native_messaging_reader_;
53 std::unique_ptr<NativeMessagingWriter> native_messaging_writer_; 52 std::unique_ptr<NativeMessagingWriter> native_messaging_writer_;
54 53
55 EventHandler* event_handler_; 54 EventHandler* event_handler_;
56 base::WeakPtr<PipeMessagingChannel> weak_ptr_; 55 base::WeakPtr<PipeMessagingChannel> weak_ptr_;
56
57 SEQUENCE_CHECKER(sequence_checker_);
58
57 base::WeakPtrFactory<PipeMessagingChannel> weak_factory_; 59 base::WeakPtrFactory<PipeMessagingChannel> weak_factory_;
58 60
59 DISALLOW_COPY_AND_ASSIGN(PipeMessagingChannel); 61 DISALLOW_COPY_AND_ASSIGN(PipeMessagingChannel);
60 }; 62 };
61 63
62 } // namespace remoting 64 } // namespace remoting
63 65
64 #endif // REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_ 66 #endif // REMOTING_HOST_NATIVE_MESSAGING_PIPE_MESSAGING_CHANNEL_H_
OLDNEW
« no previous file with comments | « remoting/host/local_input_monitor_x11.cc ('k') | remoting/host/native_messaging/pipe_messaging_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698