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

Side by Side Diff: remoting/host/host_script_object.h

Issue 7216018: Move the Remoting Host plugin into its own sub-directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix missed path in remoting.gyp. Created 9 years, 6 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
« no previous file with comments | « remoting/host/host_plugin_utils.cc ('k') | remoting/host/host_script_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
(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 REMOTING_HOST_HOST_SCRIPT_OBJECT_H_
6 #define REMOTING_HOST_HOST_SCRIPT_OBJECT_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/synchronization/cancellation_flag.h"
15 #include "base/synchronization/waitable_event.h"
16 #include "base/threading/platform_thread.h"
17 #include "remoting/host/chromoting_host_context.h"
18 #include "remoting/host/host_status_observer.h"
19 #include "third_party/npapi/bindings/npapi.h"
20 #include "third_party/npapi/bindings/npfunctions.h"
21 #include "third_party/npapi/bindings/npruntime.h"
22
23 class Task;
24
25 namespace tracked_objects {
26 class Location;
27 } // namespace tracked_objects
28
29 namespace remoting {
30
31 class ChromotingHost;
32 class MutableHostConfig;
33 class RegisterSupportHostRequest;
34 class SignalStrategy;
35 class SupportAccessVerifier;
36
37 // NPAPI plugin implementation for remoting host script object.
38 // HostNPScriptObject creates threads that are required to run
39 // ChromotingHost and starts/stops the host on those threads. When
40 // destroyed it sychronously shuts down the host and all threads.
41 class HostNPScriptObject : public HostStatusObserver {
42 public:
43 HostNPScriptObject(NPP plugin, NPObject* parent);
44 virtual ~HostNPScriptObject();
45
46 bool Init();
47
48 bool HasMethod(const std::string& method_name);
49 bool InvokeDefault(const NPVariant* args,
50 uint32_t argCount,
51 NPVariant* result);
52 bool Invoke(const std::string& method_name,
53 const NPVariant* args,
54 uint32_t argCount,
55 NPVariant* result);
56 bool HasProperty(const std::string& property_name);
57 bool GetProperty(const std::string& property_name, NPVariant* result);
58 bool SetProperty(const std::string& property_name, const NPVariant* value);
59 bool RemoveProperty(const std::string& property_name);
60 bool Enumerate(std::vector<std::string>* values);
61
62 // remoting::HostStatusObserver implementation.
63 virtual void OnSignallingConnected(remoting::SignalStrategy* signal_strategy,
64 const std::string& full_jid) OVERRIDE;
65 virtual void OnSignallingDisconnected() OVERRIDE;
66 virtual void OnAccessDenied() OVERRIDE;
67 virtual void OnAuthenticatedClientsChanged(int clients_connected) OVERRIDE;
68 virtual void OnShutdown() OVERRIDE;
69
70 private:
71 enum State {
72 kDisconnected,
73 kRequestedAccessCode,
74 kReceivedAccessCode,
75 kConnected,
76 kAffirmingConnection,
77 kError
78 };
79
80 // Start connection. args are:
81 // string uid, string auth_token
82 // No result.
83 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result);
84
85 // Disconnect. No arguments or result.
86 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result);
87
88 // Call LogDebugInfo handler if there is one.
89 void LogDebugInfo(const std::string& message);
90
91 // Call OnStateChanged handler if there is one.
92 void OnStateChanged(State state);
93
94 // Callbacks invoked during session setup.
95 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier,
96 bool success,
97 const std::string& support_id);
98
99 // Helper functions that run on main thread. Can be called on any
100 // other thread.
101 void ConnectInternal(const std::string& uid,
102 const std::string& auth_token,
103 const std::string& auth_service);
104 void DisconnectInternal();
105
106 // Callback for ChromotingHost::Shutdown().
107 void OnShutdownFinished();
108
109 // Call a JavaScript function wrapped as an NPObject.
110 // If result is non-null, the result of the call will be stored in it.
111 // Caller is responsible for releasing result if they ask for it.
112 static bool CallJSFunction(NPObject* func,
113 const NPVariant* args,
114 uint32_t argCount,
115 NPVariant* result);
116
117 // Posts a task on the main NP thread.
118 void PostTaskToNPThread(const tracked_objects::Location& from_here,
119 Task* task);
120
121 // Utility function for PostTaskToNPThread.
122 static void NPTaskSpringboard(void* task);
123
124 // Set an exception for the current call.
125 void SetException(const std::string& exception_string);
126
127 NPP plugin_;
128 NPObject* parent_;
129 int state_;
130 std::string access_code_;
131 NPObject* log_debug_info_func_;
132 NPObject* on_state_changed_func_;
133 base::PlatformThreadId np_thread_id_;
134
135 scoped_ptr<RegisterSupportHostRequest> register_request_;
136 scoped_refptr<ChromotingHost> host_;
137 scoped_refptr<MutableHostConfig> host_config_;
138 ChromotingHostContext host_context_;
139 int failed_login_attempts_;
140
141 base::WaitableEvent disconnected_event_;
142 base::CancellationFlag destructing_;
143 };
144
145 } // namespace remoting
146
147 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject);
148
149 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_
OLDNEW
« no previous file with comments | « remoting/host/host_plugin_utils.cc ('k') | remoting/host/host_script_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698