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 the host, ready for tear-down. |
Lambros
2015/11/23 22:44:48
Disconnects and shuts down the host?
Sergey Ulanov
2015/11/23 22:59:44
Done.
| |
78 // Also called internally, from the network thread. | 77 // Also called internally, from the network thread. |
Lambros
2015/11/23 22:44:48
Remove this comment, now that it's only called fro
Sergey Ulanov
2015/11/23 22:59:44
removed this line.
| |
79 virtual void Disconnect(); | 78 virtual void Disconnect(); |
80 | 79 |
81 // TODO (weitaosu): Remove RequestNatPolicy from It2MeHost. | 80 // TODO (weitaosu): Remove RequestNatPolicy from It2MeHost. |
82 // Request a NAT policy notification. | 81 // Request a NAT policy notification. |
83 virtual void RequestNatPolicy(); | 82 virtual void RequestNatPolicy(); |
84 | 83 |
85 // remoting::HostStatusObserver implementation. | 84 // remoting::HostStatusObserver implementation. |
86 void OnAccessDenied(const std::string& jid) override; | 85 void OnAccessDenied(const std::string& jid) override; |
87 void OnClientAuthenticated(const std::string& jid) override; | 86 void OnClientConnected(const std::string& jid) override; |
88 void OnClientDisconnected(const std::string& jid) override; | 87 void OnClientDisconnected(const std::string& jid) override; |
89 | 88 |
90 void SetStateForTesting(It2MeHostState state, | 89 void SetStateForTesting(It2MeHostState state, |
91 const std::string& error_message) { | 90 const std::string& error_message) { |
92 SetState(state, error_message); | 91 SetState(state, error_message); |
93 } | 92 } |
94 | 93 |
95 protected: | 94 protected: |
96 friend class base::RefCountedThreadSafe<It2MeHost>; | 95 friend class base::RefCountedThreadSafe<It2MeHost>; |
97 | 96 |
(...skipping 23 matching lines...) Expand all Loading... | |
121 void ReadPolicyAndConnect(); | 120 void ReadPolicyAndConnect(); |
122 | 121 |
123 // Called by ReadPolicyAndConnect once policies have been read. | 122 // Called by ReadPolicyAndConnect once policies have been read. |
124 void FinishConnect(); | 123 void FinishConnect(); |
125 | 124 |
126 // Called when the support host registration completes. | 125 // Called when the support host registration completes. |
127 void OnReceivedSupportID(const std::string& support_id, | 126 void OnReceivedSupportID(const std::string& support_id, |
128 const base::TimeDelta& lifetime, | 127 const base::TimeDelta& lifetime, |
129 const std::string& error_message); | 128 const std::string& error_message); |
130 | 129 |
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. | 130 // Called when initial policies are read, and when they change. |
140 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); | 131 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); |
141 | 132 |
142 // Called when malformed policies are detected. | 133 // Called when malformed policies are detected. |
143 void OnPolicyError(); | 134 void OnPolicyError(); |
144 | 135 |
145 // Handlers for NAT traversal and host domain policies. | 136 // Handlers for NAT traversal and host domain policies. |
146 void UpdateNatPolicy(bool nat_traversal_enabled); | 137 void UpdateNatPolicy(bool nat_traversal_enabled); |
147 void UpdateHostDomainPolicy(const std::string& host_domain); | 138 void UpdateHostDomainPolicy(const std::string& host_domain); |
148 | 139 |
140 void Shutdown(); | |
141 | |
149 // Caller supplied fields. | 142 // Caller supplied fields. |
150 scoped_ptr<ChromotingHostContext> host_context_; | 143 scoped_ptr<ChromotingHostContext> host_context_; |
151 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 144 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
152 base::WeakPtr<It2MeHost::Observer> observer_; | 145 base::WeakPtr<It2MeHost::Observer> observer_; |
153 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | 146 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; |
154 std::string directory_bot_jid_; | 147 std::string directory_bot_jid_; |
155 | 148 |
156 It2MeHostState state_; | 149 It2MeHostState state_; |
157 | 150 |
158 scoped_refptr<RsaKeyPair> host_key_pair_; | 151 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); | 203 const std::string& directory_bot_jid); |
211 | 204 |
212 private: | 205 private: |
213 policy::PolicyService* policy_service_; | 206 policy::PolicyService* policy_service_; |
214 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); | 207 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); |
215 }; | 208 }; |
216 | 209 |
217 } // namespace remoting | 210 } // namespace remoting |
218 | 211 |
219 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 212 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
OLD | NEW |