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

Unified Diff: remoting/protocol/host_experiment_session_plugin.cc

Issue 2586133002: [Chromoting] Implement HostExperimentSessionPlugin (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/host_experiment_session_plugin.cc
diff --git a/remoting/protocol/host_experiment_session_plugin.cc b/remoting/protocol/host_experiment_session_plugin.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2b86600f999769cdab687814f4b1e00f323a84e5
--- /dev/null
+++ b/remoting/protocol/host_experiment_session_plugin.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/host_experiment_session_plugin.h"
+
+#include "remoting/base/constants.h"
+#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.
+
+namespace remoting {
+namespace protocol {
+
+using buzz::QName;
+using buzz::XmlElement;
+
+void HostExperimentSessionPlugin::OnSending(
+ Session::State state,
+ JingleMessage::ActionType action,
+ std::unique_ptr<XmlElement>* attachments) {
+ if (state == Session::ACCEPTING && action == JingleMessage::SESSION_ACCEPT) {
+ if (!*attachments) {
+ *attachments = new_attachments_.Run();
+ }
+ XmlElement* attributes =
+ new XmlElement(QName(kChromotingXmlNamespace, "host-attributes"));
+ attributes->SetBodyText(GetHostAttributes());
+ (*attachments)->AddElement(attributes);
+ }
+}
+
+void HostExperimentSessionPlugin::OnReceiving(
+ Session::State state,
+ JingleMessage::ActionType action,
+ const std::unique_ptr<XmlElement>& attachments) {
+ 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.
+ return;
+ }
+ if (state != Session::ACCEPTING && state != Session::ACCEPTED &&
+ state != Session::AUTHENTICATING) {
+ return;
+ }
+ if (!configuration_.empty()) {
+ return;
+ }
+
+ const XmlElement* configuration = attachments->FirstNamed(
+ QName(kChromotingXmlNamespace, "host-configuration"));
+ if (!configuration) {
+ return;
+ }
+
+ configuration_ = configuration->BodyText();
+}
+
+const std::string& HostExperimentSessionPlugin::configuration() const {
+ return configuration_;
+}
+
+} // namespace protocol
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698