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

Side by Side Diff: net/base/sdch_manager.cc

Issue 1131963003: Switch //net functions to use SchemeIsCryptographic() instead of SchemeIsSecure(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing. Created 5 years, 7 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 (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 #include "net/base/sdch_manager.h" 5 #include "net/base/sdch_manager.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 if (blacklisted_domains_.end() == blacklisted_domains_.find(domain_lower)) 179 if (blacklisted_domains_.end() == blacklisted_domains_.find(domain_lower))
180 return 0; 180 return 0;
181 return blacklisted_domains_[domain_lower].exponential_count; 181 return blacklisted_domains_[domain_lower].exponential_count;
182 } 182 }
183 183
184 SdchProblemCode SdchManager::IsInSupportedDomain(const GURL& url) { 184 SdchProblemCode SdchManager::IsInSupportedDomain(const GURL& url) {
185 DCHECK(thread_checker_.CalledOnValidThread()); 185 DCHECK(thread_checker_.CalledOnValidThread());
186 if (!g_sdch_enabled_ ) 186 if (!g_sdch_enabled_ )
187 return SDCH_DISABLED; 187 return SDCH_DISABLED;
188 188
189 if (!secure_scheme_supported() && url.SchemeIsSecure()) 189 if (!secure_scheme_supported() && url.SchemeIsCryptographic())
asanka 2015/05/11 22:00:46 This is a bit confusing, but the intent here appea
lgarron 2015/05/11 23:23:47 I started splitting this into a separate CL, but I
Randy Smith (Not in Mondays) 2015/05/12 14:08:04 Yes, that's the intent. I'm not sure the conditio
Elly Fong-Jones 2015/05/12 15:26:31 I would drop support for disabling SDCH for secure
asanka 2015/05/12 17:00:17 I'd wait till rdsmith confirms whether the suggest
asanka 2015/05/12 17:00:17 ellyjones, rdsmith: Cool. Thanks for confirming!
190 return SDCH_SECURE_SCHEME_NOT_SUPPORTED; 190 return SDCH_SECURE_SCHEME_NOT_SUPPORTED;
191 191
192 if (blacklisted_domains_.empty()) 192 if (blacklisted_domains_.empty())
193 return SDCH_OK; 193 return SDCH_OK;
194 194
195 DomainBlacklistInfo::iterator it = 195 DomainBlacklistInfo::iterator it =
196 blacklisted_domains_.find(base::StringToLowerASCII(url.host())); 196 blacklisted_domains_.find(base::StringToLowerASCII(url.host()));
197 if (blacklisted_domains_.end() == it || it->second.count == 0) 197 if (blacklisted_domains_.end() == it || it->second.count == 0)
198 return SDCH_OK; 198 return SDCH_OK;
199 199
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 262
263 scoped_ptr<SdchManager::DictionarySet> 263 scoped_ptr<SdchManager::DictionarySet>
264 SdchManager::GetDictionarySet(const GURL& target_url) { 264 SdchManager::GetDictionarySet(const GURL& target_url) {
265 if (IsInSupportedDomain(target_url) != SDCH_OK) 265 if (IsInSupportedDomain(target_url) != SDCH_OK)
266 return NULL; 266 return NULL;
267 267
268 int count = 0; 268 int count = 0;
269 scoped_ptr<SdchManager::DictionarySet> result(new DictionarySet); 269 scoped_ptr<SdchManager::DictionarySet> result(new DictionarySet);
270 for (const auto& entry: dictionaries_) { 270 for (const auto& entry: dictionaries_) {
271 if (!secure_scheme_supported() && target_url.SchemeIsSecure()) 271 if (!secure_scheme_supported() && target_url.SchemeIsCryptographic())
272 continue; 272 continue;
273 if (entry.second->data.CanUse(target_url) != SDCH_OK) 273 if (entry.second->data.CanUse(target_url) != SDCH_OK)
274 continue; 274 continue;
275 if (entry.second->data.Expired()) 275 if (entry.second->data.Expired())
276 continue; 276 continue;
277 ++count; 277 ++count;
278 result->AddDictionary(entry.first, entry.second); 278 result->AddDictionary(entry.first, entry.second);
279 } 279 }
280 280
281 if (count == 0) 281 if (count == 0)
(...skipping 10 matching lines...) Expand all
292 const std::string& server_hash, 292 const std::string& server_hash,
293 SdchProblemCode* problem_code) { 293 SdchProblemCode* problem_code) {
294 scoped_ptr<SdchManager::DictionarySet> result; 294 scoped_ptr<SdchManager::DictionarySet> result;
295 295
296 *problem_code = SDCH_DICTIONARY_HASH_NOT_FOUND; 296 *problem_code = SDCH_DICTIONARY_HASH_NOT_FOUND;
297 const auto& it = dictionaries_.find(server_hash); 297 const auto& it = dictionaries_.find(server_hash);
298 if (it == dictionaries_.end()) 298 if (it == dictionaries_.end())
299 return result.Pass(); 299 return result.Pass();
300 300
301 if (!SdchManager::secure_scheme_supported() && 301 if (!SdchManager::secure_scheme_supported() &&
302 target_url.SchemeIsSecure()) { 302 target_url.SchemeIsCryptographic()) {
303 *problem_code = SDCH_DICTIONARY_FOUND_HAS_WRONG_SCHEME; 303 *problem_code = SDCH_DICTIONARY_FOUND_HAS_WRONG_SCHEME;
304 return result.Pass(); 304 return result.Pass();
305 } 305 }
306 306
307 *problem_code = it->second->data.CanUse(target_url); 307 *problem_code = it->second->data.CanUse(target_url);
308 if (*problem_code != SDCH_OK) 308 if (*problem_code != SDCH_OK)
309 return result.Pass(); 309 return result.Pass();
310 310
311 result.reset(new DictionarySet); 311 result.reset(new DictionarySet);
312 result->AddDictionary(it->first, it->second); 312 result->AddDictionary(it->first, it->second);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 entry_dict->SetInteger("tries", it->second.count); 517 entry_dict->SetInteger("tries", it->second.count);
518 entry_dict->SetInteger("reason", it->second.reason); 518 entry_dict->SetInteger("reason", it->second.reason);
519 entry_list->Append(entry_dict); 519 entry_list->Append(entry_dict);
520 } 520 }
521 value->Set("blacklisted", entry_list); 521 value->Set("blacklisted", entry_list);
522 522
523 return value; 523 return value;
524 } 524 }
525 525
526 } // namespace net 526 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698