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

Side by Side Diff: remoting/protocol/channel_multiplexer.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
« no previous file with comments | « remoting/protocol/channel_dispatcher_base.cc ('k') | remoting/protocol/channel_multiplexer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CHANNEL_MULTIPLEXER_H_ 5 #ifndef REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_
6 #define REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_ 6 #define REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "remoting/base/buffered_socket_writer.h" 10 #include "remoting/base/buffered_socket_writer.h"
(...skipping 18 matching lines...) Expand all
29 const ChannelCreatedCallback& callback) override; 29 const ChannelCreatedCallback& callback) override;
30 void CancelChannelCreation(const std::string& name) override; 30 void CancelChannelCreation(const std::string& name) override;
31 31
32 private: 32 private:
33 struct PendingChannel; 33 struct PendingChannel;
34 class MuxChannel; 34 class MuxChannel;
35 class MuxSocket; 35 class MuxSocket;
36 friend class MuxChannel; 36 friend class MuxChannel;
37 37
38 // Callback for |base_channel_| creation. 38 // Callback for |base_channel_| creation.
39 void OnBaseChannelReady(scoped_ptr<P2PStreamSocket> socket); 39 void OnBaseChannelReady(std::unique_ptr<P2PStreamSocket> socket);
40 40
41 // Helper to create channels asynchronously. 41 // Helper to create channels asynchronously.
42 void DoCreatePendingChannels(); 42 void DoCreatePendingChannels();
43 43
44 // Helper method used to create channels. 44 // Helper method used to create channels.
45 MuxChannel* GetOrCreateChannel(const std::string& name); 45 MuxChannel* GetOrCreateChannel(const std::string& name);
46 46
47 // Error handling callback for |reader_| and |writer_|. 47 // Error handling callback for |reader_| and |writer_|.
48 void OnBaseChannelError(int error); 48 void OnBaseChannelError(int error);
49 49
50 // Propagates base channel error to channel |name|, queued asynchronously by 50 // Propagates base channel error to channel |name|, queued asynchronously by
51 // OnBaseChannelError(). 51 // OnBaseChannelError().
52 void NotifyBaseChannelError(const std::string& name, int error); 52 void NotifyBaseChannelError(const std::string& name, int error);
53 53
54 // Callback for |reader_; 54 // Callback for |reader_;
55 void OnIncomingPacket(scoped_ptr<CompoundBuffer> buffer); 55 void OnIncomingPacket(std::unique_ptr<CompoundBuffer> buffer);
56 56
57 // Called by MuxChannel. 57 // Called by MuxChannel.
58 void DoWrite(scoped_ptr<MultiplexPacket> packet, 58 void DoWrite(std::unique_ptr<MultiplexPacket> packet,
59 const base::Closure& done_task); 59 const base::Closure& done_task);
60 60
61 // Factory used to create |base_channel_|. Set to nullptr once creation is 61 // Factory used to create |base_channel_|. Set to nullptr once creation is
62 // finished or failed. 62 // finished or failed.
63 StreamChannelFactory* base_channel_factory_; 63 StreamChannelFactory* base_channel_factory_;
64 64
65 // Name of the underlying channel. 65 // Name of the underlying channel.
66 std::string base_channel_name_; 66 std::string base_channel_name_;
67 67
68 // The channel over which to multiplex. 68 // The channel over which to multiplex.
69 scoped_ptr<P2PStreamSocket> base_channel_; 69 std::unique_ptr<P2PStreamSocket> base_channel_;
70 70
71 // List of requested channels while we are waiting for |base_channel_|. 71 // List of requested channels while we are waiting for |base_channel_|.
72 std::list<PendingChannel> pending_channels_; 72 std::list<PendingChannel> pending_channels_;
73 73
74 int next_channel_id_; 74 int next_channel_id_;
75 std::map<std::string, MuxChannel*> channels_; 75 std::map<std::string, MuxChannel*> channels_;
76 76
77 // Channels are added to |channels_by_receive_id_| only after we receive 77 // Channels are added to |channels_by_receive_id_| only after we receive
78 // receive_id from the remote peer. 78 // receive_id from the remote peer.
79 std::map<int, MuxChannel*> channels_by_receive_id_; 79 std::map<int, MuxChannel*> channels_by_receive_id_;
80 80
81 BufferedSocketWriter writer_; 81 BufferedSocketWriter writer_;
82 MessageReader reader_; 82 MessageReader reader_;
83 83
84 base::WeakPtrFactory<ChannelMultiplexer> weak_factory_; 84 base::WeakPtrFactory<ChannelMultiplexer> weak_factory_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(ChannelMultiplexer); 86 DISALLOW_COPY_AND_ASSIGN(ChannelMultiplexer);
87 }; 87 };
88 88
89 } // namespace protocol 89 } // namespace protocol
90 } // namespace remoting 90 } // namespace remoting
91 91
92 92
93 #endif // REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_ 93 #endif // REMOTING_PROTOCOL_CHANNEL_MULTIPLEXER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/channel_dispatcher_base.cc ('k') | remoting/protocol/channel_multiplexer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698