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

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

Issue 10071035: RefCounted types should not have public destructors, chrome/browser/extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile fix Created 8 years, 8 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 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/extensions/api/api_function.h" 10 #include "chrome/browser/extensions/api/api_function.h"
(...skipping 12 matching lines...) Expand all
23 extern const char kUdpSocketType[]; 23 extern const char kUdpSocketType[];
24 24
25 // Many of these socket functions are synchronous in the sense that 25 // Many of these socket functions are synchronous in the sense that
26 // they don't involve blocking operations, but we've made them all 26 // they don't involve blocking operations, but we've made them all
27 // AsyncExtensionFunctions because the underlying UDPClientSocket 27 // AsyncExtensionFunctions because the underlying UDPClientSocket
28 // library wants all operations to happen on the same thread as the 28 // library wants all operations to happen on the same thread as the
29 // one that created the socket. Too bad. 29 // one that created the socket. Too bad.
30 30
31 class SocketCreateFunction : public AsyncIOAPIFunction { 31 class SocketCreateFunction : public AsyncIOAPIFunction {
32 public: 32 public:
33 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create")
34
33 SocketCreateFunction(); 35 SocketCreateFunction();
34 36
35 protected: 37 protected:
38 virtual ~SocketCreateFunction();
39
40 // AsyncIOAPIFunction:
36 virtual bool Prepare() OVERRIDE; 41 virtual bool Prepare() OVERRIDE;
37 virtual void Work() OVERRIDE; 42 virtual void Work() OVERRIDE;
38 virtual bool Respond() OVERRIDE; 43 virtual bool Respond() OVERRIDE;
39 44
40 private: 45 private:
41 enum SocketType { 46 enum SocketType {
42 kSocketTypeInvalid = -1, 47 kSocketTypeInvalid = -1,
43 kSocketTypeTCP, 48 kSocketTypeTCP,
44 kSocketTypeUDP 49 kSocketTypeUDP
45 }; 50 };
46 51
47 SocketType socket_type_; 52 SocketType socket_type_;
48 int src_id_; 53 int src_id_;
49 APIResourceEventNotifier* event_notifier_; 54 APIResourceEventNotifier* event_notifier_;
50
51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create")
52 }; 55 };
53 56
54 class SocketDestroyFunction : public AsyncIOAPIFunction { 57 class SocketDestroyFunction : public AsyncIOAPIFunction {
58 public:
59 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.destroy")
60
55 protected: 61 protected:
62 virtual ~SocketDestroyFunction() {}
63
64 // AsyncIOAPIFunction:
56 virtual bool Prepare() OVERRIDE; 65 virtual bool Prepare() OVERRIDE;
57 virtual void Work() OVERRIDE; 66 virtual void Work() OVERRIDE;
58 virtual bool Respond() OVERRIDE; 67 virtual bool Respond() OVERRIDE;
59 68
60 private: 69 private:
61 int socket_id_; 70 int socket_id_;
62
63 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.destroy")
64 }; 71 };
65 72
66 class SocketConnectFunction : public AsyncIOAPIFunction { 73 class SocketConnectFunction : public AsyncIOAPIFunction {
74 public:
75 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
76
67 protected: 77 protected:
78 virtual ~SocketConnectFunction() {}
79
80 // AsyncIOAPIFunction:
68 virtual bool Prepare() OVERRIDE; 81 virtual bool Prepare() OVERRIDE;
69 virtual void Work() OVERRIDE; 82 virtual void Work() OVERRIDE;
70 virtual bool Respond() OVERRIDE; 83 virtual bool Respond() OVERRIDE;
71 84
72 private: 85 private:
73 int socket_id_; 86 int socket_id_;
74 std::string address_; 87 std::string address_;
75 int port_; 88 int port_;
76
77 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
78 }; 89 };
79 90
80 class SocketDisconnectFunction : public AsyncIOAPIFunction { 91 class SocketDisconnectFunction : public AsyncIOAPIFunction {
92 public:
93 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.disconnect")
94
81 protected: 95 protected:
96 virtual ~SocketDisconnectFunction() {}
97
98 // AsyncIOAPIFunction:
82 virtual bool Prepare() OVERRIDE; 99 virtual bool Prepare() OVERRIDE;
83 virtual void Work() OVERRIDE; 100 virtual void Work() OVERRIDE;
84 virtual bool Respond() OVERRIDE; 101 virtual bool Respond() OVERRIDE;
85 102
86 private: 103 private:
87 int socket_id_; 104 int socket_id_;
88
89 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.disconnect")
90 }; 105 };
91 106
92 class SocketBindFunction : public AsyncIOAPIFunction { 107 class SocketBindFunction : public AsyncIOAPIFunction {
93 protected: 108 protected:
94 virtual bool Prepare() OVERRIDE; 109 virtual bool Prepare() OVERRIDE;
95 virtual void Work() OVERRIDE; 110 virtual void Work() OVERRIDE;
96 virtual bool Respond() OVERRIDE; 111 virtual bool Respond() OVERRIDE;
97 112
98 private: 113 private:
99 int socket_id_; 114 int socket_id_;
100 std::string address_; 115 std::string address_;
101 int port_; 116 int port_;
102 117
103 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.bind") 118 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.bind")
104 }; 119 };
105 120
106 class SocketReadFunction : public AsyncIOAPIFunction { 121 class SocketReadFunction : public AsyncIOAPIFunction {
122 public:
123 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.read")
124
107 protected: 125 protected:
126 virtual ~SocketReadFunction() {}
127
128 // AsyncIOAPIFunction:
108 virtual bool Prepare() OVERRIDE; 129 virtual bool Prepare() OVERRIDE;
109 virtual void Work() OVERRIDE; 130 virtual void Work() OVERRIDE;
110 virtual bool Respond() OVERRIDE; 131 virtual bool Respond() OVERRIDE;
111 132
112 private: 133 private:
113 int socket_id_; 134 int socket_id_;
114
115 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.read")
116 }; 135 };
117 136
118 class SocketWriteFunction : public AsyncIOAPIFunction { 137 class SocketWriteFunction : public AsyncIOAPIFunction {
119 public: 138 public:
139 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write")
140
120 SocketWriteFunction(); 141 SocketWriteFunction();
142
143 protected:
121 virtual ~SocketWriteFunction(); 144 virtual ~SocketWriteFunction();
122 145
123 protected: 146 // AsyncIOAPIFunction:
124 virtual bool Prepare() OVERRIDE; 147 virtual bool Prepare() OVERRIDE;
125 virtual void Work() OVERRIDE; 148 virtual void Work() OVERRIDE;
126 virtual bool Respond() OVERRIDE; 149 virtual bool Respond() OVERRIDE;
127 150
128 private: 151 private:
129 int socket_id_; 152 int socket_id_;
130 scoped_refptr<net::IOBufferWithSize> io_buffer_; 153 scoped_refptr<net::IOBufferWithSize> io_buffer_;
131
132 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write")
133 }; 154 };
134 155
135 class SocketRecvFromFunction : public AsyncIOAPIFunction { 156 class SocketRecvFromFunction : public AsyncIOAPIFunction {
157 public:
158 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.recvFrom")
159
136 protected: 160 protected:
161 virtual ~SocketRecvFromFunction();
162
163 // AsyncIOAPIFunction
137 virtual bool Prepare() OVERRIDE; 164 virtual bool Prepare() OVERRIDE;
138 virtual void Work() OVERRIDE; 165 virtual void Work() OVERRIDE;
139 virtual bool Respond() OVERRIDE; 166 virtual bool Respond() OVERRIDE;
140 167
141 private: 168 private:
142 int socket_id_; 169 int socket_id_;
143 net::IPEndPoint address_; 170 net::IPEndPoint address_;
144
145 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.recvFrom")
146 }; 171 };
147 172
148 class SocketSendToFunction : public AsyncIOAPIFunction { 173 class SocketSendToFunction : public AsyncIOAPIFunction {
149 public: 174 public:
150 SocketSendToFunction(); 175 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.sendTo")
151 virtual ~SocketSendToFunction();
152 176
153 protected: 177 SocketSendToFunction();
178
179 protected:
180 virtual ~SocketSendToFunction();
181
182 // AsyncIOAPIFunction:
154 virtual bool Prepare() OVERRIDE; 183 virtual bool Prepare() OVERRIDE;
155 virtual void Work() OVERRIDE; 184 virtual void Work() OVERRIDE;
156 virtual bool Respond() OVERRIDE; 185 virtual bool Respond() OVERRIDE;
157 186
158 private: 187 private:
159 int socket_id_; 188 int socket_id_;
160 scoped_refptr<net::IOBufferWithSize> io_buffer_; 189 scoped_refptr<net::IOBufferWithSize> io_buffer_;
161 std::string address_; 190 std::string address_;
162 int port_; 191 int port_;
163
164 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.sendTo")
165 }; 192 };
166 193
167 } // namespace extensions 194 } // namespace extensions
168 195
169 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ 196 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/serial/serial_api.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