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

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: Removed ReportAckOrTimeout and ref-counting. Renamed MinimumHeartbeatSupporter to HostSignalingMan… Created 6 years 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/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.
36 // 2. Keep the host process alive while sending host-offline-reason heartbeat.
37 class HostSignalingManager {
Lambros 2014/12/16 02:14:05 Please update the CL description with the new clas
Łukasz Anforowicz 2014/12/17 18:02:04 Ooops. Done.
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 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,
46 const ChromotingHostContext& host_context,
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,
52 const std::string& oauth_refresh_token,
53 bool use_service_account);
54
55 ~HostSignalingManager();
56
57 // Gets signal strategy used for talking to the Chromoting bot.
58 // Return value is valid until |this| gets deleted.
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.
67 void SendHostOfflineReasonAndDelete(const std::string& host_offline_reason,
Lambros 2014/12/16 02:14:05 Won't you get double-deletion when the scoped_ptr
Łukasz Anforowicz 2014/12/17 18:02:04 The caller of Create takes ownership of the return
Lambros 2014/12/17 23:44:34 So the caller owns the object until it calls SendH
Łukasz Anforowicz 2014/12/18 00:03:41 I don't have a strong opinion here (with no recent
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.
81 // - |heartbeat_sender_| and |signaling_connector_| have to be destructed
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.
89 scoped_refptr<AutoThreadTaskRunner> network_task_runner_;
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_;
Lambros 2014/12/16 02:14:05 There's no ref-counting, so you don't need this.
Łukasz Anforowicz 2014/12/17 18:02:04 I do. I am calling "delete self_" in OnAckOrTimeo
Lambros 2014/12/17 23:44:34 Couldn't you do "delete this;" instead?
Łukasz Anforowicz 2014/12/18 00:03:41 Done.
98
99 DISALLOW_COPY_AND_ASSIGN(HostSignalingManager);
100 };
101
102 } // namespace remoting
103
104 #endif // REMOTING_HOST_HOST_SIGNALING_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698