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

Unified Diff: extensions/browser/api/cast_channel/cast_socket.h

Issue 417403002: Remove weak pointers from CastSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Finish reorganizing callbacks. Created 6 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 side-by-side diff with in-line comments
Download patch
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..9dcb783e58eb95612bf0b271f3b52812e37d1eb6 100644
--- a/extensions/browser/api/cast_channel/cast_socket.h
+++ b/extensions/browser/api/cast_channel/cast_socket.h
@@ -9,11 +9,10 @@
#include <string>
#include "base/basictypes.h"
-#include "base/callback.h"
+#include "base/callback_forward.h"
#include "base/cancelable_callback.h"
Kevin M 2014/07/28 22:08:17 Not used?
mark a. foltz 2014/07/29 00:16:25 Done.
#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 +44,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 +70,8 @@ class CastSocket : public ApiResource,
CastSocket::Delegate* delegate,
net::NetLog* net_log,
const base::TimeDelta& connect_timeout);
+
+ // Ensures that the socket is closed.
Wez 2014/07/28 23:14:57 Not sure what this comment adds?
mark a. foltz 2014/07/29 00:16:25 An invariant.
virtual ~CastSocket();
// The IP endpoint for the destination of the channel.
@@ -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);
+ // Closes sockets, frees resources, and cancels pending callbacks.
Wez 2014/07/28 23:14:56 nit: underlying sockets? Does "Closes sockets" no
mark a. foltz 2014/07/29 00:16:25 Done.
+ // |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.
+ base::Closure cancel_connect_callback_;
// 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.
+ base::Closure connect_loop_callback_;
+ // Callback invoked to send the auth challenge.
+ base::Closure send_auth_challenge_callback_;
+ // Callback invoked to (re)start the read loop.
+ base::Closure 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 {
« no previous file with comments | « no previous file | extensions/browser/api/cast_channel/cast_socket.cc » ('j') | extensions/browser/api/cast_channel/cast_socket.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698