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

Unified Diff: chrome/browser/extensions/api/socket/tcp_socket.h

Issue 10273016: Refactor the socket API to remove onEvent callback in socket.create() function. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update Created 8 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
Index: chrome/browser/extensions/api/socket/tcp_socket.h
diff --git a/chrome/browser/extensions/api/socket/tcp_socket.h b/chrome/browser/extensions/api/socket/tcp_socket.h
index 55ead13fd7d0cbdd0ec5bcaff26673fa2f7b2311..627ad46a293be7c22f31ce20131fc378c7bd740a 100644
--- a/chrome/browser/extensions/api/socket/tcp_socket.h
+++ b/chrome/browser/extensions/api/socket/tcp_socket.h
@@ -27,32 +27,44 @@ class TCPSocket : public Socket {
explicit TCPSocket(APIResourceEventNotifier* event_notifier);
virtual ~TCPSocket();
- virtual int Connect(const std::string& address, int port) OVERRIDE;
+ virtual void Connect(const std::string& address,
+ int port,
+ const CompletionCallback& callback) OVERRIDE;
virtual void Disconnect() OVERRIDE;
virtual int Bind(const std::string& address, int port) OVERRIDE;
- virtual int Read(scoped_refptr<net::IOBuffer> io_buffer,
- int io_buffer_size) OVERRIDE;
- virtual int Write(scoped_refptr<net::IOBuffer> io_buffer,
- int bytes) OVERRIDE;
- virtual int RecvFrom(scoped_refptr<net::IOBuffer> io_buffer,
- int io_buffer_size,
- net::IPEndPoint *address) OVERRIDE;
- virtual int SendTo(scoped_refptr<net::IOBuffer> io_buffer,
- int byte_count,
- const std::string& address,
- int port) OVERRIDE;
-
- virtual void OnConnect(int result);
+ virtual void Read(int count,
+ const ReadCompletionCallback& callback) OVERRIDE;
+ virtual void Write(scoped_refptr<net::IOBuffer> io_buffer,
+ int bytes,
+ const CompletionCallback& callback) OVERRIDE;
+ virtual void RecvFrom(int count,
+ const RecvFromCompletionCallback& callback) OVERRIDE;
+ virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer,
+ int byte_count,
+ const std::string& address,
+ int port,
+ const CompletionCallback& callback) OVERRIDE;
static TCPSocket* CreateSocketForTesting(
net::TCPClientSocket* tcp_client_socket,
APIResourceEventNotifier* event_notifier);
private:
+ virtual void OnConnectComplete(int result);
+ virtual void OnReadComplete(scoped_refptr<net::IOBuffer> io_buffer,
+ int result);
+ virtual void OnWriteComplete(int result);
+
TCPSocket(net::TCPClientSocket* tcp_client_socket,
APIResourceEventNotifier* event_notifier);
scoped_ptr<net::TCPClientSocket> socket_;
+
+ CompletionCallback connect_callback_;
+
+ ReadCompletionCallback read_callback_;
+
+ CompletionCallback write_callback_;
};
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/socket/socket_api.cc ('k') | chrome/browser/extensions/api/socket/tcp_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698