OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_IT2ME_IT2ME_HOST_H_ | 5 #ifndef REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
6 #define REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 6 #define REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 class RsaKeyPair; | 35 class RsaKeyPair; |
36 | 36 |
37 // These state values are duplicated in host_session.js. Remember to update | 37 // These state values are duplicated in host_session.js. Remember to update |
38 // both copies when making changes. | 38 // both copies when making changes. |
39 enum It2MeHostState { | 39 enum It2MeHostState { |
40 kDisconnected, | 40 kDisconnected, |
41 kStarting, | 41 kStarting, |
42 kRequestedAccessCode, | 42 kRequestedAccessCode, |
43 kReceivedAccessCode, | 43 kReceivedAccessCode, |
44 kConnected, | 44 kConnected, |
45 kDisconnecting, | |
46 kError, | 45 kError, |
47 kInvalidDomainError | 46 kInvalidDomainError |
48 }; | 47 }; |
49 | 48 |
50 // Internal implementation of the plugin's It2Me host function. | 49 // Internal implementation of the plugin's It2Me host function. |
51 class It2MeHost : public base::RefCountedThreadSafe<It2MeHost>, | 50 class It2MeHost : public base::RefCountedThreadSafe<It2MeHost>, |
52 public HostStatusObserver { | 51 public HostStatusObserver { |
53 public: | 52 public: |
54 class Observer { | 53 class Observer { |
55 public: | 54 public: |
(...skipping 11 matching lines...) Expand all Loading... |
67 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory, | 66 scoped_ptr<It2MeConfirmationDialogFactory> confirmation_dialog_factory, |
68 base::WeakPtr<It2MeHost::Observer> observer, | 67 base::WeakPtr<It2MeHost::Observer> observer, |
69 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 68 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
70 const std::string& directory_bot_jid); | 69 const std::string& directory_bot_jid); |
71 | 70 |
72 // Methods called by the script object, from the plugin thread. | 71 // Methods called by the script object, from the plugin thread. |
73 | 72 |
74 // Creates It2Me host structures and starts the host. | 73 // Creates It2Me host structures and starts the host. |
75 virtual void Connect(); | 74 virtual void Connect(); |
76 | 75 |
77 // Disconnects the host, ready for tear-down. | 76 // Disconnects and shuts down the host. |
78 // Also called internally, from the network thread. | |
79 virtual void Disconnect(); | 77 virtual void Disconnect(); |
80 | 78 |
81 // TODO (weitaosu): Remove RequestNatPolicy from It2MeHost. | 79 // TODO (weitaosu): Remove RequestNatPolicy from It2MeHost. |
82 // Request a NAT policy notification. | 80 // Request a NAT policy notification. |
83 virtual void RequestNatPolicy(); | 81 virtual void RequestNatPolicy(); |
84 | 82 |
85 // remoting::HostStatusObserver implementation. | 83 // remoting::HostStatusObserver implementation. |
86 void OnAccessDenied(const std::string& jid) override; | 84 void OnAccessDenied(const std::string& jid) override; |
87 void OnClientAuthenticated(const std::string& jid) override; | 85 void OnClientConnected(const std::string& jid) override; |
88 void OnClientDisconnected(const std::string& jid) override; | 86 void OnClientDisconnected(const std::string& jid) override; |
89 | 87 |
90 void SetStateForTesting(It2MeHostState state, | 88 void SetStateForTesting(It2MeHostState state, |
91 const std::string& error_message) { | 89 const std::string& error_message) { |
92 SetState(state, error_message); | 90 SetState(state, error_message); |
93 } | 91 } |
94 | 92 |
95 protected: | 93 protected: |
96 friend class base::RefCountedThreadSafe<It2MeHost>; | 94 friend class base::RefCountedThreadSafe<It2MeHost>; |
97 | 95 |
(...skipping 23 matching lines...) Expand all Loading... |
121 void ReadPolicyAndConnect(); | 119 void ReadPolicyAndConnect(); |
122 | 120 |
123 // Called by ReadPolicyAndConnect once policies have been read. | 121 // Called by ReadPolicyAndConnect once policies have been read. |
124 void FinishConnect(); | 122 void FinishConnect(); |
125 | 123 |
126 // Called when the support host registration completes. | 124 // Called when the support host registration completes. |
127 void OnReceivedSupportID(const std::string& support_id, | 125 void OnReceivedSupportID(const std::string& support_id, |
128 const base::TimeDelta& lifetime, | 126 const base::TimeDelta& lifetime, |
129 const std::string& error_message); | 127 const std::string& error_message); |
130 | 128 |
131 // Shuts down |host_| on the network thread and posts ShutdownOnUiThread() | |
132 // to shut down UI thread resources. | |
133 void ShutdownOnNetworkThread(); | |
134 | |
135 // Shuts down |desktop_environment_factory_| and |policy_watcher_| on | |
136 // the UI thread. | |
137 void ShutdownOnUiThread(); | |
138 | |
139 // Called when initial policies are read, and when they change. | 129 // Called when initial policies are read, and when they change. |
140 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); | 130 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); |
141 | 131 |
142 // Called when malformed policies are detected. | 132 // Called when malformed policies are detected. |
143 void OnPolicyError(); | 133 void OnPolicyError(); |
144 | 134 |
145 // Handlers for NAT traversal and host domain policies. | 135 // Handlers for NAT traversal and host domain policies. |
146 void UpdateNatPolicy(bool nat_traversal_enabled); | 136 void UpdateNatPolicy(bool nat_traversal_enabled); |
147 void UpdateHostDomainPolicy(const std::string& host_domain); | 137 void UpdateHostDomainPolicy(const std::string& host_domain); |
148 | 138 |
| 139 void Shutdown(); |
| 140 |
149 // Caller supplied fields. | 141 // Caller supplied fields. |
150 scoped_ptr<ChromotingHostContext> host_context_; | 142 scoped_ptr<ChromotingHostContext> host_context_; |
151 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 143 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
152 base::WeakPtr<It2MeHost::Observer> observer_; | 144 base::WeakPtr<It2MeHost::Observer> observer_; |
153 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | 145 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; |
154 std::string directory_bot_jid_; | 146 std::string directory_bot_jid_; |
155 | 147 |
156 It2MeHostState state_; | 148 It2MeHostState state_; |
157 | 149 |
158 scoped_refptr<RsaKeyPair> host_key_pair_; | 150 scoped_refptr<RsaKeyPair> host_key_pair_; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 const std::string& directory_bot_jid); | 202 const std::string& directory_bot_jid); |
211 | 203 |
212 private: | 204 private: |
213 policy::PolicyService* policy_service_; | 205 policy::PolicyService* policy_service_; |
214 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); | 206 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); |
215 }; | 207 }; |
216 | 208 |
217 } // namespace remoting | 209 } // namespace remoting |
218 | 210 |
219 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 211 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
OLD | NEW |