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

Side by Side Diff: components/cast_channel/cast_socket.h

Issue 2974523002: [cast_channel] Make CastSocketService a global leaky singleton (Closed)
Patch Set: Created 3 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
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 COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_ 5 #ifndef COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_
6 #define COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_ 6 #define COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // event of an error. 122 // event of an error.
123 // Setting the error state does not close the socket if it is open. 123 // Setting the error state does not close the socket if it is open.
124 virtual void SetErrorState(ChannelError error_state) = 0; 124 virtual void SetErrorState(ChannelError error_state) = 0;
125 125
126 // Returns a pointer to the socket's message transport layer. Can be used to 126 // Returns a pointer to the socket's message transport layer. Can be used to
127 // send and receive CastMessages over the socket. 127 // send and receive CastMessages over the socket.
128 virtual CastTransport* transport() const = 0; 128 virtual CastTransport* transport() const = 0;
129 129
130 // Registers |observer| with the socket to receive messages and error events. 130 // Registers |observer| with the socket to receive messages and error events.
131 virtual void AddObserver(Observer* observer) = 0; 131 virtual void AddObserver(Observer* observer) = 0;
132
133 // Unregisters |observer|
mark a. foltz 2017/07/10 20:43:05 Nit: Add period at end.
zhaobin 2017/07/12 21:58:08 Done.
134 virtual void RemoveObserver(Observer* observer) = 0;
132 }; 135 };
133 136
134 // This class implements a channel between Chrome and a Cast device using a TCP 137 // This class implements a channel between Chrome and a Cast device using a TCP
135 // socket with SSL. The channel may authenticate that the receiver is a genuine 138 // socket with SSL. The channel may authenticate that the receiver is a genuine
136 // Cast device. All CastSocketImpl objects must be used only on the IO thread. 139 // Cast device. All CastSocketImpl objects must be used only on the IO thread.
137 // 140 //
138 // NOTE: Not called "CastChannel" to reduce confusion with the generated API 141 // NOTE: Not called "CastChannel" to reduce confusion with the generated API
139 // code. 142 // code.
140 class CastSocketImpl : public CastSocket { 143 class CastSocketImpl : public CastSocket {
141 public: 144 public:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 CastTransport* transport() const override; 177 CastTransport* transport() const override;
175 void Close(const net::CompletionCallback& callback) override; 178 void Close(const net::CompletionCallback& callback) override;
176 const net::IPEndPoint& ip_endpoint() const override; 179 const net::IPEndPoint& ip_endpoint() const override;
177 int id() const override; 180 int id() const override;
178 void set_id(int channel_id) override; 181 void set_id(int channel_id) override;
179 ReadyState ready_state() const override; 182 ReadyState ready_state() const override;
180 ChannelError error_state() const override; 183 ChannelError error_state() const override;
181 bool keep_alive() const override; 184 bool keep_alive() const override;
182 bool audio_only() const override; 185 bool audio_only() const override;
183 void AddObserver(Observer* observer) override; 186 void AddObserver(Observer* observer) override;
187 void RemoveObserver(Observer* observer) override;
184 188
185 protected: 189 protected:
186 // CastTransport::Delegate methods for receiving handshake messages. 190 // CastTransport::Delegate methods for receiving handshake messages.
187 class AuthTransportDelegate : public CastTransport::Delegate { 191 class AuthTransportDelegate : public CastTransport::Delegate {
188 public: 192 public:
189 explicit AuthTransportDelegate(CastSocketImpl* socket); 193 explicit AuthTransportDelegate(CastSocketImpl* socket);
190 194
191 // Gets the error state of the channel. 195 // Gets the error state of the channel.
192 // Returns CHANNEL_ERROR_NONE if no errors are present. 196 // Returns CHANNEL_ERROR_NONE if no errors are present.
193 ChannelError error_state() const; 197 ChannelError error_state() const;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 AuthTransportDelegate* auth_delegate_; 419 AuthTransportDelegate* auth_delegate_;
416 420
417 // List of socket observers. 421 // List of socket observers.
418 base::ObserverList<Observer> observers_; 422 base::ObserverList<Observer> observers_;
419 423
420 DISALLOW_COPY_AND_ASSIGN(CastSocketImpl); 424 DISALLOW_COPY_AND_ASSIGN(CastSocketImpl);
421 }; 425 };
422 } // namespace cast_channel 426 } // namespace cast_channel
423 427
424 #endif // COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_ 428 #endif // COMPONENTS_CAST_CHANNEL_CAST_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698