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

Side by Side Diff: remoting/host/heartbeat_sender.cc

Issue 9301026: Virtual Me2Me Host: Exit process if Host ID is invalid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "remoting/host/heartbeat_sender.h" 5 #include "remoting/host/heartbeat_sender.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 10 matching lines...) Expand all
21 21
22 namespace remoting { 22 namespace remoting {
23 23
24 namespace { 24 namespace {
25 25
26 const char kHeartbeatQueryTag[] = "heartbeat"; 26 const char kHeartbeatQueryTag[] = "heartbeat";
27 const char kHostIdAttr[] = "hostid"; 27 const char kHostIdAttr[] = "hostid";
28 const char kHeartbeatSignatureTag[] = "signature"; 28 const char kHeartbeatSignatureTag[] = "signature";
29 const char kSignatureTimeAttr[] = "time"; 29 const char kSignatureTimeAttr[] = "time";
30 30
31 const char kErrorTag[] = "error";
32 const char kNotFoundTag[] = "item-not-found";
33
31 const char kHeartbeatResultTag[] = "heartbeat-result"; 34 const char kHeartbeatResultTag[] = "heartbeat-result";
32 const char kSetIntervalTag[] = "set-interval"; 35 const char kSetIntervalTag[] = "set-interval";
33 36
34 const int64 kDefaultHeartbeatIntervalMs = 5 * 60 * 1000; // 5 minutes. 37 const int64 kDefaultHeartbeatIntervalMs = 5 * 60 * 1000; // 5 minutes.
35 38
36 } // namespace 39 } // namespace
37 40
38 HeartbeatSender::HeartbeatSender( 41 HeartbeatSender::HeartbeatSender(
39 const std::string& host_id, 42 const std::string& host_id,
40 SignalStrategy* signal_strategy, 43 SignalStrategy* signal_strategy,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 VLOG(1) << "Sending heartbeat stanza to " << kChromotingBotJid; 76 VLOG(1) << "Sending heartbeat stanza to " << kChromotingBotJid;
74 request_.reset(iq_sender_->SendIq( 77 request_.reset(iq_sender_->SendIq(
75 buzz::STR_SET, kChromotingBotJid, CreateHeartbeatMessage(), 78 buzz::STR_SET, kChromotingBotJid, CreateHeartbeatMessage(),
76 base::Bind(&HeartbeatSender::ProcessResponse, 79 base::Bind(&HeartbeatSender::ProcessResponse,
77 base::Unretained(this)))); 80 base::Unretained(this))));
78 } 81 }
79 82
80 void HeartbeatSender::ProcessResponse(const XmlElement* response) { 83 void HeartbeatSender::ProcessResponse(const XmlElement* response) {
81 std::string type = response->Attr(buzz::QN_TYPE); 84 std::string type = response->Attr(buzz::QN_TYPE);
82 if (type == buzz::STR_ERROR) { 85 if (type == buzz::STR_ERROR) {
86 const XmlElement* error_element =
87 response->FirstNamed(QName(buzz::NS_CLIENT, kErrorTag));
88 if (error_element) {
89 if (error_element->FirstNamed(QName(buzz::NS_STANZA, kNotFoundTag))) {
Sergey Ulanov 2012/01/31 23:21:41 nit: maybe roll these two if statements together,
90 // TODO(lambroslambrou): Trigger an application-defined callback to
91 // shut down the host properly, instead of just exiting here
92 // (http://crbug.com/112160).
93 LOG(ERROR) << "Received error: Host ID invalid";
94 exit(1);
95 }
96 }
97
83 LOG(ERROR) << "Received error in response to heartbeat: " 98 LOG(ERROR) << "Received error in response to heartbeat: "
84 << response->Str(); 99 << response->Str();
85 return; 100 return;
86 } 101 }
87 102
88 // This method must only be called for error or result stanzas. 103 // This method must only be called for error or result stanzas.
89 DCHECK_EQ(std::string(buzz::STR_RESULT), type); 104 DCHECK_EQ(std::string(buzz::STR_RESULT), type);
90 105
91 const XmlElement* result_element = 106 const XmlElement* result_element =
92 response->FirstNamed(QName(kChromotingXmlNamespace, kHeartbeatResultTag)); 107 response->FirstNamed(QName(kChromotingXmlNamespace, kHeartbeatResultTag));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str); 153 QName(kChromotingXmlNamespace, kSignatureTimeAttr), time_str);
139 154
140 std::string message = signal_strategy_->GetLocalJid() + ' ' + time_str; 155 std::string message = signal_strategy_->GetLocalJid() + ' ' + time_str;
141 std::string signature(key_pair_->GetSignature(message)); 156 std::string signature(key_pair_->GetSignature(message));
142 signature_tag->AddText(signature); 157 signature_tag->AddText(signature);
143 158
144 return signature_tag; 159 return signature_tag;
145 } 160 }
146 161
147 } // namespace remoting 162 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698