Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef REMOTING_HOST_HOST_SIGNALING_MANAGER_H_ | |
| 6 #define REMOTING_HOST_HOST_SIGNALING_MANAGER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "remoting/base/auto_thread_task_runner.h" | |
| 13 #include "remoting/base/rsa_key_pair.h" | |
| 14 #include "remoting/host/heartbeat_sender.h" | |
| 15 #include "remoting/signaling/xmpp_signal_strategy.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class TimeDelta; | |
| 19 } | |
| 20 | |
| 21 namespace net { | |
| 22 class NetworkChangeNotifier; | |
| 23 } | |
| 24 | |
| 25 namespace remoting { | |
| 26 | |
| 27 class ChromotingHostContext; | |
| 28 class DnsBlackholeChecker; | |
| 29 class HeartbeatSender; | |
| 30 class OAuthTokenGetter; | |
| 31 class SignalStrategy; | |
| 32 class SignalingConnector; | |
| 33 | |
| 34 // HostSignalingManager has 2 functions: | |
| 35 // 1. Keep sending regular heartbeats to the service. | |
|
Wez
2014/12/18 00:46:22
You mean to the Chromoting Directory, I think?
Łukasz Anforowicz
2014/12/18 19:02:33
To Talk, Chromoting Directory and Chromoting Bot.
Wez
2014/12/19 22:05:37
We only send the heartbeat to the directory - it j
Łukasz Anforowicz
2015/01/07 01:24:04
Got it - done (s/service/Chromoting Directory/).
| |
| 36 // 2. Keep the host process alive while sending host-offline-reason heartbeat. | |
|
Wez
2014/12/18 00:46:22
nit: The second function is to make a best-effort
Łukasz Anforowicz
2014/12/18 19:02:34
I think I'll leave it as-is. The ref-counting tri
Wez
2014/12/19 22:05:37
Acknowledged.
| |
| 37 class HostSignalingManager { | |
| 38 public: | |
| 39 // TODO(lukasza): Refactor to limit the number of parameters below. | |
| 40 // Probably necessitates refactoring HostProcess to extract a new | |
| 41 // class to read and store config/policy/cmdline values. | |
|
Wez
2014/12/18 00:46:21
The parameters need documenting.
Łukasz Anforowicz
2014/12/18 19:02:34
I documented some of the parameters.
I didn't d
Wez
2014/12/19 22:05:37
Please document the paremeters in the Create() met
Łukasz Anforowicz
2015/01/07 01:24:04
Done.
| |
| 42 static scoped_ptr<HostSignalingManager> Create( | |
| 43 const base::Closure& on_heartbeat_successful_callback, | |
| 44 const base::Closure& on_unknown_host_id_error_callback, | |
| 45 const base::Closure& on_auth_failed_callback, | |
|
Wez
2014/12/18 00:46:21
As previously commented, these should be combined
Łukasz Anforowicz
2014/12/18 19:02:34
Nooooo. As I pointed out earlier, this results in
Wez
2014/12/19 22:05:37
I disagree; the callback-based implementation has
Łukasz Anforowicz
2015/01/07 01:24:04
I think the lifetime semantics are cleaner with ca
Wez
2015/01/09 02:55:45
Not really; it becomes a perfectly straightforward
Łukasz Anforowicz
2015/01/09 19:00:13
Ok.
| |
| 46 const ChromotingHostContext& host_context, | |
|
Wez
2014/12/18 00:46:21
Ick... do you really need this? The ChromotingHost
Łukasz Anforowicz
2014/12/18 19:02:34
I think it is ok / not icky...
1. HostSignalingMan
Wez
2014/12/19 22:05:37
HostProcess is a special-case in that it is an imp
Łukasz Anforowicz
2015/01/07 01:24:04
Done.
| |
| 47 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config, | |
| 48 const std::string& talkgadget_prefix, | |
| 49 const std::string& host_id, | |
| 50 const scoped_refptr<const RsaKeyPair>& key_pair, | |
| 51 const std::string& directory_bot_jid, | |
|
Wez
2014/12/18 00:46:21
what's this?
Łukasz Anforowicz
2014/12/18 19:02:34
It's a JID to use when talking to Directory Bot.
Wez
2014/12/19 22:05:37
Right; the question is not _what_ is the parameter
Łukasz Anforowicz
2015/01/07 01:24:04
Got it. As Feynman says (https://www.youtube.com/
| |
| 52 const std::string& oauth_refresh_token, | |
| 53 bool use_service_account); | |
|
Wez
2014/12/18 00:46:21
What does "use_service_account" mean?
Łukasz Anforowicz
2014/12/18 19:02:34
I don't know - I am just moving an already working
Wez
2014/12/19 22:05:37
Yeah, that parameter is super badly documented; yo
Łukasz Anforowicz
2015/01/07 01:24:04
I've added the comment you suggested to the constr
| |
| 54 | |
| 55 ~HostSignalingManager(); | |
| 56 | |
| 57 // Gets signal strategy used for talking to the Chromoting bot. | |
|
Wez
2014/12/18 00:46:22
"Get the SignalStrategy to use to talk to..."
Łukasz Anforowicz
2014/12/18 19:02:34
Done.
| |
| 58 // Return value is valid until |this| gets deleted. | |
|
Wez
2014/12/18 00:46:21
nit: Suggest: "The SignalStrategy remains owned by
Łukasz Anforowicz
2014/12/18 19:02:34
Done.
| |
| 59 SignalStrategy* signal_strategy() { return signal_strategy_.get(); } | |
| 60 | |
| 61 // Kicks off sending a heartbeat containing a host-offline-reason attribute. | |
| 62 // | |
| 63 // Will delete |this| once either the bot acks receiving the | |
| 64 // |host_offline_reason|, or the |timeout| is reached. Deleting | |
| 65 // |this| will release |network_task_runner_| and allow the host | |
| 66 // process to exit. | |
|
Wez
2014/12/18 00:46:21
You don't need the sentence re the task-runner.
T
Łukasz Anforowicz
2014/12/18 19:02:34
...
Wez
2014/12/19 22:05:37
Acknowledged.
| |
| 67 void SendHostOfflineReasonAndDelete(const std::string& host_offline_reason, | |
| 68 const base::TimeDelta& timeout); | |
| 69 | |
| 70 private: | |
| 71 HostSignalingManager( | |
| 72 scoped_refptr<AutoThreadTaskRunner> network_task_runner, | |
| 73 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier, | |
| 74 scoped_ptr<SignalStrategy> signal_strategy, | |
| 75 scoped_ptr<SignalingConnector> signaling_connector, | |
| 76 scoped_ptr<HeartbeatSender> heartbeat_sender); | |
| 77 | |
| 78 void OnAckOrTimeout(HeartbeatSender::AckOrTimeout ack_or_timeout); | |
| 79 | |
| 80 // Order of fields below is important for destructing them in the right order. | |
|
Wez
2014/12/18 00:46:21
That cannot be true of |network_task_runner_|, so
Łukasz Anforowicz
2014/12/18 19:02:34
Arrrrgh... I had the teardown done explicitly in t
| |
| 81 // - |heartbeat_sender_| and |signaling_connector_| have to be destructed | |
|
Wez
2014/12/18 00:46:22
s/destructed/destroyed/
Łukasz Anforowicz
2014/12/18 19:02:34
Done.
| |
| 82 // before |signal_strategy_| because their destructors need to call | |
| 83 // signal_strategy_->RemoveListener(this) | |
| 84 // - |signaling_connector_| has to be destructed before | |
| 85 // |network_change_notifier_| because its destructor needs to deregister | |
| 86 // network change notifications | |
| 87 // - |network_task_runner_| is used by all the other fields and has to be | |
| 88 // destructed last. | |
|
Wez
2014/12/18 00:46:21
This comment doesn't make sense, since all you're
Łukasz Anforowicz
2014/12/18 19:02:34
Dropping a ref-count to network_task_runner will d
Wez
2014/12/19 22:05:37
That case should be safe - the AutoThreadTaskRunne
Łukasz Anforowicz
2015/01/07 01:24:04
Okay, I think I get it - dropping the reference wi
Wez
2015/01/09 02:55:45
Yes; sounds like we could have explained that more
Łukasz Anforowicz
2015/01/09 19:00:13
Acknowledged.
| |
| 89 scoped_refptr<AutoThreadTaskRunner> network_task_runner_; | |
|
Wez
2014/12/18 00:46:21
You need to clarify what this task-runner is used
Łukasz Anforowicz
2014/12/18 19:02:34
This field keeps the process alive. I've added a
| |
| 90 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | |
| 91 scoped_ptr<SignalStrategy> signal_strategy_; | |
| 92 scoped_ptr<SignalingConnector> signaling_connector_; | |
| 93 scoped_ptr<HeartbeatSender> heartbeat_sender_; | |
| 94 | |
| 95 // HostSignalingManager object owns itself via |self_| field while | |
| 96 // SendHostOfflineReasonAndDelete is waiting for an ack or timeout. | |
| 97 HostSignalingManager* self_; | |
|
Wez
2014/12/18 00:46:21
This is a bare pointer so it doesn't have any effe
Łukasz Anforowicz
2014/12/18 19:02:34
Yes, I don't know what I was thinking... :-(
Wez
2014/12/19 22:05:37
Yeah, we all have code-review moments like that. :
Łukasz Anforowicz
2015/01/07 01:24:04
Acknowledged.
| |
| 98 | |
| 99 DISALLOW_COPY_AND_ASSIGN(HostSignalingManager); | |
| 100 }; | |
| 101 | |
| 102 } // namespace remoting | |
| 103 | |
| 104 #endif // REMOTING_HOST_HOST_SIGNALING_MANAGER_H_ | |
| OLD | NEW |