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

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

Issue 10692160: Support socket endpoint permissions for AppsV2 Socket API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix compile issues.wq Created 8 years, 4 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_SOCKET_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 17 matching lines...) Expand all
28 typedef base::Callback<void(int, scoped_refptr<net::IOBuffer> io_buffer)> 28 typedef base::Callback<void(int, scoped_refptr<net::IOBuffer> io_buffer)>
29 ReadCompletionCallback; 29 ReadCompletionCallback;
30 typedef base::Callback< 30 typedef base::Callback<
31 void(int, scoped_refptr<net::IOBuffer> io_buffer, const std::string&, int)> 31 void(int, scoped_refptr<net::IOBuffer> io_buffer, const std::string&, int)>
32 RecvFromCompletionCallback; 32 RecvFromCompletionCallback;
33 33
34 // A Socket wraps a low-level socket and includes housekeeping information that 34 // A Socket wraps a low-level socket and includes housekeeping information that
35 // we need to manage it in the context of an extension. 35 // we need to manage it in the context of an extension.
36 class Socket : public ApiResource { 36 class Socket : public ApiResource {
37 public: 37 public:
38 enum SocketType {
39 TYPE_NONE = 0,
Mihai Parparita -not on Chrome 2012/08/10 00:16:16 I don't see this used anywhere. It seems preferabl
Peng 2012/08/13 16:26:10 Done.
40 TYPE_TCP,
41 TYPE_UDP,
42 };
43
38 virtual ~Socket(); 44 virtual ~Socket();
39 virtual void Connect(const std::string& address, 45 virtual void Connect(const std::string& address,
40 int port, 46 int port,
41 const CompletionCallback& callback) = 0; 47 const CompletionCallback& callback) = 0;
42 virtual void Disconnect() = 0; 48 virtual void Disconnect() = 0;
43 virtual int Bind(const std::string& address, int port) = 0; 49 virtual int Bind(const std::string& address, int port) = 0;
44 50
45 // The |callback| will be called with the number of bytes read into the 51 // The |callback| will be called with the number of bytes read into the
46 // buffer, or a negative number if an error occurred. 52 // buffer, or a negative number if an error occurred.
47 virtual void Read(int count, 53 virtual void Read(int count,
(...skipping 10 matching lines...) Expand all
58 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer, 64 virtual void SendTo(scoped_refptr<net::IOBuffer> io_buffer,
59 int byte_count, 65 int byte_count,
60 const std::string& address, 66 const std::string& address,
61 int port, 67 int port,
62 const CompletionCallback& callback) = 0; 68 const CompletionCallback& callback) = 0;
63 69
64 virtual bool SetKeepAlive(bool enable, int delay); 70 virtual bool SetKeepAlive(bool enable, int delay);
65 virtual bool SetNoDelay(bool no_delay); 71 virtual bool SetNoDelay(bool no_delay);
66 72
67 bool IsConnected(); 73 bool IsConnected();
68 virtual bool IsTCPSocket() = 0;
69 74
70 virtual bool GetPeerAddress(net::IPEndPoint* address) = 0; 75 virtual bool GetPeerAddress(net::IPEndPoint* address) = 0;
71 virtual bool GetLocalAddress(net::IPEndPoint* address) = 0; 76 virtual bool GetLocalAddress(net::IPEndPoint* address) = 0;
72 77
78 virtual SocketType socket_type() const = 0;
79
73 static bool StringAndPortToAddressList(const std::string& ip_address_str, 80 static bool StringAndPortToAddressList(const std::string& ip_address_str,
74 int port, 81 int port,
75 net::AddressList* address_list); 82 net::AddressList* address_list);
76 static bool StringAndPortToIPEndPoint(const std::string& ip_address_str, 83 static bool StringAndPortToIPEndPoint(const std::string& ip_address_str,
77 int port, 84 int port,
78 net::IPEndPoint* ip_end_point); 85 net::IPEndPoint* ip_end_point);
79 static void IPEndPointToStringAndPort(const net::IPEndPoint& address, 86 static void IPEndPointToStringAndPort(const net::IPEndPoint& address,
80 std::string* ip_address_str, 87 std::string* ip_address_str,
81 int* port); 88 int* port);
82 89
(...skipping 25 matching lines...) Expand all
108 CompletionCallback callback; 115 CompletionCallback callback;
109 int bytes_written; 116 int bytes_written;
110 }; 117 };
111 std::queue<WriteRequest> write_queue_; 118 std::queue<WriteRequest> write_queue_;
112 scoped_refptr<net::IOBuffer> io_buffer_write_; 119 scoped_refptr<net::IOBuffer> io_buffer_write_;
113 }; 120 };
114 121
115 } // namespace extensions 122 } // namespace extensions
116 123
117 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_ 124 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698