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

Side by Side Diff: net/base/tcp_listen_socket.h

Issue 10386048: Decouple DevTools from socket implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Matt's comments 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 | Annotate | Revision Log
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 NET_BASE_TCP_LISTEN_SOCKET_H_ 5 #ifndef NET_BASE_TCP_LISTEN_SOCKET_H_
6 #define NET_BASE_TCP_LISTEN_SOCKET_H_ 6 #define NET_BASE_TCP_LISTEN_SOCKET_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
16 #include "net/base/stream_listen_socket.h" 16 #include "net/base/stream_listen_socket.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 // Implements a TCP socket. Note that this is ref counted. 20 // Implements a TCP socket. Note that this is ref counted.
21 class NET_EXPORT TCPListenSocket : public StreamListenSocket { 21 class NET_EXPORT TCPListenSocket : public StreamListenSocket {
22 public: 22 public:
23 // Listen on port for the specified IP address. Use 127.0.0.1 to only 23 // Listen on port for the specified IP address. Use 127.0.0.1 to only
24 // accept local connections. 24 // accept local connections.
25 static scoped_refptr<TCPListenSocket> CreateAndListen( 25 static scoped_refptr<TCPListenSocket> CreateAndListen(
26 const std::string& ip, int port, StreamListenSocket::Delegate* del); 26 const std::string& ip, int port, StreamListenSocket::Delegate* del);
27 27
28 virtual ~TCPListenSocket();
29
30 protected: 28 protected:
31 TCPListenSocket(SOCKET s, StreamListenSocket::Delegate* del); 29 TCPListenSocket(SOCKET s, StreamListenSocket::Delegate* del);
32 30
33 static SOCKET CreateAndBind(const std::string& ip, int port); 31 static SOCKET CreateAndBind(const std::string& ip, int port);
34 32
35 // Implements StreamListenSocket::Accept. 33 // Implements StreamListenSocket::Accept.
36 virtual void Accept() OVERRIDE; 34 virtual void Accept() OVERRIDE;
37 35
38 private: 36 private:
37 friend class scoped_refptr<TCPListenSocket>;
38 virtual ~TCPListenSocket();
39
39 DISALLOW_COPY_AND_ASSIGN(TCPListenSocket); 40 DISALLOW_COPY_AND_ASSIGN(TCPListenSocket);
40 }; 41 };
41 42
43 // Factory that can be used to instantiate TCPListenSocket.
44 class TCPListenSocketFactory : public StreamListenSocketFactory {
45 public:
46 TCPListenSocketFactory(const std::string& ip, int port);
47 virtual ~TCPListenSocketFactory();
48
49 // StreamListenSocketFactory overrides.
50 virtual scoped_refptr<StreamListenSocket> CreateAndListen(
51 StreamListenSocket::Delegate* delegate) const OVERRIDE;
52
53 private:
54 const std::string ip_;
55 const int port_;
56
57 DISALLOW_COPY_AND_ASSIGN(TCPListenSocketFactory);
58 };
59
42 } // namespace net 60 } // namespace net
43 61
44 #endif // NET_BASE_TCP_LISTEN_SOCKET_H_ 62 #endif // NET_BASE_TCP_LISTEN_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698