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

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

Issue 8743017: Real (but naive) UDP socket sending. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Post-try-server fixes. Created 9 years 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
7 #pragma once
8
9 #include "chrome/browser/extensions/extension_function.h"
10
11 #include <string>
12
13 namespace extensions {
14
15 extern const char kBytesWrittenKey[];
16 extern const char kSocketIdKey[];
17 extern const char kUdpSocketType[];
18
19 // Many of these socket functions are synchronous in the sense that
20 // they don't involve blocking operations, but we've made them all
21 // AsyncExtensionFunctions because the underlying UDPClientSocket
22 // library wants all operations to happen on the same thread as the
23 // one that created the socket. Too bad.
24
25 class SocketCreateFunction : public AsyncExtensionFunction {
26 public:
27 SocketCreateFunction();
28 virtual ~SocketCreateFunction();
29 virtual bool RunImpl() OVERRIDE;
30
31 protected:
32 void WorkOnIOThread();
33 void RespondOnUIThread();
34
35 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create")
36 };
37
38 class SocketDestroyFunction : public AsyncExtensionFunction {
39 public:
40 SocketDestroyFunction();
41 virtual ~SocketDestroyFunction();
42 virtual bool RunImpl() OVERRIDE;
43
44 protected:
45 void WorkOnIOThread();
46 void RespondOnUIThread();
47
48 private:
49 int socket_id_;
50
51 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.destroy")
52 };
53
54 class SocketConnectFunction : public AsyncExtensionFunction {
55 public:
56 SocketConnectFunction();
57 virtual ~SocketConnectFunction();
58 virtual bool RunImpl() OVERRIDE;
59
60 protected:
61 void WorkOnIOThread();
62 void RespondOnUIThread();
63
64 private:
65 int socket_id_;
66 std::string address_;
67 int port_;
68
69 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
70 };
71
72 class SocketCloseFunction : public AsyncExtensionFunction {
73 public:
74 SocketCloseFunction();
75 virtual ~SocketCloseFunction();
76 virtual bool RunImpl() OVERRIDE;
77
78 protected:
79 void WorkOnIOThread();
80 void RespondOnUIThread();
81
82 private:
83 int socket_id_;
84
85 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.close")
86 };
87
88 class SocketWriteFunction : public AsyncExtensionFunction {
89 public:
90 SocketWriteFunction();
91 virtual ~SocketWriteFunction();
92 virtual bool RunImpl() OVERRIDE;
93
94 protected:
95 void WorkOnIOThread();
96 void RespondOnUIThread();
97
98 int socket_id_;
99 std::string message_;
100
101 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write")
102 };
103
104 } // namespace extensions
105
106 #endif // CHROME_BROWSER_EXTENSIONS_API_SOCKET_SOCKET_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698