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

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

Issue 2423713002: Remove usage of FOR_EACH_OBSERVER macro in net (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | net/cert/sth_distributor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <limits.h> 7 #include <limits.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 while (!dictionaries_.empty()) { 89 while (!dictionaries_.empty()) {
90 auto it = dictionaries_.begin(); 90 auto it = dictionaries_.begin();
91 dictionaries_.erase(it->first); 91 dictionaries_.erase(it->first);
92 } 92 }
93 } 93 }
94 94
95 void SdchManager::ClearData() { 95 void SdchManager::ClearData() {
96 blacklisted_domains_.clear(); 96 blacklisted_domains_.clear();
97 allow_latency_experiment_.clear(); 97 allow_latency_experiment_.clear();
98 dictionaries_.clear(); 98 dictionaries_.clear();
99 FOR_EACH_OBSERVER(SdchObserver, observers_, OnClearDictionaries()); 99 for (auto& observer : observers_)
100 observer.OnClearDictionaries();
100 } 101 }
101 102
102 // static 103 // static
103 void SdchManager::SdchErrorRecovery(SdchProblemCode problem) { 104 void SdchManager::SdchErrorRecovery(SdchProblemCode problem) {
104 UMA_HISTOGRAM_ENUMERATION("Sdch3.ProblemCodes_5", problem, 105 UMA_HISTOGRAM_ENUMERATION("Sdch3.ProblemCodes_5", problem,
105 SDCH_MAX_PROBLEM_CODE); 106 SDCH_MAX_PROBLEM_CODE);
106 } 107 }
107 108
108 void SdchManager::BlacklistDomain(const GURL& url, 109 void SdchManager::BlacklistDomain(const GURL& url,
109 SdchProblemCode blacklist_reason) { 110 SdchProblemCode blacklist_reason) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return SDCH_DOMAIN_BLACKLIST_INCLUDES_TARGET; 186 return SDCH_DOMAIN_BLACKLIST_INCLUDES_TARGET;
186 } 187 }
187 188
188 SdchProblemCode SdchManager::OnGetDictionary(const GURL& request_url, 189 SdchProblemCode SdchManager::OnGetDictionary(const GURL& request_url,
189 const GURL& dictionary_url) { 190 const GURL& dictionary_url) {
190 DCHECK(thread_checker_.CalledOnValidThread()); 191 DCHECK(thread_checker_.CalledOnValidThread());
191 SdchProblemCode rv = CanFetchDictionary(request_url, dictionary_url); 192 SdchProblemCode rv = CanFetchDictionary(request_url, dictionary_url);
192 if (rv != SDCH_OK) 193 if (rv != SDCH_OK)
193 return rv; 194 return rv;
194 195
195 FOR_EACH_OBSERVER(SdchObserver, 196 for (auto& observer : observers_)
196 observers_, 197 observer.OnGetDictionary(request_url, dictionary_url);
197 OnGetDictionary(request_url, dictionary_url));
198 198
199 return SDCH_OK; 199 return SDCH_OK;
200 } 200 }
201 201
202 void SdchManager::OnDictionaryUsed(const std::string& server_hash) { 202 void SdchManager::OnDictionaryUsed(const std::string& server_hash) {
203 FOR_EACH_OBSERVER(SdchObserver, observers_, 203 for (auto& observer : observers_)
204 OnDictionaryUsed(server_hash)); 204 observer.OnDictionaryUsed(server_hash);
205 } 205 }
206 206
207 SdchProblemCode SdchManager::CanFetchDictionary( 207 SdchProblemCode SdchManager::CanFetchDictionary(
208 const GURL& referring_url, 208 const GURL& referring_url,
209 const GURL& dictionary_url) const { 209 const GURL& dictionary_url) const {
210 DCHECK(thread_checker_.CalledOnValidThread()); 210 DCHECK(thread_checker_.CalledOnValidThread());
211 /* The user agent may retrieve a dictionary from the dictionary URL if all of 211 /* The user agent may retrieve a dictionary from the dictionary URL if all of
212 the following are true: 212 the following are true:
213 1 The dictionary URL host name matches the referrer URL host name and 213 1 The dictionary URL host name matches the referrer URL host name and
214 scheme. 214 scheme.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 DVLOG(1) << "Loaded dictionary with client hash " << client_hash 416 DVLOG(1) << "Loaded dictionary with client hash " << client_hash
417 << " and server hash " << server_hash; 417 << " and server hash " << server_hash;
418 SdchDictionary dictionary(dictionary_text, header_end + 2, client_hash, 418 SdchDictionary dictionary(dictionary_text, header_end + 2, client_hash,
419 server_hash, dictionary_url_normalized, domain, 419 server_hash, dictionary_url_normalized, domain,
420 path, expiration, ports); 420 path, expiration, ports);
421 dictionaries_[server_hash] = 421 dictionaries_[server_hash] =
422 new base::RefCountedData<SdchDictionary>(dictionary); 422 new base::RefCountedData<SdchDictionary>(dictionary);
423 if (server_hash_p) 423 if (server_hash_p)
424 *server_hash_p = server_hash; 424 *server_hash_p = server_hash;
425 425
426 FOR_EACH_OBSERVER(SdchObserver, observers_, 426 for (auto& observer : observers_)
427 OnDictionaryAdded(dictionary_url, server_hash)); 427 observer.OnDictionaryAdded(dictionary_url, server_hash);
428 428
429 return SDCH_OK; 429 return SDCH_OK;
430 } 430 }
431 431
432 SdchProblemCode SdchManager::RemoveSdchDictionary( 432 SdchProblemCode SdchManager::RemoveSdchDictionary(
433 const std::string& server_hash) { 433 const std::string& server_hash) {
434 if (dictionaries_.find(server_hash) == dictionaries_.end()) 434 if (dictionaries_.find(server_hash) == dictionaries_.end())
435 return SDCH_DICTIONARY_HASH_NOT_FOUND; 435 return SDCH_DICTIONARY_HASH_NOT_FOUND;
436 436
437 dictionaries_.erase(server_hash); 437 dictionaries_.erase(server_hash);
438 438
439 FOR_EACH_OBSERVER(SdchObserver, observers_, OnDictionaryRemoved(server_hash)); 439 for (auto& observer : observers_)
440 observer.OnDictionaryRemoved(server_hash);
440 441
441 return SDCH_OK; 442 return SDCH_OK;
442 } 443 }
443 444
444 // static 445 // static
445 std::unique_ptr<SdchManager::DictionarySet> 446 std::unique_ptr<SdchManager::DictionarySet>
446 SdchManager::CreateEmptyDictionarySetForTesting() { 447 SdchManager::CreateEmptyDictionarySetForTesting() {
447 return std::unique_ptr<DictionarySet>(new DictionarySet); 448 return std::unique_ptr<DictionarySet>(new DictionarySet);
448 } 449 }
449 450
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 entry_dict->SetInteger("tries", it->second.count); 485 entry_dict->SetInteger("tries", it->second.count);
485 entry_dict->SetInteger("reason", it->second.reason); 486 entry_dict->SetInteger("reason", it->second.reason);
486 entry_list->Append(std::move(entry_dict)); 487 entry_list->Append(std::move(entry_dict));
487 } 488 }
488 value->Set("blacklisted", std::move(entry_list)); 489 value->Set("blacklisted", std::move(entry_list));
489 490
490 return std::move(value); 491 return std::move(value);
491 } 492 }
492 493
493 } // namespace net 494 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/cert/sth_distributor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698