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

Side by Side Diff: remoting/client/plugin/chromoting_scriptable_object.h

Issue 8573024: Clean up client state callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 1 month 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
« no previous file with comments | « no previous file | remoting/client/plugin/chromoting_scriptable_object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This implements the JavaScript class entrypoint for the plugin instance. 5 // This implements the JavaScript class entrypoint for the plugin instance.
6 // The Javascript API is defined as follows. 6 // The Javascript API is defined as follows.
7 // 7 //
8 // interface ChromotingScriptableObject { 8 // interface ChromotingScriptableObject {
9 // 9 //
10 // // Chromoting session API version (for this plugin). 10 // // Chromoting session API version (for this plugin).
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 namespace remoting { 114 namespace remoting {
115 115
116 class ChromotingInstance; 116 class ChromotingInstance;
117 class PepperXmppProxy; 117 class PepperXmppProxy;
118 118
119 class ChromotingScriptableObject 119 class ChromotingScriptableObject
120 : public pp::deprecated::ScriptableObject, 120 : public pp::deprecated::ScriptableObject,
121 public base::SupportsWeakPtr<ChromotingScriptableObject> { 121 public base::SupportsWeakPtr<ChromotingScriptableObject> {
122 public: 122 public:
123 // These state values are duplicated in the JS code. Remember to update both
124 // copies when making changes.
123 enum ConnectionStatus { 125 enum ConnectionStatus {
126 // TODO(jamiewalch): Remove STATUS_UNKNOWN once all web-apps that might try
127 // to access it have been upgraded.
124 STATUS_UNKNOWN = 0, 128 STATUS_UNKNOWN = 0,
125 STATUS_CONNECTING, 129 STATUS_CONNECTING,
126 STATUS_INITIALIZING, 130 STATUS_INITIALIZING,
127 STATUS_CONNECTED, 131 STATUS_CONNECTED,
128 STATUS_CLOSED, 132 STATUS_CLOSED,
129 STATUS_FAILED, 133 STATUS_FAILED,
130 }; 134 };
131 135
136 // These state values are duplicated in the JS code. Remember to update both
137 // copies when making changes.
132 enum ConnectionError { 138 enum ConnectionError {
133 ERROR_NONE = 0, 139 ERROR_NONE = 0,
134 ERROR_HOST_IS_OFFLINE, 140 ERROR_HOST_IS_OFFLINE,
135 ERROR_SESSION_REJECTED, 141 ERROR_SESSION_REJECTED,
136 ERROR_INCOMPATIBLE_PROTOCOL, 142 ERROR_INCOMPATIBLE_PROTOCOL,
137 ERROR_NETWORK_FAILURE, 143 ERROR_NETWORK_FAILURE,
138 }; 144 };
139 145
140 ChromotingScriptableObject( 146 ChromotingScriptableObject(
141 ChromotingInstance* instance, 147 ChromotingInstance* instance,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 196
191 std::string name; 197 std::string name;
192 pp::Var attribute; 198 pp::Var attribute;
193 MethodHandler method; 199 MethodHandler method;
194 }; 200 };
195 201
196 // Routines to add new attribute, method properties. 202 // Routines to add new attribute, method properties.
197 void AddAttribute(const std::string& name, pp::Var attribute); 203 void AddAttribute(const std::string& name, pp::Var attribute);
198 void AddMethod(const std::string& name, MethodHandler handler); 204 void AddMethod(const std::string& name, MethodHandler handler);
199 205
200 void SignalConnectionInfoChange(); 206 void SignalConnectionInfoChange(int status, int error);
201 void SignalDesktopSizeChange(); 207 void SignalDesktopSizeChange();
202 208
203 // Calls to these methods are posted to the plugin thread so that we 209 // Calls to these methods are posted to the plugin thread so that we
204 // call JavaScript with clean stack. This is necessary because 210 // call JavaScript with clean stack. This is necessary because
205 // JavaScript event handlers may destroy the plugin. 211 // JavaScript event handlers may destroy the plugin.
206 void DoSignalConnectionInfoChange(); 212 void DoSignalConnectionInfoChange(int status, int error);
207 void DoSignalDesktopSizeChange(); 213 void DoSignalDesktopSizeChange();
208 void DoSendIq(const std::string& message_xml); 214 void DoSendIq(const std::string& message_xml);
209 215
210 pp::Var DoConnect(const std::vector<pp::Var>& args, pp::Var* exception); 216 pp::Var DoConnect(const std::vector<pp::Var>& args, pp::Var* exception);
211 pp::Var DoDisconnect(const std::vector<pp::Var>& args, pp::Var* exception); 217 pp::Var DoDisconnect(const std::vector<pp::Var>& args, pp::Var* exception);
212 218
213 // This method is called by JS to set scale-to-fit. 219 // This method is called by JS to set scale-to-fit.
214 pp::Var DoSetScaleToFit(const std::vector<pp::Var>& args, pp::Var* exception); 220 pp::Var DoSetScaleToFit(const std::vector<pp::Var>& args, pp::Var* exception);
215 221
216 // This method is called by Javascript to provide responses to sendIq() 222 // This method is called by Javascript to provide responses to sendIq()
(...skipping 13 matching lines...) Expand all
230 236
231 scoped_refptr<base::MessageLoopProxy> plugin_message_loop_; 237 scoped_refptr<base::MessageLoopProxy> plugin_message_loop_;
232 ScopedRunnableMethodFactory<ChromotingScriptableObject> task_factory_; 238 ScopedRunnableMethodFactory<ChromotingScriptableObject> task_factory_;
233 239
234 DISALLOW_COPY_AND_ASSIGN(ChromotingScriptableObject); 240 DISALLOW_COPY_AND_ASSIGN(ChromotingScriptableObject);
235 }; 241 };
236 242
237 } // namespace remoting 243 } // namespace remoting
238 244
239 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ 245 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/client/plugin/chromoting_scriptable_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698