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

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: Implementations 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 11 matching lines...) Expand all
22 extern const char kUdpSocketType[]; 22 extern const char kUdpSocketType[];
23 23
24 // Many of these socket functions are synchronous in the sense that 24 // Many of these socket functions are synchronous in the sense that
25 // they don't involve blocking operations, but we've made them all 25 // they don't involve blocking operations, but we've made them all
26 // AsyncExtensionFunctions because the underlying UDPClientSocket 26 // AsyncExtensionFunctions because the underlying UDPClientSocket
27 // library wants all operations to happen on the same thread as the 27 // library wants all operations to happen on the same thread as the
28 // one that created the socket. Too bad. 28 // one that created the socket. Too bad.
29 29
30 class SocketCreateFunction : public AsyncIOAPIFunction { 30 class SocketCreateFunction : public AsyncIOAPIFunction {
31 public: 31 public:
32 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create")
33
32 SocketCreateFunction(); 34 SocketCreateFunction();
33 35
34 protected: 36 protected:
37 virtual ~SocketCreateFunction();
38
39 // AsyncIOAPIFunction:
35 virtual bool Prepare() OVERRIDE; 40 virtual bool Prepare() OVERRIDE;
36 virtual void Work() OVERRIDE; 41 virtual void Work() OVERRIDE;
37 virtual bool Respond() OVERRIDE; 42 virtual bool Respond() OVERRIDE;
38 43
39 private: 44 private:
40 enum SocketType { 45 enum SocketType {
41 kSocketTypeInvalid = -1, 46 kSocketTypeInvalid = -1,
42 kSocketTypeTCP, 47 kSocketTypeTCP,
43 kSocketTypeUDP 48 kSocketTypeUDP
44 }; 49 };
45 50
46 int src_id_; 51 int src_id_;
47 SocketType socket_type_; 52 SocketType socket_type_;
48 std::string address_; 53 std::string address_;
49 int port_; 54 int port_;
50 APIResourceEventNotifier* event_notifier_; 55 APIResourceEventNotifier* event_notifier_;
51
52 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create")
53 }; 56 };
54 57
55 class SocketDestroyFunction : public AsyncIOAPIFunction { 58 class SocketDestroyFunction : public AsyncIOAPIFunction {
59 public:
60 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.destroy")
61
56 protected: 62 protected:
63 virtual ~SocketDestroyFunction() {}
64
65 // AsyncIOAPIFunction:
57 virtual bool Prepare() OVERRIDE; 66 virtual bool Prepare() OVERRIDE;
58 virtual void Work() OVERRIDE; 67 virtual void Work() OVERRIDE;
59 virtual bool Respond() OVERRIDE; 68 virtual bool Respond() OVERRIDE;
60 69
61 private: 70 private:
62 int socket_id_; 71 int socket_id_;
63
64 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.destroy")
65 }; 72 };
66 73
67 class SocketConnectFunction : public AsyncIOAPIFunction { 74 class SocketConnectFunction : public AsyncIOAPIFunction {
75 public:
76 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
77
68 protected: 78 protected:
79 virtual ~SocketConnectFunction() {}
80
81 // AsyncIOAPIFunction:
69 virtual bool Prepare() OVERRIDE; 82 virtual bool Prepare() OVERRIDE;
70 virtual void Work() OVERRIDE; 83 virtual void Work() OVERRIDE;
71 virtual bool Respond() OVERRIDE; 84 virtual bool Respond() OVERRIDE;
72 85
73 private: 86 private:
74 int socket_id_; 87 int socket_id_;
75
76 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
77 }; 88 };
78 89
79 class SocketDisconnectFunction : public AsyncIOAPIFunction { 90 class SocketDisconnectFunction : public AsyncIOAPIFunction {
91 public:
92 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.disconnect")
93
80 protected: 94 protected:
95 virtual ~SocketDisconnectFunction() {}
96
97 // AsyncIOAPIFunction:
81 virtual bool Prepare() OVERRIDE; 98 virtual bool Prepare() OVERRIDE;
82 virtual void Work() OVERRIDE; 99 virtual void Work() OVERRIDE;
83 virtual bool Respond() OVERRIDE; 100 virtual bool Respond() OVERRIDE;
84 101
85 private: 102 private:
86 int socket_id_; 103 int socket_id_;
87
88 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.disconnect")
89 }; 104 };
90 105
91 class SocketReadFunction : public AsyncIOAPIFunction { 106 class SocketReadFunction : public AsyncIOAPIFunction {
107 public:
108 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.read")
109
92 protected: 110 protected:
111 virtual ~SocketReadFunction() {}
112
113 // AsyncIOAPIFunction:
93 virtual bool Prepare() OVERRIDE; 114 virtual bool Prepare() OVERRIDE;
94 virtual void Work() OVERRIDE; 115 virtual void Work() OVERRIDE;
95 virtual bool Respond() OVERRIDE; 116 virtual bool Respond() OVERRIDE;
96 117
97 private: 118 private:
98 int socket_id_; 119 int socket_id_;
99
100 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.read")
101 }; 120 };
102 121
103 class SocketWriteFunction : public AsyncIOAPIFunction { 122 class SocketWriteFunction : public AsyncIOAPIFunction {
104 public: 123 public:
124 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write")
125
105 SocketWriteFunction(); 126 SocketWriteFunction();
127
128 protected:
106 virtual ~SocketWriteFunction(); 129 virtual ~SocketWriteFunction();
107 130
108 protected: 131 // AsyncIOAPIFunction:
109 virtual bool Prepare() OVERRIDE; 132 virtual bool Prepare() OVERRIDE;
110 virtual void Work() OVERRIDE; 133 virtual void Work() OVERRIDE;
111 virtual bool Respond() OVERRIDE; 134 virtual bool Respond() OVERRIDE;
112 135
113 private: 136 private:
114 int socket_id_; 137 int socket_id_;
115 scoped_refptr<net::IOBufferWithSize> io_buffer_; 138 scoped_refptr<net::IOBufferWithSize> io_buffer_;
116
117 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write")
118 }; 139 };
119 140
120 } // namespace extensions 141 } // namespace extensions
121 142
122 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_ 143 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698