| 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_IMPL_H_ | 5 #ifndef REMOTING_HOST_IT2ME__IT2ME_HOST_H_ |
| 6 #define REMOTING_HOST_IT2ME__IT2ME_IMPL_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/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "remoting/host/log_to_server.h" | 11 #include "remoting/host/log_to_server.h" |
| 12 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 12 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| 13 | 13 |
| 14 namespace remoting { | 14 namespace remoting { |
| 15 | 15 |
| 16 class RegisterSupportHostRequest; | 16 class RegisterSupportHostRequest; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 33 kStarting, | 33 kStarting, |
| 34 kRequestedAccessCode, | 34 kRequestedAccessCode, |
| 35 kReceivedAccessCode, | 35 kReceivedAccessCode, |
| 36 kConnected, | 36 kConnected, |
| 37 kDisconnecting, | 37 kDisconnecting, |
| 38 kError, | 38 kError, |
| 39 kInvalidDomainError | 39 kInvalidDomainError |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 // Internal implementation of the plugin's It2Me host function. | 42 // Internal implementation of the plugin's It2Me host function. |
| 43 class It2MeImpl | 43 class It2MeHost |
| 44 : public base::RefCountedThreadSafe<It2MeImpl>, | 44 : public base::RefCountedThreadSafe<It2MeHost>, |
| 45 public HostStatusObserver { | 45 public HostStatusObserver { |
| 46 public: | 46 public: |
| 47 | 47 |
| 48 class Observer { | 48 class Observer { |
| 49 public: | 49 public: |
| 50 virtual void OnClientAuthenticated(const std::string& client_username) = 0; | 50 virtual void OnClientAuthenticated(const std::string& client_username) = 0; |
| 51 virtual void OnStoreAccessCode(const std::string& access_code, | 51 virtual void OnStoreAccessCode(const std::string& access_code, |
| 52 base::TimeDelta access_code_lifetime) = 0; | 52 base::TimeDelta access_code_lifetime) = 0; |
| 53 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) = 0; | 53 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) = 0; |
| 54 virtual void OnStateChanged(It2MeHostState state) = 0; | 54 virtual void OnStateChanged(It2MeHostState state) = 0; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 It2MeImpl( | 57 It2MeHost( |
| 58 scoped_ptr<ChromotingHostContext> context, | 58 scoped_ptr<ChromotingHostContext> context, |
| 59 scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner, | 59 scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner, |
| 60 base::WeakPtr<It2MeImpl::Observer> observer, | 60 base::WeakPtr<It2MeHost::Observer> observer, |
| 61 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | 61 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, |
| 62 const std::string& directory_bot_jid); | 62 const std::string& directory_bot_jid); |
| 63 | 63 |
| 64 // Methods called by the script object, from the plugin thread. | 64 // Methods called by the script object, from the plugin thread. |
| 65 | 65 |
| 66 // Creates It2Me host structures and starts the host. | 66 // Creates It2Me host structures and starts the host. |
| 67 void Connect(); | 67 void Connect(); |
| 68 | 68 |
| 69 // Disconnects the host, ready for tear-down. | 69 // Disconnects the host, ready for tear-down. |
| 70 // Also called internally, from the network thread. | 70 // Also called internally, from the network thread. |
| 71 void Disconnect(); | 71 void Disconnect(); |
| 72 | 72 |
| 73 // Request a NAT policy notification. | 73 // Request a NAT policy notification. |
| 74 void RequestNatPolicy(); | 74 void RequestNatPolicy(); |
| 75 | 75 |
| 76 // remoting::HostStatusObserver implementation. | 76 // remoting::HostStatusObserver implementation. |
| 77 virtual void OnAccessDenied(const std::string& jid) OVERRIDE; | 77 virtual void OnAccessDenied(const std::string& jid) OVERRIDE; |
| 78 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; | 78 virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE; |
| 79 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; | 79 virtual void OnClientDisconnected(const std::string& jid) OVERRIDE; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 friend class base::RefCountedThreadSafe<It2MeImpl>; | 82 friend class base::RefCountedThreadSafe<It2MeHost>; |
| 83 | 83 |
| 84 virtual ~It2MeImpl(); | 84 virtual ~It2MeHost(); |
| 85 | 85 |
| 86 // Updates state of the host. Can be called only on the network thread. | 86 // Updates state of the host. Can be called only on the network thread. |
| 87 void SetState(It2MeHostState state); | 87 void SetState(It2MeHostState state); |
| 88 | 88 |
| 89 // Returns true if the host is connected. | 89 // Returns true if the host is connected. |
| 90 bool IsConnected() const; | 90 bool IsConnected() const; |
| 91 | 91 |
| 92 // Called by Connect() to check for policies and start connection process. | 92 // Called by Connect() to check for policies and start connection process. |
| 93 void ReadPolicyAndConnect(); | 93 void ReadPolicyAndConnect(); |
| 94 | 94 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 111 // Called when initial policies are read, and when they change. | 111 // Called when initial policies are read, and when they change. |
| 112 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); | 112 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); |
| 113 | 113 |
| 114 // Handlers for NAT traversal and host domain policies. | 114 // Handlers for NAT traversal and host domain policies. |
| 115 void UpdateNatPolicy(bool nat_traversal_enabled); | 115 void UpdateNatPolicy(bool nat_traversal_enabled); |
| 116 void UpdateHostDomainPolicy(const std::string& host_domain); | 116 void UpdateHostDomainPolicy(const std::string& host_domain); |
| 117 | 117 |
| 118 // Caller supplied fields. | 118 // Caller supplied fields. |
| 119 scoped_ptr<ChromotingHostContext> host_context_; | 119 scoped_ptr<ChromotingHostContext> host_context_; |
| 120 scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_; | 120 scoped_refptr<base::SingleThreadTaskRunner> plugin_task_runner_; |
| 121 base::WeakPtr<It2MeImpl::Observer> observer_; | 121 base::WeakPtr<It2MeHost::Observer> observer_; |
| 122 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | 122 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; |
| 123 std::string directory_bot_jid_; | 123 std::string directory_bot_jid_; |
| 124 | 124 |
| 125 It2MeHostState state_; | 125 It2MeHostState state_; |
| 126 | 126 |
| 127 scoped_refptr<RsaKeyPair> host_key_pair_; | 127 scoped_refptr<RsaKeyPair> host_key_pair_; |
| 128 scoped_ptr<SignalStrategy> signal_strategy_; | 128 scoped_ptr<SignalStrategy> signal_strategy_; |
| 129 scoped_ptr<RegisterSupportHostRequest> register_request_; | 129 scoped_ptr<RegisterSupportHostRequest> register_request_; |
| 130 scoped_ptr<LogToServer> log_to_server_; | 130 scoped_ptr<LogToServer> log_to_server_; |
| 131 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; | 131 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 146 // that on startup, we do not accidentally start a connection before we have | 146 // that on startup, we do not accidentally start a connection before we have |
| 147 // queried our policy restrictions. | 147 // queried our policy restrictions. |
| 148 bool policy_received_; | 148 bool policy_received_; |
| 149 | 149 |
| 150 // On startup, it is possible to have Connect() called before the policy read | 150 // On startup, it is possible to have Connect() called before the policy read |
| 151 // is completed. Rather than just failing, we thunk the connection call so | 151 // is completed. Rather than just failing, we thunk the connection call so |
| 152 // it can be executed after at least one successful policy read. This | 152 // it can be executed after at least one successful policy read. This |
| 153 // variable contains the thunk if it is necessary. | 153 // variable contains the thunk if it is necessary. |
| 154 base::Closure pending_connect_; | 154 base::Closure pending_connect_; |
| 155 | 155 |
| 156 DISALLOW_COPY_AND_ASSIGN(It2MeImpl); | 156 DISALLOW_COPY_AND_ASSIGN(It2MeHost); |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 } // namespace remoting | 159 } // namespace remoting |
| 160 | 160 |
| 161 #endif // REMOTING_HOST_IT2ME__IT2ME_IMPL_H_ | 161 #endif // REMOTING_HOST_IT2ME__IT2ME_HOST_H_ |
| OLD | NEW |