OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "remoting/host/host_change_notification_listener.h" | 5 #include "remoting/host/host_change_notification_listener.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return false; | 48 return false; |
49 | 49 |
50 const XmlElement* host_changed_element = | 50 const XmlElement* host_changed_element = |
51 stanza->FirstNamed(QName(kChromotingXmlNamespace, "host-changed")); | 51 stanza->FirstNamed(QName(kChromotingXmlNamespace, "host-changed")); |
52 if (!host_changed_element) | 52 if (!host_changed_element) |
53 return false; | 53 return false; |
54 | 54 |
55 const std::string& host_id = | 55 const std::string& host_id = |
56 host_changed_element->Attr(QName(kChromotingXmlNamespace, "hostid")); | 56 host_changed_element->Attr(QName(kChromotingXmlNamespace, "hostid")); |
57 const std::string& from = stanza->Attr(buzz::QN_FROM); | 57 const std::string& from = stanza->Attr(buzz::QN_FROM); |
58 const std::string& to = stanza->Attr(buzz::QN_TO); | 58 |
| 59 std::string to_error; |
| 60 SignalingAddress to = |
| 61 SignalingAddress::Parse(stanza, SignalingAddress::TO, &to_error); |
| 62 |
59 if (host_id == host_id_ && from == directory_bot_jid_ && | 63 if (host_id == host_id_ && from == directory_bot_jid_ && |
60 to == signal_strategy_->GetLocalJid()) { | 64 to == signal_strategy_->GetLocalAddress()) { |
61 const std::string& operation = | 65 const std::string& operation = |
62 host_changed_element->Attr(QName(kChromotingXmlNamespace, "operation")); | 66 host_changed_element->Attr(QName(kChromotingXmlNamespace, "operation")); |
63 if (operation == "delete") { | 67 if (operation == "delete") { |
64 // OnHostDeleted() may want delete |signal_strategy_|, but SignalStrategy | 68 // OnHostDeleted() may want delete |signal_strategy_|, but SignalStrategy |
65 // objects cannot be deleted from a Listener callback, so OnHostDeleted() | 69 // objects cannot be deleted from a Listener callback, so OnHostDeleted() |
66 // has to be invoked later. | 70 // has to be invoked later. |
67 base::ThreadTaskRunnerHandle::Get()->PostTask( | 71 base::ThreadTaskRunnerHandle::Get()->PostTask( |
68 FROM_HERE, base::Bind(&HostChangeNotificationListener::OnHostDeleted, | 72 FROM_HERE, base::Bind(&HostChangeNotificationListener::OnHostDeleted, |
69 weak_factory_.GetWeakPtr())); | 73 weak_factory_.GetWeakPtr())); |
70 } | 74 } |
71 } else { | 75 } else { |
72 LOG(ERROR) << "Invalid host-changed message received: " << stanza->Str(); | 76 LOG(ERROR) << "Invalid host-changed message received: " << stanza->Str(); |
73 } | 77 } |
74 return true; | 78 return true; |
75 } | 79 } |
76 | 80 |
77 void HostChangeNotificationListener::OnHostDeleted() { | 81 void HostChangeNotificationListener::OnHostDeleted() { |
78 listener_->OnHostDeleted(); | 82 listener_->OnHostDeleted(); |
79 } | 83 } |
80 | 84 |
81 } // namespace remoting | 85 } // namespace remoting |
OLD | NEW |