OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef EXTENSIONS_COMMON_HOST_ID_H_ | |
6 #define EXTENSIONS_COMMON_HOST_ID_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/macros.h" | |
Devlin
2015/01/27 22:06:39
Don't need this, right?
| |
11 | |
12 // IDs of hosts who own user scripts. | |
13 // A HostID is immutable after creation. | |
14 struct HostID { | |
15 enum HostType { EXTENSIONS, WEBUI }; | |
16 | |
17 HostID() {} | |
18 HostID(HostType type, const std::string& id) | |
19 : type_(type), id_(id) {} | |
20 | |
21 bool operator<(const HostID& host_id) const { | |
22 if (type_ != host_id.type()) | |
23 return type_ < host_id.type(); | |
24 else if (id_ != host_id.id()) | |
25 return id_ < host_id.id(); | |
26 else | |
Devlin
2015/01/27 22:06:39
nit: remove this else
| |
27 return false; | |
28 } | |
29 | |
30 HostType type() const { return type_; } | |
31 const std::string& id() const { return id_; } | |
32 | |
33 private: | |
34 // The type of the host. | |
35 HostType type_; | |
36 | |
37 // Similar to extension_id, host_id is a unique indentifier for a host, | |
38 // e.g., an Extension or WebUI. | |
39 std::string id_; | |
40 }; | |
41 | |
42 #endif // EXTENSIONS_COMMON_HOST_ID_H_ | |
OLD | NEW |