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 "base/memory/ref_counted.h" |
9 #include "chrome/browser/extensions/api/api_function.h" | 10 #include "chrome/browser/extensions/api/api_function.h" |
| 11 #include "net/base/io_buffer.h" |
10 | 12 |
11 #include <string> | 13 #include <string> |
12 | 14 |
13 namespace extensions { | 15 namespace extensions { |
14 | 16 |
15 class APIResourceController; | 17 class APIResourceController; |
16 class APIResourceEventNotifier; | 18 class APIResourceEventNotifier; |
17 | 19 |
18 extern const char kBytesWrittenKey[]; | 20 extern const char kBytesWrittenKey[]; |
19 extern const char kSocketIdKey[]; | 21 extern const char kSocketIdKey[]; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 virtual void Work() OVERRIDE; | 94 virtual void Work() OVERRIDE; |
93 virtual bool Respond() OVERRIDE; | 95 virtual bool Respond() OVERRIDE; |
94 | 96 |
95 private: | 97 private: |
96 int socket_id_; | 98 int socket_id_; |
97 | 99 |
98 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.read") | 100 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.read") |
99 }; | 101 }; |
100 | 102 |
101 class SocketWriteFunction : public AsyncIOAPIFunction { | 103 class SocketWriteFunction : public AsyncIOAPIFunction { |
| 104 public: |
| 105 SocketWriteFunction(); |
| 106 virtual ~SocketWriteFunction(); |
| 107 |
102 protected: | 108 protected: |
103 virtual bool Prepare() OVERRIDE; | 109 virtual bool Prepare() OVERRIDE; |
104 virtual void Work() OVERRIDE; | 110 virtual void Work() OVERRIDE; |
105 virtual bool Respond() OVERRIDE; | 111 virtual bool Respond() OVERRIDE; |
106 | 112 |
107 private: | 113 private: |
108 int socket_id_; | 114 int socket_id_; |
109 std::string message_; | 115 scoped_refptr<net::IOBufferWithSize> io_buffer_; |
110 | 116 |
111 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write") | 117 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write") |
112 }; | 118 }; |
113 | 119 |
114 } // namespace extensions | 120 } // namespace extensions |
115 | 121 |
116 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ | 122 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ |
OLD | NEW |