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

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

Issue 7655006: Revert 97050 - Add PluginMessageLoopProxy and use it for Host plugin UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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/plugin/host_plugin.cc ('k') | remoting/host/plugin/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
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 REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ 5 #ifndef REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_
6 #define REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_ 6 #define REMOTING_HOST_PLUGIN_HOST_SCRIPT_OBJECT_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/synchronization/cancellation_flag.h" 14 #include "base/synchronization/cancellation_flag.h"
15 #include "base/synchronization/waitable_event.h" 15 #include "base/synchronization/waitable_event.h"
16 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "remoting/base/plugin_message_loop_proxy.h"
19 #include "remoting/host/chromoting_host_context.h" 18 #include "remoting/host/chromoting_host_context.h"
20 #include "remoting/host/host_status_observer.h" 19 #include "remoting/host/host_status_observer.h"
21 #include "remoting/host/plugin/host_plugin_utils.h" 20 #include "remoting/host/plugin/host_plugin_utils.h"
22 #include "third_party/npapi/bindings/npapi.h" 21 #include "third_party/npapi/bindings/npapi.h"
23 #include "third_party/npapi/bindings/npfunctions.h" 22 #include "third_party/npapi/bindings/npfunctions.h"
24 #include "third_party/npapi/bindings/npruntime.h" 23 #include "third_party/npapi/bindings/npruntime.h"
25 24
26 namespace tracked_objects { 25 namespace tracked_objects {
27 class Location; 26 class Location;
28 } // namespace tracked_objects 27 } // namespace tracked_objects
(...skipping 10 matching lines...) Expand all
39 namespace policy_hack { 38 namespace policy_hack {
40 class NatPolicy; 39 class NatPolicy;
41 } // namespace policy_hack 40 } // namespace policy_hack
42 41
43 // NPAPI plugin implementation for remoting host script object. 42 // NPAPI plugin implementation for remoting host script object.
44 // HostNPScriptObject creates threads that are required to run 43 // HostNPScriptObject creates threads that are required to run
45 // ChromotingHost and starts/stops the host on those threads. When 44 // ChromotingHost and starts/stops the host on those threads. When
46 // destroyed it sychronously shuts down the host and all threads. 45 // destroyed it sychronously shuts down the host and all threads.
47 class HostNPScriptObject : public HostStatusObserver { 46 class HostNPScriptObject : public HostStatusObserver {
48 public: 47 public:
49 HostNPScriptObject(NPP plugin, NPObject* parent, 48 HostNPScriptObject(NPP plugin, NPObject* parent);
50 PluginMessageLoopProxy::Delegate* plugin_thread_delegate);
51 virtual ~HostNPScriptObject(); 49 virtual ~HostNPScriptObject();
52 50
53 bool Init(); 51 bool Init();
54 52
55 bool HasMethod(const std::string& method_name); 53 bool HasMethod(const std::string& method_name);
56 bool InvokeDefault(const NPVariant* args, 54 bool InvokeDefault(const NPVariant* args,
57 uint32_t argCount, 55 uint32_t argCount,
58 NPVariant* result); 56 NPVariant* result);
59 bool Invoke(const std::string& method_name, 57 bool Invoke(const std::string& method_name,
60 const NPVariant* args, 58 const NPVariant* args,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // unchanged and returns false on failure. 135 // unchanged and returns false on failure.
138 bool LocalizeString(const char* tag, const char* substitution, 136 bool LocalizeString(const char* tag, const char* substitution,
139 std::string* result); 137 std::string* result);
140 138
141 // Helper function for executing InvokeDefault on an NPObject, and ignoring 139 // Helper function for executing InvokeDefault on an NPObject, and ignoring
142 // the return value. 140 // the return value.
143 bool InvokeAndIgnoreResult(NPObject* func, 141 bool InvokeAndIgnoreResult(NPObject* func,
144 const NPVariant* args, 142 const NPVariant* args,
145 uint32_t argCount); 143 uint32_t argCount);
146 144
145 // Posts a task on the main NP thread.
146 void PostTaskToNPThread(
147 const tracked_objects::Location& from_here, const base::Closure& task);
148
149 // Utility function for PostTaskToNPThread.
150 static void NPTaskSpringboard(void* task);
151
147 // Set an exception for the current call. 152 // Set an exception for the current call.
148 void SetException(const std::string& exception_string); 153 void SetException(const std::string& exception_string);
149 154
150 NPP plugin_; 155 NPP plugin_;
151 NPObject* parent_; 156 NPObject* parent_;
152 int state_; 157 int state_;
153 std::string access_code_; 158 std::string access_code_;
154 std::string client_username_; 159 std::string client_username_;
155 base::TimeDelta access_code_lifetime_; 160 base::TimeDelta access_code_lifetime_;
156 ScopedRefNPObject localize_func_; 161 ScopedRefNPObject localize_func_;
157 ScopedRefNPObject log_debug_info_func_; 162 ScopedRefNPObject log_debug_info_func_;
158 ScopedRefNPObject on_state_changed_func_; 163 ScopedRefNPObject on_state_changed_func_;
159 base::PlatformThreadId np_thread_id_; 164 base::PlatformThreadId np_thread_id_;
160 scoped_refptr<PluginMessageLoopProxy> plugin_message_loop_proxy_;
161 165
162 scoped_ptr<RegisterSupportHostRequest> register_request_; 166 scoped_ptr<RegisterSupportHostRequest> register_request_;
163 scoped_refptr<MutableHostConfig> host_config_; 167 scoped_refptr<MutableHostConfig> host_config_;
164 ChromotingHostContext host_context_; 168 ChromotingHostContext host_context_;
165 scoped_ptr<DesktopEnvironment> desktop_environment_; 169 scoped_ptr<DesktopEnvironment> desktop_environment_;
166 170
167 scoped_refptr<ChromotingHost> host_; 171 scoped_refptr<ChromotingHost> host_;
168 int failed_login_attempts_; 172 int failed_login_attempts_;
169 173
170 base::WaitableEvent disconnected_event_; 174 base::WaitableEvent disconnected_event_;
175 base::CancellationFlag destructing_;
171 176
172 scoped_ptr<policy_hack::NatPolicy> nat_policy_; 177 scoped_ptr<policy_hack::NatPolicy> nat_policy_;
173 178
174 // Host the current nat traversal policy setting. 179 // Host the current nat traversal policy setting.
175 bool nat_traversal_enabled_; 180 bool nat_traversal_enabled_;
176 181
177 // Indiciates whether or not a policy has ever been read. This is to ensure 182 // Indiciates whether or not a policy has ever been read. This is to ensure
178 // that on startup, we do not accidentally start a connection before we have 183 // that on startup, we do not accidentally start a connection before we have
179 // queried our policy restrictions. 184 // queried our policy restrictions.
180 bool policy_received_; 185 bool policy_received_;
181 186
182 // On startup, it is possible to have Connect() called before the policy read 187 // On startup, it is possible to have Connect() called before the policy read
183 // is completed. Rather than just failing, we thunk the connection call so 188 // is completed. Rather than just failing, we thunk the connection call so
184 // it can be executed after at least one successful policy read. This 189 // it can be executed after at least one successful policy read. This
185 // variable contains the thunk if it is necessary. 190 // variable contains the thunk if it is necessary.
186 base::Closure pending_connect_; 191 base::Closure pending_connect_;
187 }; 192 };
188 193
189 } // namespace remoting 194 } // namespace remoting
190 195
191 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); 196 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject);
192 197
193 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ 198 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_
OLDNEW
« no previous file with comments | « remoting/host/plugin/host_plugin.cc ('k') | remoting/host/plugin/host_script_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698