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

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

Issue 10827390: Implement chrome.socket.bind/listen/accept for TCP server socket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years, 2 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 CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "chrome/browser/extensions/api/api_function.h" 9 #include "chrome/browser/extensions/api/api_function.h"
10 #include "chrome/browser/extensions/api/api_resource_manager.h" 10 #include "chrome/browser/extensions/api/api_resource_manager.h"
11 #include "chrome/browser/extensions/extension_function.h" 11 #include "chrome/browser/extensions/extension_function.h"
12 #include "chrome/common/extensions/api/socket.h" 12 #include "chrome/common/extensions/api/socket.h"
13 #include "net/base/address_list.h" 13 #include "net/base/address_list.h"
14 #include "net/base/host_resolver.h" 14 #include "net/base/host_resolver.h"
15 #include "net/socket/tcp_client_socket.h"
15 16
16 #include <string> 17 #include <string>
17 18
18 class IOThread; 19 class IOThread;
19 20
20 namespace net { 21 namespace net {
21 class IOBuffer; 22 class IOBuffer;
22 } 23 }
23 24
24 namespace extensions { 25 namespace extensions {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // AsyncApiFunction: 158 // AsyncApiFunction:
158 virtual bool Prepare() OVERRIDE; 159 virtual bool Prepare() OVERRIDE;
159 virtual void Work() OVERRIDE; 160 virtual void Work() OVERRIDE;
160 161
161 private: 162 private:
162 int socket_id_; 163 int socket_id_;
163 std::string address_; 164 std::string address_;
164 int port_; 165 int port_;
165 }; 166 };
166 167
168 class SocketListenFunction : public SocketAsyncApiFunction {
169 public:
170 DECLARE_EXTENSION_FUNCTION_NAME("socket.listen");
171
172 SocketListenFunction();
173
174 protected:
175 virtual ~SocketListenFunction();
176
177 // AsyncApiFunction:
178 virtual bool Prepare() OVERRIDE;
179 virtual void Work() OVERRIDE;
180
181 private:
182 scoped_ptr<api::socket::Listen::Params> params_;
183 };
184
185 class SocketAcceptFunction : public SocketAsyncApiFunction {
186 public:
187 DECLARE_EXTENSION_FUNCTION_NAME("socket.accept");
188
189 SocketAcceptFunction();
190
191 protected:
192 virtual ~SocketAcceptFunction();
193
194 // AsyncApiFunction:
195 virtual bool Prepare() OVERRIDE;
196 virtual void AsyncWorkStart() OVERRIDE;
197
198 private:
199 void OnAccept(int result_code, net::TCPClientSocket *socket);
200 scoped_ptr<api::socket::Accept::Params> params_;
201 };
202
167 class SocketReadFunction : public SocketAsyncApiFunction { 203 class SocketReadFunction : public SocketAsyncApiFunction {
168 public: 204 public:
169 DECLARE_EXTENSION_FUNCTION_NAME("socket.read") 205 DECLARE_EXTENSION_FUNCTION_NAME("socket.read")
170 206
171 SocketReadFunction(); 207 SocketReadFunction();
172 208
173 protected: 209 protected:
174 virtual ~SocketReadFunction(); 210 virtual ~SocketReadFunction();
175 211
176 // AsyncApiFunction: 212 // AsyncApiFunction:
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 348
313 private: 349 private:
314 void GetNetworkListOnFileThread(); 350 void GetNetworkListOnFileThread();
315 void HandleGetNetworkListError(); 351 void HandleGetNetworkListError();
316 void SendResponseOnUIThread(const net::NetworkInterfaceList& interface_list); 352 void SendResponseOnUIThread(const net::NetworkInterfaceList& interface_list);
317 }; 353 };
318 354
319 } // namespace extensions 355 } // namespace extensions
320 356
321 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ 357 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/socket/socket.cc ('k') | chrome/browser/extensions/api/socket/socket_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698