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

Side by Side Diff: remoting/host/it2me/it2me_host.h

Issue 639233002: Remote assistance on Chrome OS Part IV - It2MeHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 class Observer { 53 class Observer {
54 public: 54 public:
55 virtual void OnClientAuthenticated(const std::string& client_username) = 0; 55 virtual void OnClientAuthenticated(const std::string& client_username) = 0;
56 virtual void OnStoreAccessCode(const std::string& access_code, 56 virtual void OnStoreAccessCode(const std::string& access_code,
57 base::TimeDelta access_code_lifetime) = 0; 57 base::TimeDelta access_code_lifetime) = 0;
58 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) = 0; 58 virtual void OnNatPolicyChanged(bool nat_traversal_enabled) = 0;
59 virtual void OnStateChanged(It2MeHostState state) = 0; 59 virtual void OnStateChanged(It2MeHostState state) = 0;
60 }; 60 };
61 61
62 It2MeHost( 62 It2MeHost(
63 ChromotingHostContext* context, 63 scoped_refptr<ChromotingHostContext> context,
64 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 64 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
65 base::WeakPtr<It2MeHost::Observer> observer, 65 base::WeakPtr<It2MeHost::Observer> observer,
66 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, 66 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config,
67 const std::string& directory_bot_jid); 67 const std::string& directory_bot_jid);
68 68
69 // Methods called by the script object, from the plugin thread. 69 // Methods called by the script object, from the plugin thread.
70 70
71 // Creates It2Me host structures and starts the host. 71 // Creates It2Me host structures and starts the host.
72 virtual void Connect(); 72 virtual void Connect();
73 73
(...skipping 10 matching lines...) Expand all
84 virtual void OnClientAuthenticated(const std::string& jid) override; 84 virtual void OnClientAuthenticated(const std::string& jid) override;
85 virtual void OnClientDisconnected(const std::string& jid) override; 85 virtual void OnClientDisconnected(const std::string& jid) override;
86 86
87 void SetStateForTesting(It2MeHostState state) { SetState(state); } 87 void SetStateForTesting(It2MeHostState state) { SetState(state); }
88 88
89 protected: 89 protected:
90 friend class base::RefCountedThreadSafe<It2MeHost>; 90 friend class base::RefCountedThreadSafe<It2MeHost>;
91 91
92 virtual ~It2MeHost(); 92 virtual ~It2MeHost();
93 93
94 ChromotingHostContext* host_context() { return host_context_; } 94 ChromotingHostContext* host_context() { return host_context_.get(); }
95 scoped_refptr<base::SingleThreadTaskRunner> task_runner() { 95 scoped_refptr<base::SingleThreadTaskRunner> task_runner() {
96 return task_runner_; 96 return task_runner_;
97 } 97 }
98 base::WeakPtr<It2MeHost::Observer> observer() { return observer_; } 98 base::WeakPtr<It2MeHost::Observer> observer() { return observer_; }
99 99
100 private: 100 private:
101 // Updates state of the host. Can be called only on the network thread. 101 // Updates state of the host. Can be called only on the network thread.
102 void SetState(It2MeHostState state); 102 void SetState(It2MeHostState state);
103 103
104 // Returns true if the host is connected. 104 // Returns true if the host is connected.
(...skipping 11 matching lines...) Expand all
116 const base::TimeDelta& lifetime); 116 const base::TimeDelta& lifetime);
117 117
118 // Shuts down |host_| on the network thread and posts ShutdownOnUiThread() 118 // Shuts down |host_| on the network thread and posts ShutdownOnUiThread()
119 // to shut down UI thread resources. 119 // to shut down UI thread resources.
120 void ShutdownOnNetworkThread(); 120 void ShutdownOnNetworkThread();
121 121
122 // Shuts down |desktop_environment_factory_| and |policy_watcher_| on 122 // Shuts down |desktop_environment_factory_| and |policy_watcher_| on
123 // the UI thread. 123 // the UI thread.
124 void ShutdownOnUiThread(); 124 void ShutdownOnUiThread();
125 125
126 // Called when |policy_watcher_| has stopped listening for changes so that it
127 // safe to delete the |policy_watcher_| object.
128 void OnPolicyWatcherShutdown();
129
126 // Called when initial policies are read, and when they change. 130 // Called when initial policies are read, and when they change.
127 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies); 131 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies);
128 132
129 // Handlers for NAT traversal and host domain policies. 133 // Handlers for NAT traversal and host domain policies.
130 void UpdateNatPolicy(bool nat_traversal_enabled); 134 void UpdateNatPolicy(bool nat_traversal_enabled);
131 void UpdateHostDomainPolicy(const std::string& host_domain); 135 void UpdateHostDomainPolicy(const std::string& host_domain);
132 136
133 // Caller supplied fields. 137 // Caller supplied fields.
134 138
135 // The creator of the It2MeHost object owns the the host context and is 139 // The creator of the It2MeHost object owns the the host context and is
136 // responsible for keeping it alive throughout the liftime of the host. 140 // responsible for keeping it alive throughout the liftime of the host.
137 ChromotingHostContext* host_context_; 141 scoped_refptr<ChromotingHostContext> host_context_;
138 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 142 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
139 base::WeakPtr<It2MeHost::Observer> observer_; 143 base::WeakPtr<It2MeHost::Observer> observer_;
140 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; 144 XmppSignalStrategy::XmppServerConfig xmpp_server_config_;
141 std::string directory_bot_jid_; 145 std::string directory_bot_jid_;
142 146
143 It2MeHostState state_; 147 It2MeHostState state_;
144 148
145 scoped_refptr<RsaKeyPair> host_key_pair_; 149 scoped_refptr<RsaKeyPair> host_key_pair_;
146 scoped_ptr<SignalStrategy> signal_strategy_; 150 scoped_ptr<SignalStrategy> signal_strategy_;
147 scoped_ptr<RegisterSupportHostRequest> register_request_; 151 scoped_ptr<RegisterSupportHostRequest> register_request_;
(...skipping 27 matching lines...) Expand all
175 }; 179 };
176 180
177 // Having a factory interface makes it possible for the test to provide a mock 181 // Having a factory interface makes it possible for the test to provide a mock
178 // implementation of the It2MeHost. 182 // implementation of the It2MeHost.
179 class It2MeHostFactory { 183 class It2MeHostFactory {
180 public: 184 public:
181 It2MeHostFactory(); 185 It2MeHostFactory();
182 virtual ~It2MeHostFactory(); 186 virtual ~It2MeHostFactory();
183 187
184 virtual scoped_refptr<It2MeHost> CreateIt2MeHost( 188 virtual scoped_refptr<It2MeHost> CreateIt2MeHost(
185 ChromotingHostContext* context, 189 scoped_refptr<ChromotingHostContext> context,
186 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 190 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
187 base::WeakPtr<It2MeHost::Observer> observer, 191 base::WeakPtr<It2MeHost::Observer> observer,
188 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, 192 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config,
189 const std::string& directory_bot_jid); 193 const std::string& directory_bot_jid);
190 194
191 private: 195 private:
192 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); 196 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory);
193 }; 197 };
194 198
195 } // namespace remoting 199 } // namespace remoting
196 200
197 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ 201 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698