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

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

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
« no previous file with comments | « extensions/browser/updater/manifest_fetch_data.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "extensions/browser/updater/manifest_fetch_data.h" 5 #include "extensions/browser/updater/manifest_fetch_data.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 23 matching lines...) Expand all
34 } 34 }
35 } 35 }
36 } 36 }
37 37
38 } // namespace 38 } // namespace
39 39
40 ManifestFetchData::ManifestFetchData(const GURL& update_url, 40 ManifestFetchData::ManifestFetchData(const GURL& update_url,
41 int request_id, 41 int request_id,
42 const std::string& brand_code, 42 const std::string& brand_code,
43 const std::string& base_query_params, 43 const std::string& base_query_params,
44 PingMode ping_mode) 44 PingMode ping_mode,
45 FetchPriority fetch_priority)
45 : base_url_(update_url), 46 : base_url_(update_url),
46 full_url_(update_url), 47 full_url_(update_url),
47 brand_code_(brand_code), 48 brand_code_(brand_code),
48 ping_mode_(ping_mode) { 49 ping_mode_(ping_mode),
50 fetch_priority_(fetch_priority) {
49 std::string query = 51 std::string query =
50 full_url_.has_query() ? full_url_.query() + "&" : std::string(); 52 full_url_.has_query() ? full_url_.query() + "&" : std::string();
51 query += base_query_params; 53 query += base_query_params;
52 GURL::Replacements replacements; 54 GURL::Replacements replacements;
53 replacements.SetQueryStr(query); 55 replacements.SetQueryStr(query);
54 full_url_ = full_url_.ReplaceComponents(replacements); 56 full_url_ = full_url_.ReplaceComponents(replacements);
55 57
56 request_ids_.insert(request_id); 58 request_ids_.insert(request_id);
57 } 59 }
58 60
(...skipping 19 matching lines...) Expand all
78 // Extension 2- id:bbbb version:2.0 80 // Extension 2- id:bbbb version:2.0
79 // 81 //
80 // the full update url would be: 82 // the full update url would be:
81 // http://somehost/path?x=id%3Daaaa%26v%3D1.1%26uc&x=id%3Dbbbb%26v%3D2.0%26uc 83 // http://somehost/path?x=id%3Daaaa%26v%3D1.1%26uc&x=id%3Dbbbb%26v%3D2.0%26uc
82 // 84 //
83 // (Note that '=' is %3D and '&' is %26 when urlencoded.) 85 // (Note that '=' is %3D and '&' is %26 when urlencoded.)
84 bool ManifestFetchData::AddExtension(const std::string& id, 86 bool ManifestFetchData::AddExtension(const std::string& id,
85 const std::string& version, 87 const std::string& version,
86 const PingData* ping_data, 88 const PingData* ping_data,
87 const std::string& update_url_data, 89 const std::string& update_url_data,
88 const std::string& install_source) { 90 const std::string& install_source,
91 FetchPriority fetch_priority) {
89 if (extension_ids_.find(id) != extension_ids_.end()) { 92 if (extension_ids_.find(id) != extension_ids_.end()) {
90 NOTREACHED() << "Duplicate extension id " << id; 93 NOTREACHED() << "Duplicate extension id " << id;
91 return false; 94 return false;
92 } 95 }
93 96
97 if (fetch_priority_ != FOREGROUND) {
98 fetch_priority_ = fetch_priority;
99 }
100
94 // Compute the string we'd append onto the full_url_, and see if it fits. 101 // Compute the string we'd append onto the full_url_, and see if it fits.
95 std::vector<std::string> parts; 102 std::vector<std::string> parts;
96 parts.push_back("id=" + id); 103 parts.push_back("id=" + id);
97 parts.push_back("v=" + version); 104 parts.push_back("v=" + version);
98 if (!install_source.empty()) 105 if (!install_source.empty())
99 parts.push_back("installsource=" + install_source); 106 parts.push_back("installsource=" + install_source);
100 parts.push_back("uc"); 107 parts.push_back("uc");
101 108
102 if (!update_url_data.empty()) { 109 if (!update_url_data.empty()) {
103 // Make sure the update_url_data string is escaped before using it so that 110 // Make sure the update_url_data string is escaped before using it so that
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 value = i->second.rollcall_days; 173 value = i->second.rollcall_days;
167 else if (type == ACTIVE) 174 else if (type == ACTIVE)
168 value = i->second.active_days; 175 value = i->second.active_days;
169 else 176 else
170 NOTREACHED(); 177 NOTREACHED();
171 return value == kNeverPinged || value > 0; 178 return value == kNeverPinged || value > 0;
172 } 179 }
173 180
174 void ManifestFetchData::Merge(const ManifestFetchData& other) { 181 void ManifestFetchData::Merge(const ManifestFetchData& other) {
175 DCHECK(full_url() == other.full_url()); 182 DCHECK(full_url() == other.full_url());
183 if (fetch_priority_ != FOREGROUND) {
184 fetch_priority_ = other.fetch_priority_;
185 }
176 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end()); 186 request_ids_.insert(other.request_ids_.begin(), other.request_ids_.end());
177 } 187 }
178 188
179 } // namespace extensions 189 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/updater/manifest_fetch_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698