OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_EXTENSIONS_UPDATER_MANIFEST_FETCH_DATA_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_UPDATER_MANIFEST_FETCH_DATA_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_MANIFEST_FETCH_DATA_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_MANIFEST_FETCH_DATA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
| 18 struct ManifestFetchExtensionInfo { |
| 19 ManifestFetchExtensionInfo(const std::string& id, const std::string& version, |
| 20 const std::string& update_url_data, |
| 21 const std::string& install_source, |
| 22 bool is_sync); |
| 23 ManifestFetchExtensionInfo(); |
| 24 ~ManifestFetchExtensionInfo(); |
| 25 |
| 26 std::string id; |
| 27 std::string version; |
| 28 std::string update_url_data; |
| 29 std::string install_source; |
| 30 bool is_sync; |
| 31 }; |
| 32 |
18 // To save on server resources we can request updates for multiple extensions | 33 // To save on server resources we can request updates for multiple extensions |
19 // in one manifest check. This class helps us keep track of the id's for a | 34 // in one manifest check. This class helps us keep track of the id's for a |
20 // given fetch, building up the actual URL, and what if anything to include | 35 // given fetch, building up the actual URL, and what if anything to include |
21 // in the ping parameter. | 36 // in the ping parameter. |
22 class ManifestFetchData { | 37 class ManifestFetchData { |
23 public: | 38 public: |
| 39 typedef std::map<std::string, ManifestFetchExtensionInfo> ExtensionInfoMap; |
| 40 |
24 static const int kNeverPinged = -1; | 41 static const int kNeverPinged = -1; |
25 | 42 |
26 // Each ping type is sent at most once per day. | 43 // Each ping type is sent at most once per day. |
27 enum PingType { | 44 enum PingType { |
28 // Used for counting total installs of an extension/app/theme. | 45 // Used for counting total installs of an extension/app/theme. |
29 ROLLCALL, | 46 ROLLCALL, |
30 | 47 |
31 // Used for counting number of active users of an app, where "active" means | 48 // Used for counting number of active users of an app, where "active" means |
32 // the app was launched at least once since the last active ping. | 49 // the app was launched at least once since the last active ping. |
33 ACTIVE, | 50 ACTIVE, |
(...skipping 13 matching lines...) Expand all Loading... |
47 | 64 |
48 explicit ManifestFetchData(const GURL& update_url); | 65 explicit ManifestFetchData(const GURL& update_url); |
49 ~ManifestFetchData(); | 66 ~ManifestFetchData(); |
50 | 67 |
51 // Returns true if this extension information was successfully added. If the | 68 // Returns true if this extension information was successfully added. If the |
52 // return value is false it means the full_url would have become too long, and | 69 // return value is false it means the full_url would have become too long, and |
53 // this ManifestFetchData object remains unchanged. | 70 // this ManifestFetchData object remains unchanged. |
54 bool AddExtension(std::string id, std::string version, | 71 bool AddExtension(std::string id, std::string version, |
55 const PingData* ping_data, | 72 const PingData* ping_data, |
56 const std::string& update_url_data, | 73 const std::string& update_url_data, |
57 const std::string& install_source); | 74 const std::string& install_source, |
| 75 bool is_sync); |
58 | 76 |
59 const GURL& base_url() const { return base_url_; } | 77 const GURL& base_url() const { return base_url_; } |
60 const GURL& full_url() const { return full_url_; } | 78 const GURL& full_url() const { return full_url_; } |
61 int extension_count() { return extension_ids_.size(); } | 79 int extension_count() { return extension_infos_.size(); } |
62 const std::set<std::string>& extension_ids() const { return extension_ids_; } | 80 const ExtensionInfoMap& extension_infos() const { return extension_infos_; } |
63 | 81 |
64 // Returns true if the given id is included in this manifest fetch. | 82 // Returns true if the given id is included in this manifest fetch. |
65 bool Includes(const std::string& extension_id) const; | 83 bool Includes(const std::string& extension_id) const; |
66 | 84 |
67 // Returns true if a ping parameter for |type| was added to full_url for this | 85 // Returns true if a ping parameter for |type| was added to full_url for this |
68 // extension id. | 86 // extension id. |
69 bool DidPing(std::string extension_id, PingType type) const; | 87 bool DidPing(std::string extension_id, PingType type) const; |
70 | 88 |
71 private: | 89 private: |
72 // The set of extension id's for this ManifestFetchData. | 90 // Map of the extension id's to their info. |
73 std::set<std::string> extension_ids_; | 91 ExtensionInfoMap extension_infos_; |
74 | 92 |
75 // The set of ping data we actually sent. | 93 // The set of ping data we actually sent. |
76 std::map<std::string, PingData> pings_; | 94 std::map<std::string, PingData> pings_; |
77 | 95 |
78 // The base update url without any arguments added. | 96 // The base update url without any arguments added. |
79 GURL base_url_; | 97 GURL base_url_; |
80 | 98 |
81 // The base update url plus arguments indicating the id, version, etc. | 99 // The base update url plus arguments indicating the id, version, etc. |
82 // information about each extension. | 100 // information about each extension. |
83 GURL full_url_; | 101 GURL full_url_; |
84 | 102 |
85 DISALLOW_COPY_AND_ASSIGN(ManifestFetchData); | 103 DISALLOW_COPY_AND_ASSIGN(ManifestFetchData); |
86 }; | 104 }; |
87 | 105 |
88 } // namespace extensions | 106 } // namespace extensions |
89 | 107 |
90 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_MANIFEST_FETCH_DATA_H_ | 108 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_MANIFEST_FETCH_DATA_H_ |
OLD | NEW |