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

Side by Side Diff: chrome/browser/extensions/api/socket/tcp_socket.h

Issue 10134008: Add bind(), recvFrom(), sendTo() for UDP socket. (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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/extensions/api/socket/socket.h" 11 #include "chrome/browser/extensions/api/socket/socket.h"
12 12
13 // This looks like it should be forward-declarable, but it does some tricky 13 // This looks like it should be forward-declarable, but it does some tricky
14 // moves that make it easier to just include it. 14 // moves that make it easier to just include it.
15 #include "net/socket/tcp_client_socket.h" 15 #include "net/socket/tcp_client_socket.h"
16 16
17 namespace net { 17 namespace net {
18 class Socket; 18 class Socket;
19 } 19 }
20 20
21 namespace extensions { 21 namespace extensions {
22 22
23 class APIResourceEventNotifier; 23 class APIResourceEventNotifier;
24 24
25 class TCPSocket : public Socket { 25 class TCPSocket : public Socket {
26 public: 26 public:
27 TCPSocket(const std::string& address, int port, 27 explicit TCPSocket(APIResourceEventNotifier* event_notifier);
28 APIResourceEventNotifier* event_notifier);
29 virtual ~TCPSocket(); 28 virtual ~TCPSocket();
30 29
31 virtual bool IsValid() OVERRIDE; 30 virtual int Connect(const std::string& address, int port) OVERRIDE;
32
33 virtual int Connect() OVERRIDE;
34 virtual void Disconnect() OVERRIDE; 31 virtual void Disconnect() OVERRIDE;
32 virtual int Bind(const std::string& address, int port) OVERRIDE;
33 virtual int Read(scoped_refptr<net::IOBuffer> io_buffer,
34 int io_buffer_size) OVERRIDE;
35 virtual int Write(scoped_refptr<net::IOBuffer> io_buffer,
36 int bytes) OVERRIDE;
37 virtual int RecvFrom(scoped_refptr<net::IOBuffer> io_buffer,
38 int io_buffer_size,
39 net::IPEndPoint *address) OVERRIDE;
40 virtual int SendTo(scoped_refptr<net::IOBuffer> io_buffer,
41 int byte_count,
42 const std::string& address,
43 int port) OVERRIDE;
35 44
36 virtual void OnConnect(int result); 45 virtual void OnConnect(int result);
37 46
38 static TCPSocket* CreateSocketForTesting( 47 static TCPSocket* CreateSocketForTesting(
39 net::TCPClientSocket* tcp_client_socket, 48 net::TCPClientSocket* tcp_client_socket,
40 const std::string& address, int port,
41 APIResourceEventNotifier* event_notifier); 49 APIResourceEventNotifier* event_notifier);
42 50
43 protected:
44 virtual net::Socket* socket() OVERRIDE;
45
46 private: 51 private:
47 TCPSocket(net::TCPClientSocket* tcp_client_socket, 52 TCPSocket(net::TCPClientSocket* tcp_client_socket,
48 const std::string& address, int port,
49 APIResourceEventNotifier* event_notifier); 53 APIResourceEventNotifier* event_notifier);
50 54
51 scoped_ptr<net::TCPClientSocket> socket_; 55 scoped_ptr<net::TCPClientSocket> socket_;
52 }; 56 };
53 57
54 } // namespace extensions 58 } // namespace extensions
55 59
56 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_ 60 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_TCP_SOCKET_H_
OLDNEW
« 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