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

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

Issue 7792011: Run LocalizeStrings() on plugin thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pass localize_func as parameter. Created 9 years, 3 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
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/lock.h"
15 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
16 #include "base/string16.h" 17 #include "base/string16.h"
17 #include "base/threading/platform_thread.h" 18 #include "base/threading/platform_thread.h"
18 #include "base/time.h" 19 #include "base/time.h"
19 #include "remoting/base/plugin_message_loop_proxy.h" 20 #include "remoting/base/plugin_message_loop_proxy.h"
20 #include "remoting/host/chromoting_host_context.h" 21 #include "remoting/host/chromoting_host_context.h"
21 #include "remoting/host/host_status_observer.h" 22 #include "remoting/host/host_status_observer.h"
22 #include "remoting/host/plugin/host_plugin_utils.h" 23 #include "remoting/host/plugin/host_plugin_utils.h"
24 #include "remoting/host/ui_strings.h"
23 #include "third_party/npapi/bindings/npapi.h" 25 #include "third_party/npapi/bindings/npapi.h"
24 #include "third_party/npapi/bindings/npfunctions.h" 26 #include "third_party/npapi/bindings/npfunctions.h"
25 #include "third_party/npapi/bindings/npruntime.h" 27 #include "third_party/npapi/bindings/npruntime.h"
26 28
27 namespace tracked_objects { 29 namespace tracked_objects {
28 class Location; 30 class Location;
29 } // namespace tracked_objects 31 } // namespace tracked_objects
30 32
31 namespace remoting { 33 namespace remoting {
32 34
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 }; 97 };
96 98
97 // Start connection. args are: 99 // Start connection. args are:
98 // string uid, string auth_token 100 // string uid, string auth_token
99 // No result. 101 // No result.
100 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result); 102 bool Connect(const NPVariant* args, uint32_t argCount, NPVariant* result);
101 103
102 // Disconnect. No arguments or result. 104 // Disconnect. No arguments or result.
103 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result); 105 bool Disconnect(const NPVariant* args, uint32_t argCount, NPVariant* result);
104 106
107 // Localize strings. args are:
108 // localize_func - a callback function which returns a localized string for
109 // a given tag name.
110 // No result.
111 bool Localize(const NPVariant* args, uint32_t argCount, NPVariant* result);
112
105 // Call OnStateChanged handler if there is one. 113 // Call OnStateChanged handler if there is one.
106 void OnStateChanged(State state); 114 void OnStateChanged(State state);
107 115
108 // Call LogDebugInfo handler if there is one. 116 // Call LogDebugInfo handler if there is one.
109 void LogDebugInfo(const std::string& message); 117 void LogDebugInfo(const std::string& message);
110 118
111 // Callbacks invoked during session setup. 119 // Callbacks invoked during session setup.
112 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, 120 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier,
113 bool success, 121 bool success,
114 const std::string& support_id, 122 const std::string& support_id,
115 const base::TimeDelta& lifetime); 123 const base::TimeDelta& lifetime);
116 124
117 // Helper functions that run on main thread. Can be called on any 125 // Helper functions that run on main thread. Can be called on any
118 // other thread. 126 // other thread.
119 void ReadPolicyAndConnect(const std::string& uid, 127 void ReadPolicyAndConnect(const std::string& uid,
120 const std::string& auth_token, 128 const std::string& auth_token,
121 const std::string& auth_service); 129 const std::string& auth_service);
122 void FinishConnect(const std::string& uid, 130 void FinishConnect(const std::string& uid,
123 const std::string& auth_token, 131 const std::string& auth_token,
124 const std::string& auth_service); 132 const std::string& auth_service);
125 void DisconnectInternal(); 133 void DisconnectInternal();
126 134
127 // Callback for ChromotingHost::Shutdown(). 135 // Callback for ChromotingHost::Shutdown().
128 void OnShutdownFinished(); 136 void OnShutdownFinished();
129 137
130 // Called when the nat traversal policy is updated. 138 // Called when the nat traversal policy is updated.
131 void OnNatPolicyUpdate(bool nat_traversal_enabled); 139 void OnNatPolicyUpdate(bool nat_traversal_enabled);
132 140
133 void LocalizeStrings(); 141 void LocalizeStrings(ScopedRefNPObject *localize_func);
Jamie 2011/08/30 00:43:34 Not a big deal, but why not a const reference?
Sergey Ulanov 2011/08/30 00:53:08 Here and in other places: star is in a wrong place
Jamie 2011/08/30 00:57:55 That's a good point. With hindsight, NPObject* is
Lambros 2011/08/30 01:49:26 Done.
134 142
135 // Helper function for executing InvokeDefault on an NPObject that performs 143 // Helper function for executing InvokeDefault on an NPObject that performs
136 // a string->string mapping with one optional substitution parameter. Stores 144 // a string->string mapping with one optional substitution parameter. Stores
137 // the translation in |result| and returns true on success, or leaves it 145 // the translation in |result| and returns true on success, or leaves it
138 // unchanged and returns false on failure. 146 // unchanged and returns false on failure.
139 bool LocalizeString(const char* tag, string16* result); 147 bool LocalizeString(ScopedRefNPObject *localize_func, const char* tag,
148 string16* result);
140 149
141 // Helper function for executing InvokeDefault on an NPObject, and ignoring 150 // Helper function for executing InvokeDefault on an NPObject, and ignoring
142 // the return value. 151 // the return value.
143 bool InvokeAndIgnoreResult(NPObject* func, 152 bool InvokeAndIgnoreResult(NPObject* func,
144 const NPVariant* args, 153 const NPVariant* args,
145 uint32_t argCount); 154 uint32_t argCount);
146 155
147 // Set an exception for the current call. 156 // Set an exception for the current call.
148 void SetException(const std::string& exception_string); 157 void SetException(const std::string& exception_string);
149 158
150 NPP plugin_; 159 NPP plugin_;
151 NPObject* parent_; 160 NPObject* parent_;
152 int state_; 161 int state_;
153 std::string access_code_; 162 std::string access_code_;
154 std::string client_username_; 163 std::string client_username_;
155 base::TimeDelta access_code_lifetime_; 164 base::TimeDelta access_code_lifetime_;
156 ScopedRefNPObject localize_func_;
157 ScopedRefNPObject log_debug_info_func_; 165 ScopedRefNPObject log_debug_info_func_;
158 ScopedRefNPObject on_state_changed_func_; 166 ScopedRefNPObject on_state_changed_func_;
159 base::PlatformThreadId np_thread_id_; 167 base::PlatformThreadId np_thread_id_;
160 scoped_refptr<PluginMessageLoopProxy> plugin_message_loop_proxy_; 168 scoped_refptr<PluginMessageLoopProxy> plugin_message_loop_proxy_;
161 169
162 scoped_ptr<RegisterSupportHostRequest> register_request_; 170 scoped_ptr<RegisterSupportHostRequest> register_request_;
163 scoped_refptr<MutableHostConfig> host_config_; 171 scoped_refptr<MutableHostConfig> host_config_;
164 ChromotingHostContext host_context_; 172 ChromotingHostContext host_context_;
165 scoped_ptr<DesktopEnvironment> desktop_environment_; 173 scoped_ptr<DesktopEnvironment> desktop_environment_;
166 174
167 scoped_refptr<ChromotingHost> host_; 175 scoped_refptr<ChromotingHost> host_;
168 int failed_login_attempts_; 176 int failed_login_attempts_;
169 177
178 UiStrings ui_strings_;
179 base::Lock ui_strings_lock_;
180
170 base::WaitableEvent disconnected_event_; 181 base::WaitableEvent disconnected_event_;
171 182
172 scoped_ptr<policy_hack::NatPolicy> nat_policy_; 183 scoped_ptr<policy_hack::NatPolicy> nat_policy_;
173 184
174 // Host the current nat traversal policy setting. 185 // Host the current nat traversal policy setting.
175 bool nat_traversal_enabled_; 186 bool nat_traversal_enabled_;
176 187
177 // Indiciates whether or not a policy has ever been read. This is to ensure 188 // 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 189 // that on startup, we do not accidentally start a connection before we have
179 // queried our policy restrictions. 190 // queried our policy restrictions.
180 bool policy_received_; 191 bool policy_received_;
181 192
182 // On startup, it is possible to have Connect() called before the policy read 193 // 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 194 // 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 195 // it can be executed after at least one successful policy read. This
185 // variable contains the thunk if it is necessary. 196 // variable contains the thunk if it is necessary.
186 base::Closure pending_connect_; 197 base::Closure pending_connect_;
187 }; 198 };
188 199
189 } // namespace remoting 200 } // namespace remoting
190 201
191 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); 202 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject);
192 203
193 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ 204 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698