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

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

Issue 8743017: Real (but naive) UDP socket sending. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial. 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_SOCKET_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SOCKET_API_H_
Aaron Boodman 2011/12/02 06:06:12 I have been trying to figure out what to do with A
miket_OOO 2011/12/02 21:06:36 Done!
6 #define CHROME_BROWSER_EXTENSIONS_SOCKET_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SOCKET_API_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/extensions/extension_function.h" 9 #include "chrome/browser/extensions/extension_function.h"
10 10
11 #include <string>
12
11 namespace extensions { 13 namespace extensions {
12 14
15 // Many of these socket functions are synchronous in the sense that
16 // they don't involve blocking operations, but we've made them all
17 // AsyncExtensionFunctions because the underlying UDPClientSocket
18 // library wants all operations to happen on the same thread as the
19 // one that created the socket. Too bad.
20
13 class SocketCreateFunction : public AsyncExtensionFunction { 21 class SocketCreateFunction : public AsyncExtensionFunction {
14 public: 22 public:
15 SocketCreateFunction(); 23 SocketCreateFunction() {}
Mihai Parparita -not on Chrome 2011/12/01 23:39:32 The style guide strongly discourages inline constr
miket_OOO 2011/12/02 21:06:36 Fixed.
16 virtual ~SocketCreateFunction(); 24 virtual ~SocketCreateFunction() {}
17 virtual bool RunImpl() OVERRIDE; 25 virtual bool RunImpl() OVERRIDE;
18 26
19 protected: 27 protected:
20 void WorkOnIOThread(); 28 void WorkOnIOThread();
21 void RespondOnUIThread(); 29 void RespondOnUIThread();
22 30
23 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create") 31 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.create")
24 }; 32 };
25 33
26 class SocketConnectFunction : public AsyncExtensionFunction { 34 class SocketDestroyFunction : public AsyncExtensionFunction {
27 public: 35 public:
28 SocketConnectFunction(); 36 SocketDestroyFunction() {}
29 virtual ~SocketConnectFunction(); 37 virtual ~SocketDestroyFunction() {}
30 virtual bool RunImpl() OVERRIDE; 38 virtual bool RunImpl() OVERRIDE;
31 39
32 protected: 40 protected:
33 void WorkOnIOThread(); 41 void WorkOnIOThread();
34 void RespondOnUIThread(); 42 void RespondOnUIThread();
35 43
36 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect") 44 private:
45 int socket_id_;
46
47 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.destroy")
37 }; 48 };
38 49
39 class SocketDisconnectFunction : public AsyncExtensionFunction { 50 class SocketConnectFunction : public AsyncExtensionFunction {
40 public: 51 public:
41 SocketDisconnectFunction(); 52 SocketConnectFunction() {}
42 virtual ~SocketDisconnectFunction(); 53 virtual ~SocketConnectFunction() {}
43 virtual bool RunImpl() OVERRIDE; 54 virtual bool RunImpl() OVERRIDE;
44 55
45 protected: 56 protected:
46 void WorkOnIOThread(); 57 void WorkOnIOThread();
47 void RespondOnUIThread(); 58 void RespondOnUIThread();
48 59
49 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.disconnect") 60 private:
61 int socket_id_;
62 std::string address_;
63 int port_;
64
65 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.connect")
50 }; 66 };
51 67
52 class SocketSendFunction : public AsyncExtensionFunction { 68 class SocketCloseFunction : public AsyncExtensionFunction {
53 public: 69 public:
54 SocketSendFunction(); 70 SocketCloseFunction() {}
55 virtual ~SocketSendFunction(); 71 virtual ~SocketCloseFunction() {}
56 virtual bool RunImpl() OVERRIDE; 72 virtual bool RunImpl() OVERRIDE;
57 73
58 protected: 74 protected:
59 void WorkOnIOThread(); 75 void WorkOnIOThread();
60 void RespondOnUIThread(); 76 void RespondOnUIThread();
61 77
62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.send") 78 private:
79 int socket_id_;
80
81 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.close")
82 };
83
84 class SocketWriteFunction : public AsyncExtensionFunction {
85 public:
86 SocketWriteFunction() {}
87 virtual ~SocketWriteFunction() {}
88 virtual bool RunImpl() OVERRIDE;
89
90 protected:
91 void WorkOnIOThread();
92 void RespondOnUIThread();
93
94 int socket_id_;
95 std::string message_;
96
97 DECLARE_EXTENSION_FUNCTION_NAME("experimental.socket.write")
63 }; 98 };
64 99
65 } // namespace extensions 100 } // namespace extensions
66 101
67 #endif // CHROME_BROWSER_EXTENSIONS_SOCKET_API_H_ 102 #endif // CHROME_BROWSER_EXTENSIONS_SOCKET_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698