| Index: remoting/base/capabilities.h
|
| diff --git a/remoting/base/capabilities.h b/remoting/base/capabilities.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bd2adae835dc99da82a03f9a92f8bcb89a264cc8
|
| --- /dev/null
|
| +++ b/remoting/base/capabilities.h
|
| @@ -0,0 +1,69 @@
|
| +// Copyright 2013 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_BASE_CAPABILITIES_H_
|
| +#define REMOTING_BASE_CAPABILITIES_H_
|
| +
|
| +#include <set>
|
| +#include <string>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +
|
| +namespace base {
|
| +class ListValue;
|
| +} // namespace base
|
| +
|
| +namespace remoting {
|
| +
|
| +namespace protocol {
|
| +class Capabilities;
|
| +} // namespace protocol
|
| +
|
| +// Represents a set of capabilities. Each capability is represented by a unique
|
| +// string that may not contain spaces.
|
| +class Capabilities {
|
| + public:
|
| + Capabilities();
|
| + explicit Capabilities(const std::string& value);
|
| + ~Capabilities();
|
| +
|
| + // Returs the number of capabilities in the set.
|
| + size_t Size() const {
|
| + return capabilities_.size();
|
| + }
|
| +
|
| + // Returns true if |this| contains |capability|.
|
| + bool HasCapability(const std::string& capability) const;
|
| +
|
| + // Returns a set of capabilities contained in both |this| and |other| sets.
|
| + Capabilities Intersect(const Capabilities& other) const;
|
| +
|
| + // Initializes |this| from |base::ListValue|. Returns false if |value|
|
| + // contains anything else than valid capability strings.
|
| + bool FromListValue(const base::ListValue& value);
|
| +
|
| + // Initializes |this| from |message|. Returns false if |message| contains
|
| + // anything else than valid capability strings.
|
| + bool FromProtocolMessage(const protocol::Capabilities& message);
|
| +
|
| + // Initializes |this| from |message|.
|
| + void FromString(const std::string& value);
|
| +
|
| + // Converts |this| into |base::ListValue|.
|
| + scoped_ptr<base::ListValue> ToListValue() const;
|
| +
|
| + // Converts |this| into |protocol::Capabilities|.
|
| + scoped_ptr<protocol::Capabilities> ToProtocolMessage() const;
|
| +
|
| + // Converts |this| into |std::string|.
|
| + std::string ToString() const;
|
| +
|
| + protected:
|
| + std::set<std::string> capabilities_;
|
| +};
|
| +
|
| +} // namespace remoting
|
| +
|
| +#endif // REMOTING_BASE_CAPABILITIES_H_
|
|
|