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

Unified Diff: jingle/glue/pseudotcp_adapter.h

Issue 7040021: Fix crash condition if caller deletes PseudoTcpAdaptor from within a callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change the flag we supply to Close(). Created 9 years, 7 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
« no previous file with comments | « no previous file | jingle/glue/pseudotcp_adapter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jingle/glue/pseudotcp_adapter.h
diff --git a/jingle/glue/pseudotcp_adapter.h b/jingle/glue/pseudotcp_adapter.h
index 35df8ce91aff96bf6bd1ef200d20647379df36da..977dcf1ba0e950d7d22fb6f5ff6268a1d7ffd384 100644
--- a/jingle/glue/pseudotcp_adapter.h
+++ b/jingle/glue/pseudotcp_adapter.h
@@ -17,12 +17,15 @@
namespace jingle_glue {
-class PseudoTcpAdapter : public net::StreamSocket,
- public cricket::IPseudoTcpNotify,
- public base::NonThreadSafe {
+// PseudoTcpAdapter adapts a connectionless net::Socket to a connection-
+// oriented net::StreamSocket using PseudoTcp. Because net::StreamSockets
+// can be deleted during callbacks, while PseudoTcp cannot, the core of the
+// PseudoTcpAdapter is reference counted, with a reference held by the
+// adapter, and an additional reference held on the stack during callbacks.
+class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe {
public:
- // Creates adapter for the specified |socket|. |socket| is assumed
- // to be already connected. Takes ownership of |socket|.
+ // Creates an adapter for the supplied Socket. |socket| should already
+ // be ready for use, and ownership of it will be assumed by the adapter.
PseudoTcpAdapter(net::Socket* socket);
virtual ~PseudoTcpAdapter();
@@ -47,43 +50,10 @@ class PseudoTcpAdapter : public net::StreamSocket,
virtual bool WasEverUsed() const OVERRIDE;
virtual bool UsingTCPFastOpen() const OVERRIDE;
- // cricket::IPseudoTcpNotify implementation.
- virtual void OnTcpOpen(cricket::PseudoTcp* tcp) OVERRIDE;
- virtual void OnTcpReadable(cricket::PseudoTcp* tcp) OVERRIDE;
- virtual void OnTcpWriteable(cricket::PseudoTcp* tcp) OVERRIDE;
- virtual void OnTcpClosed(cricket::PseudoTcp* tcp, uint32 error) OVERRIDE;
- virtual WriteResult TcpWritePacket(cricket::PseudoTcp* tcp,
- const char* buffer, size_t len) OVERRIDE;
-
private:
- void DoReadFromSocket();
- void HandleReadResults(int result);
-
- // Callback functions for Read() and Write() in |socket_|
- void OnRead(int result);
- void OnWritten(int result);
-
- void AdjustClock();
- void HandleTcpClock();
-
- scoped_ptr<net::Socket> socket_;
- cricket::PseudoTcp pseudotcp_;
-
- net::CompletionCallback* connect_callback_;
- scoped_refptr<net::IOBuffer> read_buffer_;
- int read_buffer_size_;
- net::CompletionCallback* read_callback_;
- scoped_refptr<net::IOBuffer> write_buffer_;
- int write_buffer_size_;
- net::CompletionCallback* write_callback_;
-
- bool socket_write_pending_;
- scoped_refptr<net::IOBuffer> socket_read_buffer_;
-
- net::CompletionCallbackImpl<PseudoTcpAdapter> socket_read_callback_;
- net::CompletionCallbackImpl<PseudoTcpAdapter> socket_write_callback_;
+ class Core;
- base::OneShotTimer<PseudoTcpAdapter> timer_;
+ scoped_refptr<Core> core_;
net::BoundNetLog net_log_;
« no previous file with comments | « no previous file | jingle/glue/pseudotcp_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698