Chromium Code Reviews| Index: extensions/common/host_id.h |
| diff --git a/extensions/common/host_id.h b/extensions/common/host_id.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4e4f5f49f59d548f3fd2ab167dea410d82cde8bd |
| --- /dev/null |
| +++ b/extensions/common/host_id.h |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2015 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 EXTENSIONS_COMMON_HOST_ID_H_ |
| +#define EXTENSIONS_COMMON_HOST_ID_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/macros.h" |
|
Devlin
2015/01/27 22:06:39
Don't need this, right?
|
| + |
| +// IDs of hosts who own user scripts. |
| +// A HostID is immutable after creation. |
| +struct HostID { |
| + enum HostType { EXTENSIONS, WEBUI }; |
| + |
| + HostID() {} |
| + HostID(HostType type, const std::string& id) |
| + : type_(type), id_(id) {} |
| + |
| + bool operator<(const HostID& host_id) const { |
| + if (type_ != host_id.type()) |
| + return type_ < host_id.type(); |
| + else if (id_ != host_id.id()) |
| + return id_ < host_id.id(); |
| + else |
|
Devlin
2015/01/27 22:06:39
nit: remove this else
|
| + return false; |
| + } |
| + |
| + HostType type() const { return type_; } |
| + const std::string& id() const { return id_; } |
| + |
| + private: |
| + // The type of the host. |
| + HostType type_; |
| + |
| + // Similar to extension_id, host_id is a unique indentifier for a host, |
| + // e.g., an Extension or WebUI. |
| + std::string id_; |
| +}; |
| + |
| +#endif // EXTENSIONS_COMMON_HOST_ID_H_ |