Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: extensions/browser/updater/manifest_fetch_data.h

Issue 2768573002: Send traffic-management headers from extension updater. (Closed)
Patch Set: Change the code according to mek's comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_BROWSER_UPDATER_MANIFEST_FETCH_DATA_H_ 5 #ifndef EXTENSIONS_BROWSER_UPDATER_MANIFEST_FETCH_DATA_H_
6 #define EXTENSIONS_BROWSER_UPDATER_MANIFEST_FETCH_DATA_H_ 6 #define EXTENSIONS_BROWSER_UPDATER_MANIFEST_FETCH_DATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 26 matching lines...) Expand all
37 // Each ping type is sent at most once per day. 37 // Each ping type is sent at most once per day.
38 enum PingType { 38 enum PingType {
39 // Used for counting total installs of an extension/app/theme. 39 // Used for counting total installs of an extension/app/theme.
40 ROLLCALL, 40 ROLLCALL,
41 41
42 // Used for counting number of active users of an app, where "active" means 42 // Used for counting number of active users of an app, where "active" means
43 // the app was launched at least once since the last active ping. 43 // the app was launched at least once since the last active ping.
44 ACTIVE, 44 ACTIVE,
45 }; 45 };
46 46
47 // What is the priority of the update request.
48 enum FetchPriority {
49 // Used for update requests not initiated by a user, for example regular
50 // extension updates started by the scheduler.
51 BACKGROUND,
52
53 // Used for on-demate update requests i.e. requests initiated by a users.
54 FOREGROUND,
55 };
56
47 struct PingData { 57 struct PingData {
48 // The number of days it's been since our last rollcall or active ping, 58 // The number of days it's been since our last rollcall or active ping,
49 // respectively. These are calculated based on the start of day from the 59 // respectively. These are calculated based on the start of day from the
50 // server's perspective. 60 // server's perspective.
51 int rollcall_days; 61 int rollcall_days;
52 int active_days; 62 int active_days;
53 63
54 // Whether the extension is enabled or not. 64 // Whether the extension is enabled or not.
55 bool is_enabled; 65 bool is_enabled;
56 66
(...skipping 10 matching lines...) Expand all
67 : rollcall_days(rollcall), 77 : rollcall_days(rollcall),
68 active_days(active), 78 active_days(active),
69 is_enabled(enabled), 79 is_enabled(enabled),
70 disable_reasons(reasons) {} 80 disable_reasons(reasons) {}
71 }; 81 };
72 82
73 ManifestFetchData(const GURL& update_url, 83 ManifestFetchData(const GURL& update_url,
74 int request_id, 84 int request_id,
75 const std::string& brand_code, 85 const std::string& brand_code,
76 const std::string& base_query_params, 86 const std::string& base_query_params,
77 PingMode ping_mode); 87 PingMode ping_mode,
88 FetchPriority fetch_priority);
78 ~ManifestFetchData(); 89 ~ManifestFetchData();
79 90
80 // Returns true if this extension information was successfully added. If the 91 // Returns true if this extension information was successfully added. If the
81 // return value is false it means the full_url would have become too long, and 92 // return value is false it means the full_url would have become too long or
93 // the request type is not compatible the current request type, and
82 // this ManifestFetchData object remains unchanged. 94 // this ManifestFetchData object remains unchanged.
83 bool AddExtension(const std::string& id, 95 bool AddExtension(const std::string& id,
84 const std::string& version, 96 const std::string& version,
85 const PingData* ping_data, 97 const PingData* ping_data,
86 const std::string& update_url_data, 98 const std::string& update_url_data,
87 const std::string& install_source); 99 const std::string& install_source,
100 FetchPriority fetch_priority);
88 101
89 const GURL& base_url() const { return base_url_; } 102 const GURL& base_url() const { return base_url_; }
90 const GURL& full_url() const { return full_url_; } 103 const GURL& full_url() const { return full_url_; }
91 const std::set<std::string>& extension_ids() const { return extension_ids_; } 104 const std::set<std::string>& extension_ids() const { return extension_ids_; }
92 const std::set<int>& request_ids() const { return request_ids_; } 105 const std::set<int>& request_ids() const { return request_ids_; }
106 bool foreground_check() const { return fetch_priority_ == FOREGROUND; }
107 FetchPriority fetch_priority() const { return fetch_priority_; }
93 108
94 // Returns true if the given id is included in this manifest fetch. 109 // Returns true if the given id is included in this manifest fetch.
95 bool Includes(const std::string& extension_id) const; 110 bool Includes(const std::string& extension_id) const;
96 111
97 // Returns true if a ping parameter for |type| was added to full_url for this 112 // Returns true if a ping parameter for |type| was added to full_url for this
98 // extension id. 113 // extension id.
99 bool DidPing(const std::string& extension_id, PingType type) const; 114 bool DidPing(const std::string& extension_id, PingType type) const;
100 115
101 // Assuming that both this ManifestFetchData and |other| have the same 116 // Assuming that both this ManifestFetchData and |other| have the same
102 // full_url, this method merges the other information associated with the 117 // full_url, this method merges the other information associated with the
(...skipping 22 matching lines...) Expand all
125 std::set<int> request_ids_; 140 std::set<int> request_ids_;
126 141
127 // The brand code to include with manifest fetch queries, if non-empty and 142 // The brand code to include with manifest fetch queries, if non-empty and
128 // |ping_mode_| >= PING. 143 // |ping_mode_| >= PING.
129 const std::string brand_code_; 144 const std::string brand_code_;
130 145
131 // The ping mode for this fetch. This determines whether or not ping data 146 // The ping mode for this fetch. This determines whether or not ping data
132 // (and possibly extra metrics) will be included in the fetch query. 147 // (and possibly extra metrics) will be included in the fetch query.
133 const PingMode ping_mode_; 148 const PingMode ping_mode_;
134 149
150 // The priority of the update.
151 FetchPriority fetch_priority_;
152
135 DISALLOW_COPY_AND_ASSIGN(ManifestFetchData); 153 DISALLOW_COPY_AND_ASSIGN(ManifestFetchData);
136 }; 154 };
137 155
138 } // namespace extensions 156 } // namespace extensions
139 157
140 #endif // EXTENSIONS_BROWSER_UPDATER_MANIFEST_FETCH_DATA_H_ 158 #endif // EXTENSIONS_BROWSER_UPDATER_MANIFEST_FETCH_DATA_H_
OLDNEW
« no previous file with comments | « extensions/browser/updater/extension_downloader.cc ('k') | extensions/browser/updater/manifest_fetch_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698