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

Side by Side Diff: remoting/host/host_signaling_manager.h

Issue 719983002: Reporting of policy errors via host-offline-reason: part 3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hor-nohoststatussender
Patch Set: Rebasing... Created 5 years, 11 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
(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/oauth_token_getter.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 Chromoting Directory.
36 // 2. Keep the host process alive while sending host-offline-reason heartbeat.
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.
42 //
43 // |on_heartbeat_successful_callback| is invoked after the first successful
44 // heartbeat.
45 //
46 // |on_heartbeat_successful_callback| is invoked when the host ID is
47 // permanently not recognized by the server.
48 //
49 // |on_auth_failed_callback| is invoked when authentication fails.
50 //
51 // |directory_bot_jid| is typically equal to "remoting@bot.talk.google.com".
52 static scoped_ptr<HostSignalingManager> Create(
53 const base::Closure& on_heartbeat_successful_callback,
54 const base::Closure& on_unknown_host_id_error_callback,
55 const base::Closure& on_auth_failed_callback,
Wez 2015/01/09 02:55:45 See earlier comments re interface
Łukasz Anforowicz 2015/01/09 19:00:14 Acknowledged.
56 const scoped_refptr<AutoThreadTaskRunner>& network_task_runner,
57 const scoped_refptr<net::URLRequestContextGetter>&
58 url_request_context_getter,
59 const XmppSignalStrategy::XmppServerConfig& xmpp_server_config,
60 const std::string& talkgadget_prefix_policy,
61 const std::string& host_id,
62 const scoped_refptr<const RsaKeyPair>& host_key_pair,
63 const std::string& directory_bot_jid,
64 scoped_ptr<OAuthTokenGetter::OAuthCredentials> oauth_credentials);
65
66 ~HostSignalingManager();
67
68 // Get the SignalStrategy to use for talking to the Chromoting bot.
69 // Returned SignalStrategy remains owned by the HostSignalingManager.
70 SignalStrategy* signal_strategy() { return signal_strategy_.get(); }
71
72 // Kicks off sending a heartbeat containing a host-offline-reason attribute.
73 //
74 // Will delete |this| once either the bot acks receiving the
75 // |host_offline_reason|, or the |timeout| is reached. Deleting
76 // |this| will release |network_task_runner_| and allow the host
77 // process to exit.
78 void SendHostOfflineReasonAndDelete(const std::string& host_offline_reason,
79 const base::TimeDelta& timeout);
80
81 private:
82 HostSignalingManager(
83 const scoped_refptr<AutoThreadTaskRunner>& network_task_runner,
84 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier,
85 scoped_ptr<SignalStrategy> signal_strategy,
86 scoped_ptr<SignalingConnector> signaling_connector,
87 scoped_ptr<HeartbeatSender> heartbeat_sender);
88
89 void OnHostOfflineReasonAck(bool success);
90
91 // Order of fields below is important for destroying them in the right order.
92 // - |heartbeat_sender_| and |signaling_connector_| have to be destroyed
93 // before |signal_strategy_| because their destructors need to call
94 // signal_strategy_->RemoveListener(this)
95 // - |signaling_connector_| has to be destroyed before
96 // |network_change_notifier_| because its destructor needs to deregister
97 // network change notifications
98 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
Wez 2015/01/09 02:55:45 I thought you were going to document that this was
Łukasz Anforowicz 2015/01/09 19:00:13 Done.
99 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
100 scoped_ptr<SignalStrategy> signal_strategy_;
101 scoped_ptr<SignalingConnector> signaling_connector_;
102 scoped_ptr<HeartbeatSender> heartbeat_sender_;
103
104 DISALLOW_COPY_AND_ASSIGN(HostSignalingManager);
105 };
106
107 } // namespace remoting
108
109 #endif // REMOTING_HOST_HOST_SIGNALING_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698