OLD | NEW |
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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 namespace remoting { | 28 namespace remoting { |
29 | 29 |
30 class ChromotingHost; | 30 class ChromotingHost; |
31 class DesktopEnvironment; | 31 class DesktopEnvironment; |
32 class MutableHostConfig; | 32 class MutableHostConfig; |
33 class RegisterSupportHostRequest; | 33 class RegisterSupportHostRequest; |
34 class SignalStrategy; | 34 class SignalStrategy; |
35 class SupportAccessVerifier; | 35 class SupportAccessVerifier; |
36 | 36 |
| 37 namespace policy_hack { |
| 38 class NatPolicy; |
| 39 } // namespace policy_hack |
| 40 |
37 // NPAPI plugin implementation for remoting host script object. | 41 // NPAPI plugin implementation for remoting host script object. |
38 // HostNPScriptObject creates threads that are required to run | 42 // HostNPScriptObject creates threads that are required to run |
39 // ChromotingHost and starts/stops the host on those threads. When | 43 // ChromotingHost and starts/stops the host on those threads. When |
40 // destroyed it sychronously shuts down the host and all threads. | 44 // destroyed it sychronously shuts down the host and all threads. |
41 class HostNPScriptObject : public HostStatusObserver { | 45 class HostNPScriptObject : public HostStatusObserver { |
42 public: | 46 public: |
43 HostNPScriptObject(NPP plugin, NPObject* parent); | 47 HostNPScriptObject(NPP plugin, NPObject* parent); |
44 virtual ~HostNPScriptObject(); | 48 virtual ~HostNPScriptObject(); |
45 | 49 |
46 bool Init(); | 50 bool Init(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, | 107 void OnReceivedSupportID(remoting::SupportAccessVerifier* access_verifier, |
104 bool success, | 108 bool success, |
105 const std::string& support_id, | 109 const std::string& support_id, |
106 const base::TimeDelta& lifetime); | 110 const base::TimeDelta& lifetime); |
107 | 111 |
108 // Helper functions that run on main thread. Can be called on any | 112 // Helper functions that run on main thread. Can be called on any |
109 // other thread. | 113 // other thread. |
110 void ConnectInternal(const std::string& uid, | 114 void ConnectInternal(const std::string& uid, |
111 const std::string& auth_token, | 115 const std::string& auth_token, |
112 const std::string& auth_service); | 116 const std::string& auth_service); |
| 117 void ReadPolicyAndConnect(const std::string& uid, |
| 118 const std::string& auth_token, |
| 119 const std::string& auth_service); |
| 120 void InitNatPolicy(); |
113 void DisconnectInternal(); | 121 void DisconnectInternal(); |
114 | 122 |
115 // Callback for ChromotingHost::Shutdown(). | 123 // Callback for ChromotingHost::Shutdown(). |
116 void OnShutdownFinished(); | 124 void OnShutdownFinished(); |
117 | 125 |
| 126 // Called when the nat traversal policy is updated. |
| 127 void OnNatPolicyUpdate(bool nat_traversal_enabled); |
| 128 |
118 // Helper function for executing InvokeDefault on an NPObject, and ignoring | 129 // Helper function for executing InvokeDefault on an NPObject, and ignoring |
119 // the return value. | 130 // the return value. |
120 bool InvokeAndIgnoreResult(NPObject* func, | 131 bool InvokeAndIgnoreResult(NPObject* func, |
121 const NPVariant* args, | 132 const NPVariant* args, |
122 uint32_t argCount); | 133 uint32_t argCount); |
123 | 134 |
124 // Posts a task on the main NP thread. | 135 // Posts a task on the main NP thread. |
125 void PostTaskToNPThread( | 136 void PostTaskToNPThread( |
126 const tracked_objects::Location& from_here, const base::Closure& task); | 137 const tracked_objects::Location& from_here, const base::Closure& task); |
127 | 138 |
(...skipping 16 matching lines...) Expand all Loading... |
144 scoped_ptr<RegisterSupportHostRequest> register_request_; | 155 scoped_ptr<RegisterSupportHostRequest> register_request_; |
145 scoped_refptr<MutableHostConfig> host_config_; | 156 scoped_refptr<MutableHostConfig> host_config_; |
146 ChromotingHostContext host_context_; | 157 ChromotingHostContext host_context_; |
147 scoped_ptr<DesktopEnvironment> desktop_environment_; | 158 scoped_ptr<DesktopEnvironment> desktop_environment_; |
148 | 159 |
149 scoped_refptr<ChromotingHost> host_; | 160 scoped_refptr<ChromotingHost> host_; |
150 int failed_login_attempts_; | 161 int failed_login_attempts_; |
151 | 162 |
152 base::WaitableEvent disconnected_event_; | 163 base::WaitableEvent disconnected_event_; |
153 base::CancellationFlag destructing_; | 164 base::CancellationFlag destructing_; |
| 165 |
| 166 // This object must always be created/deleted on the network thread. |
| 167 policy_hack::NatPolicy* nat_policy_; |
| 168 |
| 169 bool nat_traversal_enabled_; |
| 170 bool policy_received_; |
| 171 base::Closure pending_connect_; |
154 }; | 172 }; |
155 | 173 |
156 } // namespace remoting | 174 } // namespace remoting |
157 | 175 |
158 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); | 176 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::HostNPScriptObject); |
159 | 177 |
160 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ | 178 #endif // REMOTING_HOST_HOST_SCRIPT_OBJECT_H_ |
OLD | NEW |