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