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_CONSUMER_H_ | |
Devlin
2015/01/20 17:51:06
Given the contents of this file, I think it makes
Xi Han
2015/01/21 21:30:17
This git tool really handy for refactoring, thanks
| |
6 #define EXTENSIONS_COMMON_CONSUMER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/macros.h" | |
11 | |
12 // IDs of API consumers who own user scripts. | |
13 // A ConsumerID is immutable after creation. | |
14 // A ConsumerID could be used for an extension, a <webview> created by an | |
15 // extension, or a <webview> created by WebUI. | |
16 class ConsumerID { | |
17 public: | |
18 // The type of a host who contains regular tabs or <webview>s. | |
19 enum HostType { EXTENSIONS, WEBUI }; | |
20 | |
21 enum InstanceType { TAB, WEBVIEW }; | |
22 | |
23 // Default instance ID of a consumer who owns statically defined user scripts. | |
24 static const int kDefaultInstanceID; | |
25 | |
26 ConsumerID(); | |
27 explicit ConsumerID(const ConsumerID& other); | |
Devlin
2015/01/20 17:51:06
Make a note here about why we allow copying/why it
Xi Han
2015/01/21 21:30:17
It seems we don't need this copy constructor now,
| |
28 ConsumerID(HostType host_type, | |
29 const std::string& host_id, | |
30 InstanceType instance_type, | |
31 int instance_id); | |
Devlin
2015/01/20 17:51:06
I think I'd slightly prefer an "is_declarative" bo
Xi Han
2015/01/21 21:30:17
That is a good point. I won't add the is_declarati
| |
32 ~ConsumerID(); | |
33 | |
34 // Get next available instance ID. | |
35 static int GetNextID(); | |
36 | |
37 bool operator<(const ConsumerID& id) const; | |
38 void operator=(const ConsumerID& id); | |
39 | |
40 HostType host_type() const { return host_type_; } | |
41 const std::string& host_id() const { return host_id_; } | |
42 InstanceType instance_type() const { return instance_type_; } | |
43 int instance_id() const { return instance_id_; } | |
44 | |
45 private: | |
46 // Extension or WebUI. | |
Devlin
2015/01/20 17:51:06
nit: Just say "The host type of the consumer." The
Xi Han
2015/01/21 21:30:17
Done.
| |
47 HostType host_type_; | |
48 | |
49 // Similar to extension_id, host_id is a unique indentifier for a host, | |
50 // e.g., an Extension or WebUI. | |
51 std::string host_id_; | |
52 | |
53 // A tab or a <webiew>. | |
54 InstanceType instance_type_; | |
Devlin
2015/01/20 17:51:06
Similar comment to above.
Xi Han
2015/01/21 21:30:17
Done.
| |
55 | |
56 // For a consumer that owns staticlly defined user scripts, the | |
57 // |instance_id| is 0; | |
Devlin
2015/01/20 17:51:06
nit: either make the semicolon a period, or fix wr
Xi Han
2015/01/21 21:30:17
Replace the semicolon with a period:)
| |
58 // For a consumer that owns declarative user scripts, the |instance_id| | |
59 // is assigned by DeclarativeUserScriptManager when the consumer requests a | |
60 // master object. | |
61 int instance_id_; | |
62 }; | |
63 | |
64 // Represents an API consumer. | |
65 class Consumer { | |
Devlin
2015/01/20 17:51:06
When is this used?
Xi Han
2015/01/21 21:30:17
It is not used in this patch, I can just remove it
| |
66 public: | |
67 Consumer(); | |
68 virtual ~Consumer(); | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(Consumer); | |
71 }; | |
72 | |
73 #endif // EXTENSIONS_COMMON_CONSUMER_H_ | |
OLD | NEW |