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..f6f96e26c27e76061f82478357a1d149450343b4 |
--- /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" |
+ |
+// IDs of hosts who own user scripts. |
+// A HostID is immutable after creation. |
+struct HostID { |
+ enum HostType { EXTENSIONS, WEBUI }; |
+ |
+ HostID() {} |
+ HostID(HostType host_type, const std::string& host_id) |
+ : type(host_type), id(host_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 |
+ return false; |
+ } |
+ |
+ HostType Type() const { return type; } |
Devlin
2015/01/26 20:12:09
nit: lowercase these -> type() and id()
Xi Han
2015/01/26 23:27:53
Done.
|
+ const std::string& ID() const { return id; } |
+ |
+ private: |
+ // The type of the host. |
+ HostType type; |
Devlin
2015/01/26 20:12:09
Since these are private, they should have a traili
Xi Han
2015/01/26 23:27:53
Oh, I thought the member variables of a struct wou
|
+ |
+ // 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_ |