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

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

Issue 465543004: Factor Chrome details out of update manifest fetching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 EXTENSIONS_BROWSER_UPDATER_MANIFEST_FETCH_DATA_H_
6 #define CHROME_BROWSER_EXTENSIONS_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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 // To save on server resources we can request updates for multiple extensions 17 // To save on server resources we can request updates for multiple extensions
18 // in one manifest check. This class helps us keep track of the id's for a 18 // in one manifest check. This class helps us keep track of the id's for a
19 // given fetch, building up the actual URL, and what if anything to include 19 // given fetch, building up the actual URL, and what if anything to include
20 // in the ping parameter. 20 // in the ping parameter.
21 class ManifestFetchData { 21 class ManifestFetchData {
22 public: 22 public:
23 static const int kNeverPinged = -1; 23 static const int kNeverPinged = -1;
24 24
25 // What ping mode this fetch should use.
26 enum PingMode {
27 // No ping, no extra metrics.
28 NO_PING,
29
30 // Ping without extra metrics.
31 PING,
32
33 // Ping with extra metrics.
34 PING_WITH_METRICS,
35 };
36
25 // Each ping type is sent at most once per day. 37 // Each ping type is sent at most once per day.
26 enum PingType { 38 enum PingType {
27 // Used for counting total installs of an extension/app/theme. 39 // Used for counting total installs of an extension/app/theme.
28 ROLLCALL, 40 ROLLCALL,
29 41
30 // 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
31 // 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.
32 ACTIVE, 44 ACTIVE,
33 }; 45 };
34 46
35 struct PingData { 47 struct PingData {
36 // The number of days it's been since our last rollcall or active ping, 48 // The number of days it's been since our last rollcall or active ping,
37 // respectively. These are calculated based on the start of day from the 49 // respectively. These are calculated based on the start of day from the
38 // server's perspective. 50 // server's perspective.
39 int rollcall_days; 51 int rollcall_days;
40 int active_days; 52 int active_days;
41 // Wether the extension is enabled or not. 53 // Wether the extension is enabled or not.
42 bool is_enabled; 54 bool is_enabled;
43 55
44 PingData() : rollcall_days(0), active_days(0), is_enabled(true) {} 56 PingData() : rollcall_days(0), active_days(0), is_enabled(true) {}
45 PingData(int rollcall, int active, bool enabled) 57 PingData(int rollcall, int active, bool enabled)
46 : rollcall_days(rollcall), active_days(active), is_enabled(enabled) {} 58 : rollcall_days(rollcall), active_days(active), is_enabled(enabled) {}
47 }; 59 };
48 60
49 ManifestFetchData(const GURL& update_url, int request_id); 61 ManifestFetchData(const GURL& update_url,
62 int request_id,
63 const std::string& brand_code,
64 const std::string& base_query_params,
65 PingMode ping_mode);
50 ~ManifestFetchData(); 66 ~ManifestFetchData();
51 67
52 // Returns true if this extension information was successfully added. If the 68 // Returns true if this extension information was successfully added. If the
53 // 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
54 // this ManifestFetchData object remains unchanged. 70 // this ManifestFetchData object remains unchanged.
55 bool AddExtension(const std::string& id, 71 bool AddExtension(const std::string& id,
56 const std::string& version, 72 const std::string& version,
57 const PingData* ping_data, 73 const PingData* ping_data,
58 const std::string& update_url_data, 74 const std::string& update_url_data,
59 const std::string& install_source); 75 const std::string& install_source);
(...skipping 29 matching lines...) Expand all
89 // The base update url plus arguments indicating the id, version, etc. 105 // The base update url plus arguments indicating the id, version, etc.
90 // information about each extension. 106 // information about each extension.
91 GURL full_url_; 107 GURL full_url_;
92 108
93 // The set of request ids associated with this manifest fetch. If multiple 109 // The set of request ids associated with this manifest fetch. If multiple
94 // requests are trying to fetch the same manifest, they can be merged into 110 // requests are trying to fetch the same manifest, they can be merged into
95 // one fetch, so potentially multiple request ids can get associated with 111 // one fetch, so potentially multiple request ids can get associated with
96 // one ManifestFetchData. 112 // one ManifestFetchData.
97 std::set<int> request_ids_; 113 std::set<int> request_ids_;
98 114
115 // The brand code to include with manifest fetch queries, if non-empty and
116 // |ping_mode_| >= PING.
117 const std::string brand_code_;
118
119 // The ping mode for this fetch. This determines whether or not ping data
120 // (and possibly extra metrics) will be included in the fetch query.
121 const PingMode ping_mode_;
122
99 DISALLOW_COPY_AND_ASSIGN(ManifestFetchData); 123 DISALLOW_COPY_AND_ASSIGN(ManifestFetchData);
100 }; 124 };
101 125
102 } // namespace extensions 126 } // namespace extensions
103 127
104 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_MANIFEST_FETCH_DATA_H_ 128 #endif // EXTENSIONS_BROWSER_UPDATER_MANIFEST_FETCH_DATA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698