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

Unified Diff: remoting/host/host_attributes.h

Issue 2464293002: [Chromoting] GetHostAttributes with tests (Closed)
Patch Set: Resolve review comments Created 4 years, 1 month 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/host/host_attributes.h
diff --git a/remoting/host/host_attributes.h b/remoting/host/host_attributes.h
new file mode 100644
index 0000000000000000000000000000000000000000..0a0b32b8c114d2f1b575169b3e83fe23bd6ca093
--- /dev/null
+++ b/remoting/host/host_attributes.h
@@ -0,0 +1,49 @@
+// 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.
+
+#ifndef REMOTING_HOST_HOST_ATTRIBUTES_H_
+#define REMOTING_HOST_HOST_ATTRIBUTES_H_
+
+#include <map>
+#include <set>
+#include <string>
+
+#include "base/callback.h"
+
+namespace remoting {
+
+class HostAttributes final {
+ public:
+ HostAttributes();
+ HostAttributes(HostAttributes&& other);
+ HostAttributes(const HostAttributes& other);
+ ~HostAttributes();
+
+ HostAttributes& operator=(HostAttributes&& other);
+ HostAttributes& operator=(const HostAttributes& other);
+
+ // Converts the HostAttributes into its text representation, which is a comma-
+ // separated string, each field indicates one attribute.
+ std::string ToString() const;
+
+ // Registers a static value, which will be appended to ToString() result.
+ void Register(const std::string& key);
+
+ // Registers a dynamic value, which will be evaluated each time ToString() is
+ // called.
+ void Register(const std::string& key, const base::Callback<bool()>& value);
+
+ // Whether the |output| contains the specified attribute as |key|. This
+ // function is usually for testing purpose.
+ static bool ContainsAttribute(const std::string& output,
+ const std::string& key);
+
+ private:
+ std::set<std::string> static_values_;
+ std::map<std::string, base::Callback<bool()>> dynamic_values_;
Sergey Ulanov 2016/11/03 22:15:34 I still think we don't need set/map here instead o
Hzj_jie 2016/11/05 05:29:28 I have moved this logic into the test case.
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_HOST_ATTRIBUTES_H_

Powered by Google App Engine
This is Rietveld 408576698