Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/common/extensions/api/socket.h" | 11 #include "chrome/common/extensions/api/socket.h" |
| 12 #include "net/base/address_list.h" | 12 #include "net/base/address_list.h" |
| 13 #include "net/base/host_resolver.h" | 13 #include "net/base/host_resolver.h" |
| 14 #include "net/socket/tcp_client_socket.h" | |
| 14 | 15 |
| 15 #include <string> | 16 #include <string> |
| 16 | 17 |
| 17 class IOThread; | 18 class IOThread; |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 class IOBuffer; | 21 class IOBuffer; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace extensions { | 24 namespace extensions { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 // AsyncApiFunction: | 154 // AsyncApiFunction: |
| 154 virtual bool Prepare() OVERRIDE; | 155 virtual bool Prepare() OVERRIDE; |
| 155 virtual void Work() OVERRIDE; | 156 virtual void Work() OVERRIDE; |
| 156 | 157 |
| 157 private: | 158 private: |
| 158 int socket_id_; | 159 int socket_id_; |
| 159 std::string address_; | 160 std::string address_; |
| 160 int port_; | 161 int port_; |
| 161 }; | 162 }; |
| 162 | 163 |
| 164 class SocketListenFunction : public SocketAsyncApiFunction { | |
| 165 public: | |
| 166 DECLARE_EXTENSION_FUNCTION_NAME("socket.listen"); | |
|
Peng
2012/09/11 14:01:18
maybe experimental first?
justinlin
2012/09/12 07:29:42
Sure, but it doesn't seem to work when I just add
Peng
2012/09/12 19:49:49
I think you need create another idl file which jus
justinlin
2012/09/13 08:21:12
Done. Thanks!
| |
| 167 | |
| 168 SocketListenFunction(); | |
| 169 | |
| 170 protected: | |
| 171 virtual ~SocketListenFunction(); | |
| 172 | |
| 173 // AsyncApiFunction: | |
| 174 virtual bool Prepare() OVERRIDE; | |
| 175 virtual void Work() OVERRIDE; | |
| 176 | |
| 177 private: | |
| 178 scoped_ptr<api::socket::Listen::Params> params_; | |
| 179 }; | |
| 180 | |
| 181 class SocketAcceptFunction : public SocketAsyncApiFunction { | |
| 182 public: | |
| 183 DECLARE_EXTENSION_FUNCTION_NAME("socket.accept"); | |
| 184 | |
| 185 SocketAcceptFunction(); | |
| 186 | |
| 187 protected: | |
| 188 virtual ~SocketAcceptFunction(); | |
| 189 | |
| 190 // AsyncApiFunction: | |
| 191 virtual bool Prepare() OVERRIDE; | |
| 192 virtual void AsyncWorkStart() OVERRIDE; | |
| 193 | |
| 194 private: | |
| 195 void OnAccept(int result_code, net::TCPClientSocket *socket); | |
| 196 scoped_ptr<api::socket::Accept::Params> params_; | |
| 197 }; | |
| 198 | |
| 163 class SocketReadFunction : public SocketAsyncApiFunction { | 199 class SocketReadFunction : public SocketAsyncApiFunction { |
| 164 public: | 200 public: |
| 165 DECLARE_EXTENSION_FUNCTION_NAME("socket.read") | 201 DECLARE_EXTENSION_FUNCTION_NAME("socket.read") |
| 166 | 202 |
| 167 SocketReadFunction(); | 203 SocketReadFunction(); |
| 168 | 204 |
| 169 protected: | 205 protected: |
| 170 virtual ~SocketReadFunction(); | 206 virtual ~SocketReadFunction(); |
| 171 | 207 |
| 172 // AsyncApiFunction: | 208 // AsyncApiFunction: |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 virtual bool Prepare() OVERRIDE; | 330 virtual bool Prepare() OVERRIDE; |
| 295 virtual void Work() OVERRIDE; | 331 virtual void Work() OVERRIDE; |
| 296 | 332 |
| 297 private: | 333 private: |
| 298 scoped_ptr<api::socket::GetInfo::Params> params_; | 334 scoped_ptr<api::socket::GetInfo::Params> params_; |
| 299 }; | 335 }; |
| 300 | 336 |
| 301 } // namespace extensions | 337 } // namespace extensions |
| 302 | 338 |
| 303 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ | 339 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ |
| OLD | NEW |