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

Side by Side Diff: remoting/protocol/stream_message_pipe_adapter.h

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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 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_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ 5 #ifndef REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_
6 #define REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ 6 #define REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "remoting/protocol/message_channel_factory.h" 9 #include "remoting/protocol/message_channel_factory.h"
10 #include "remoting/protocol/message_pipe.h" 10 #include "remoting/protocol/message_pipe.h"
11 #include "remoting/protocol/message_reader.h" 11 #include "remoting/protocol/message_reader.h"
12 12
13 namespace remoting { 13 namespace remoting {
14 class BufferedSocketWriter; 14 class BufferedSocketWriter;
15 15
16 namespace protocol { 16 namespace protocol {
17 17
18 class P2PStreamSocket; 18 class P2PStreamSocket;
19 class StreamChannelFactory; 19 class StreamChannelFactory;
20 20
21 // MessagePipe implementation that sends and receives messages over a 21 // MessagePipe implementation that sends and receives messages over a
22 // P2PStreamChannel. 22 // P2PStreamChannel.
23 class StreamMessagePipeAdapter : public MessagePipe { 23 class StreamMessagePipeAdapter : public MessagePipe {
24 public: 24 public:
25 typedef base::Callback<void(int)> ErrorCallback; 25 typedef base::Callback<void(int)> ErrorCallback;
26 26
27 StreamMessagePipeAdapter(scoped_ptr<P2PStreamSocket> socket, 27 StreamMessagePipeAdapter(std::unique_ptr<P2PStreamSocket> socket,
28 const ErrorCallback& error_callback); 28 const ErrorCallback& error_callback);
29 ~StreamMessagePipeAdapter() override; 29 ~StreamMessagePipeAdapter() override;
30 30
31 // MessagePipe interface. 31 // MessagePipe interface.
32 void StartReceiving(const MessageReceivedCallback& callback) override; 32 void StartReceiving(const MessageReceivedCallback& callback) override;
33 void Send(google::protobuf::MessageLite* message, 33 void Send(google::protobuf::MessageLite* message,
34 const base::Closure& done) override; 34 const base::Closure& done) override;
35 35
36 private: 36 private:
37 void CloseOnError(int error); 37 void CloseOnError(int error);
38 38
39 scoped_ptr<P2PStreamSocket> socket_; 39 std::unique_ptr<P2PStreamSocket> socket_;
40 ErrorCallback error_callback_; 40 ErrorCallback error_callback_;
41 41
42 MessageReader reader_; 42 MessageReader reader_;
43 scoped_ptr<BufferedSocketWriter> writer_; 43 std::unique_ptr<BufferedSocketWriter> writer_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(StreamMessagePipeAdapter); 45 DISALLOW_COPY_AND_ASSIGN(StreamMessagePipeAdapter);
46 }; 46 };
47 47
48 class StreamMessageChannelFactoryAdapter : public MessageChannelFactory { 48 class StreamMessageChannelFactoryAdapter : public MessageChannelFactory {
49 public: 49 public:
50 typedef base::Callback<void(int)> ErrorCallback; 50 typedef base::Callback<void(int)> ErrorCallback;
51 51
52 StreamMessageChannelFactoryAdapter( 52 StreamMessageChannelFactoryAdapter(
53 StreamChannelFactory* stream_channel_factory, 53 StreamChannelFactory* stream_channel_factory,
54 const ErrorCallback& error_callback); 54 const ErrorCallback& error_callback);
55 ~StreamMessageChannelFactoryAdapter() override; 55 ~StreamMessageChannelFactoryAdapter() override;
56 56
57 // MessageChannelFactory interface. 57 // MessageChannelFactory interface.
58 void CreateChannel(const std::string& name, 58 void CreateChannel(const std::string& name,
59 const ChannelCreatedCallback& callback) override; 59 const ChannelCreatedCallback& callback) override;
60 void CancelChannelCreation(const std::string& name) override; 60 void CancelChannelCreation(const std::string& name) override;
61 61
62 private: 62 private:
63 void OnChannelCreated(const ChannelCreatedCallback& callback, 63 void OnChannelCreated(const ChannelCreatedCallback& callback,
64 scoped_ptr<P2PStreamSocket> socket); 64 std::unique_ptr<P2PStreamSocket> socket);
65 65
66 StreamChannelFactory* stream_channel_factory_; 66 StreamChannelFactory* stream_channel_factory_;
67 ErrorCallback error_callback_; 67 ErrorCallback error_callback_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(StreamMessageChannelFactoryAdapter); 69 DISALLOW_COPY_AND_ASSIGN(StreamMessageChannelFactoryAdapter);
70 }; 70 };
71 71
72 } // namespace protocol 72 } // namespace protocol
73 } // namespace remoting 73 } // namespace remoting
74 74
75 #endif // REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_ 75 #endif // REMOTING_PROTOCOL_STREAM_MESSAGE_PIPE_ADAPTER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/stream_channel_factory.h ('k') | remoting/protocol/stream_message_pipe_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698