OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 #include "remoting/protocol/host_experiment_session_plugin.h" | |
6 | |
7 #include "remoting/base/constants.h" | |
8 #include "remoting/host/host_attributes.h" | |
Sergey Ulanov
2016/12/23 00:23:20
remoting/protocol should not depend on remoting/ho
Hzj_jie
2016/12/30 04:23:28
This file pair has been moved to remoting/host.
| |
9 | |
10 namespace remoting { | |
11 namespace protocol { | |
12 | |
13 using buzz::QName; | |
14 using buzz::XmlElement; | |
15 | |
16 void HostExperimentSessionPlugin::OnSending( | |
17 Session::State state, | |
18 JingleMessage::ActionType action, | |
19 std::unique_ptr<XmlElement>* attachments) { | |
20 if (state == Session::ACCEPTING && action == JingleMessage::SESSION_ACCEPT) { | |
21 if (!*attachments) { | |
22 *attachments = new_attachments_.Run(); | |
23 } | |
24 XmlElement* attributes = | |
25 new XmlElement(QName(kChromotingXmlNamespace, "host-attributes")); | |
26 attributes->SetBodyText(GetHostAttributes()); | |
27 (*attachments)->AddElement(attributes); | |
28 } | |
29 } | |
30 | |
31 void HostExperimentSessionPlugin::OnReceiving( | |
32 Session::State state, | |
33 JingleMessage::ActionType action, | |
34 const std::unique_ptr<XmlElement>& attachments) { | |
35 if (!attachments) { | |
Sergey Ulanov
2016/12/23 00:23:19
Why would this function be called with empty attac
Hzj_jie
2016/12/30 04:23:27
Done.
| |
36 return; | |
37 } | |
38 if (state != Session::ACCEPTING && state != Session::ACCEPTED && | |
39 state != Session::AUTHENTICATING) { | |
40 return; | |
41 } | |
42 if (!configuration_.empty()) { | |
43 return; | |
44 } | |
45 | |
46 const XmlElement* configuration = attachments->FirstNamed( | |
47 QName(kChromotingXmlNamespace, "host-configuration")); | |
48 if (!configuration) { | |
49 return; | |
50 } | |
51 | |
52 configuration_ = configuration->BodyText(); | |
53 } | |
54 | |
55 const std::string& HostExperimentSessionPlugin::configuration() const { | |
56 return configuration_; | |
57 } | |
58 | |
59 } // namespace protocol | |
60 } // namespace remoting | |
OLD | NEW |