Index: extensions/browser/api/cast_channel/cast_socket.h |
diff --git a/extensions/browser/api/cast_channel/cast_socket.h b/extensions/browser/api/cast_channel/cast_socket.h |
index 7bcd513bba76ea7554084dc3512c29ebf87d0ffa..fcfd9af8fe936d7d6fd5519c2a23b3ebee261532 100644 |
--- a/extensions/browser/api/cast_channel/cast_socket.h |
+++ b/extensions/browser/api/cast_channel/cast_socket.h |
@@ -9,11 +9,9 @@ |
#include <string> |
#include "base/basictypes.h" |
-#include "base/callback.h" |
#include "base/cancelable_callback.h" |
#include "base/gtest_prod_util.h" |
#include "base/memory/ref_counted.h" |
-#include "base/memory/weak_ptr.h" |
#include "base/threading/thread_checker.h" |
#include "base/timer/timer.h" |
#include "extensions/browser/api/api_resource.h" |
@@ -45,8 +43,7 @@ class CastMessage; |
// |
// NOTE: Not called "CastChannel" to reduce confusion with the generated API |
// code. |
-class CastSocket : public ApiResource, |
- public base::SupportsWeakPtr<CastSocket> { |
+class CastSocket : public ApiResource { |
public: |
// Object to be informed of incoming messages and errors. |
class Delegate { |
@@ -72,6 +69,8 @@ class CastSocket : public ApiResource, |
CastSocket::Delegate* delegate, |
net::NetLog* net_log, |
const base::TimeDelta& connect_timeout); |
+ |
+ // Ensures that the socket is closed. |
virtual ~CastSocket(); |
// The IP endpoint for the destination of the channel. |
@@ -221,6 +220,7 @@ class CastSocket : public ApiResource, |
int DoSslConnectComplete(int result); |
int DoAuthChallengeSend(); |
int DoAuthChallengeSendComplete(int result); |
+ void DoAuthChallengeSendWriteComplete(int result); |
int DoAuthChallengeReplyComplete(int result); |
///////////////////////////////////////////////////////////////////////////// |
@@ -266,9 +266,14 @@ class CastSocket : public ApiResource, |
// Parses the contents of body_read_buffer_ and sets current_message_ to |
// the message received. |
bool ProcessBody(); |
- // Closes socket, updating the error state and signaling the delegate that |
- // |error| has occurred. |
+ // Closes the socket, sets |error_state_| to |error| and signals the |
+ // delegate that |error| has occurred. |
void CloseWithError(ChannelError error); |
+ // Frees resources and cancels pending callbacks. |ready_state_| will be set |
+ // READY_STATE_CLOSED on completion. A no-op if |ready_state_| is already |
+ // READY_STATE_CLOSED. |
+ void CloseInternal(); |
+ |
// Serializes the content of message_proto (with a header) to |message_data|. |
static bool Serialize(const CastMessage& message_proto, |
std::string* message_data); |
@@ -324,6 +329,8 @@ class CastSocket : public ApiResource, |
// Callback invoked when the socket is connected or fails to connect. |
net::CompletionCallback connect_callback_; |
+ // Callback invoked to cancel the connection. |
Wez
2014/07/30 19:14:53
nit: Invoked by whom?
mark a. foltz
2014/07/31 18:33:17
Done.
|
+ base::CancelableClosure cancel_connect_callback_; |
Wez
2014/07/30 19:14:53
nit: Consider connect_timeout_callback_
mark a. foltz
2014/07/31 18:33:17
Done.
|
// Duration to wait before timing out. |
base::TimeDelta connect_timeout_; |
// Timer invoked when the connection has timed out. |
@@ -343,6 +350,13 @@ class CastSocket : public ApiResource, |
// The current status of the channel. |
ReadyState ready_state_; |
+ // Callback invoked to (re)start the connect loop. |
Wez
2014/07/30 19:14:53
nit: Clarify when these callbacks is are in the "c
mark a. foltz
2014/07/31 18:33:17
Done.
|
+ base::CancelableClosure connect_loop_callback_; |
+ // Callback invoked after the auth challenge has been sent. |
+ base::CancelableClosure send_auth_challenge_callback_; |
+ // Callback invoked to (re)start the read loop. |
+ base::CancelableClosure read_loop_callback_; |
+ |
// Holds a message to be written to the socket. |callback| is invoked when the |
// message is fully written or an error occurrs. |
struct WriteRequest { |