Chromium Code Reviews| 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..daa8caed2d44f5bb95d70079f2570d984a4a409a |
| --- /dev/null |
| +++ b/remoting/host/host_attributes.h |
| @@ -0,0 +1,44 @@ |
| +// 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 <string> |
| + |
| +namespace remoting { |
| + |
| +struct DynamicAttribute { |
|
Sergey Ulanov
2016/11/07 20:11:33
I don't think we need this to be in the header.
Hzj_jie
2016/11/08 01:29:54
Done.
|
| + const char* name; |
| + bool(* value)(); |
|
Sergey Ulanov
2016/11/07 20:11:33
this is not a good name for a function. maybe get_
Hzj_jie
2016/11/08 01:29:54
Done.
|
| +}; |
| + |
| +// This structure requires to be POD, so use EvaluatedValue() instead of |value| |
| +// or |attribute| variables directly. |
| +// This class is thread-safe, but |attribute|.value() may be evaluated several |
| +// times concurrently if EvaluatedValue() function is called concurrently. |
| +struct StaticAttribute { |
| + static StaticAttribute Create(DynamicAttribute&& attribute) { |
|
Hzj_jie
2016/11/05 05:29:28
MSVC does not allow to change a constexpr object,
|
| + // std::move is not constexpr in c++ 11. |
| + // TODO(zijiehe): Add std::move once we move to c++ 14. |
| + return StaticAttribute { attribute, false, false }; |
| + } |
| + |
| + const char* name() const; |
| + bool EvaluatedValue(); |
| + |
| + DynamicAttribute attribute; |
|
Hzj_jie
2016/11/05 05:29:28
I do not think it's a good idea to evaluate the St
Sergey Ulanov
2016/11/07 20:11:33
We are not allowed to have any static initializers
Hzj_jie
2016/11/08 01:29:54
See my comments in host_attributes_win.h
|
| + bool evaluated; |
| + bool value; |
| +}; |
| + |
| +// Returns a comma-separated string to represent host attributes. The result may |
| +// vary if any system configurations change. So consumers should not cache the |
| +// result. |
| +// This function is thread-safe. |
| +std::string GetHostAttributes(); |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_HOST_HOST_ATTRIBUTES_H_ |