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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/extensions/api/api_function.h" | 9 #include "chrome/browser/extensions/api/generated_base_classes.h" |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 class APIResourceController; | 15 class APIResourceController; |
16 | 16 |
17 extern const char kBytesWrittenKey[]; | 17 extern const char kBytesWrittenKey[]; |
18 extern const char kSocketIdKey[]; | 18 extern const char kSocketIdKey[]; |
19 extern const char kUdpSocketType[]; | 19 extern const char kUdpSocketType[]; |
20 | 20 |
21 // Many of these socket functions are synchronous in the sense that | 21 // Many of these socket functions are synchronous in the sense that |
22 // they don't involve blocking operations, but we've made them all | 22 // they don't involve blocking operations, but we've made them all |
23 // AsyncExtensionFunctions because the underlying UDPClientSocket | 23 // AsyncExtensionFunctions because the underlying UDPClientSocket |
24 // library wants all operations to happen on the same thread as the | 24 // library wants all operations to happen on the same thread as the |
25 // one that created the socket. Too bad. | 25 // one that created the socket. Too bad. |
26 | 26 |
| 27 // AsyncSocketCreateFunction |
27 class SocketCreateFunction : public AsyncIOAPIFunction { | 28 class SocketCreateFunction : public AsyncIOAPIFunction { |
28 public: | 29 public: |
29 SocketCreateFunction(); | 30 SocketCreateFunction(); |
30 | 31 |
31 protected: | 32 protected: |
32 virtual bool Prepare() OVERRIDE; | 33 virtual bool Prepare() OVERRIDE; |
33 virtual void Work() OVERRIDE; | 34 virtual void Work() OVERRIDE; |
34 virtual bool Respond() OVERRIDE; | 35 virtual bool Respond() OVERRIDE; |
35 | 36 |
36 private: | 37 private: |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 private: | 106 private: |
106 int socket_id_; | 107 int socket_id_; |
107 std::string message_; | 108 std::string message_; |
108 | 109 |
109 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write") | 110 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write") |
110 }; | 111 }; |
111 | 112 |
112 } // namespace extensions | 113 } // namespace extensions |
113 | 114 |
114 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ | 115 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ |
OLD | NEW |