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

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

Issue 10161005: Add DefaultListenSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build on Windows 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
« no previous file with comments | « chrome_frame/test/test_with_web_server.cc ('k') | net/base/listen_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Abstract socket server that handles IO asynchronously in the specified
6 // MessageLoop.
7
8 #ifndef NET_BASE_LISTEN_SOCKET_H_
9 #define NET_BASE_LISTEN_SOCKET_H_
10 #pragma once
11
12 #include <string>
13
14 #include "base/basictypes.h"
15 #include "base/memory/ref_counted.h"
16 #include "build/build_config.h"
17 #include "net/base/net_export.h"
18
19 namespace net {
20
21 // Defines a socket interface for a server.
22 class NET_EXPORT ListenSocket
23 : public base::RefCountedThreadSafe<ListenSocket> {
24 public:
25 // TODO(erikkay): this delegate should really be split into two parts
26 // to split up the listener from the connected socket. Perhaps this class
27 // should be split up similarly.
28 class ListenSocketDelegate {
29 public:
30 // server is the original listening Socket, connection is the new
31 // Socket that was created. Ownership of connection is transferred
32 // to the delegate with this call.
33 virtual void DidAccept(ListenSocket *server,
34 ListenSocket *connection) = 0;
35 virtual void DidRead(ListenSocket *connection,
36 const char* data,
37 int len) = 0;
38 virtual void DidClose(ListenSocket *sock) = 0;
39
40 protected:
41 virtual ~ListenSocketDelegate() {}
42 };
43
44 // Send data to the socket.
45 void Send(const char* bytes, int len, bool append_linefeed = false);
46 void Send(const std::string& str, bool append_linefeed = false);
47
48 protected:
49 ListenSocket(ListenSocketDelegate* del);
50 virtual ~ListenSocket();
51
52 virtual void SendInternal(const char* bytes, int len) = 0;
53
54 ListenSocketDelegate* const socket_delegate_;
55
56 private:
57 friend class base::RefCountedThreadSafe<ListenSocket>;
58
59 DISALLOW_COPY_AND_ASSIGN(ListenSocket);
60 };
61
62 } // namespace net
63
64 #endif // NET_BASE_LISTEN_SOCKET_H_
OLDNEW
« no previous file with comments | « chrome_frame/test/test_with_web_server.cc ('k') | net/base/listen_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698