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

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

Issue 1133763003: SdchObserver: add OnDictionary{Added,Removed} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove manager parameter from SdchObserver 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 // Explicitly confirm that we can't notify any observers anymore. 97 // Explicitly confirm that we can't notify any observers anymore.
98 CHECK(!observers_.might_have_observers()); 98 CHECK(!observers_.might_have_observers());
99 #endif 99 #endif
100 } 100 }
101 101
102 void SdchManager::ClearData() { 102 void SdchManager::ClearData() {
103 blacklisted_domains_.clear(); 103 blacklisted_domains_.clear();
104 allow_latency_experiment_.clear(); 104 allow_latency_experiment_.clear();
105 dictionaries_.clear(); 105 dictionaries_.clear();
106 FOR_EACH_OBSERVER(SdchObserver, observers_, OnClearDictionaries(this)); 106 FOR_EACH_OBSERVER(SdchObserver, observers_, OnClearDictionaries());
107 } 107 }
108 108
109 // static 109 // static
110 void SdchManager::SdchErrorRecovery(SdchProblemCode problem) { 110 void SdchManager::SdchErrorRecovery(SdchProblemCode problem) {
111 UMA_HISTOGRAM_ENUMERATION("Sdch3.ProblemCodes_5", problem, 111 UMA_HISTOGRAM_ENUMERATION("Sdch3.ProblemCodes_5", problem,
112 SDCH_MAX_PROBLEM_CODE); 112 SDCH_MAX_PROBLEM_CODE);
113 } 113 }
114 114
115 // static 115 // static
116 void SdchManager::EnableSdchSupport(bool enabled) { 116 void SdchManager::EnableSdchSupport(bool enabled) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 SdchProblemCode SdchManager::OnGetDictionary(const GURL& request_url, 214 SdchProblemCode SdchManager::OnGetDictionary(const GURL& request_url,
215 const GURL& dictionary_url) { 215 const GURL& dictionary_url) {
216 DCHECK(thread_checker_.CalledOnValidThread()); 216 DCHECK(thread_checker_.CalledOnValidThread());
217 SdchProblemCode rv = CanFetchDictionary(request_url, dictionary_url); 217 SdchProblemCode rv = CanFetchDictionary(request_url, dictionary_url);
218 if (rv != SDCH_OK) 218 if (rv != SDCH_OK)
219 return rv; 219 return rv;
220 220
221 FOR_EACH_OBSERVER(SdchObserver, 221 FOR_EACH_OBSERVER(SdchObserver,
222 observers_, 222 observers_,
223 OnGetDictionary(this, request_url, dictionary_url)); 223 OnGetDictionary(request_url, dictionary_url));
224 224
225 return SDCH_OK; 225 return SDCH_OK;
226 } 226 }
227 227
228 void SdchManager::OnDictionaryUsed(const std::string& server_hash) { 228 void SdchManager::OnDictionaryUsed(const std::string& server_hash) {
229 FOR_EACH_OBSERVER(SdchObserver, observers_, 229 FOR_EACH_OBSERVER(SdchObserver, observers_,
230 OnDictionaryUsed(this, server_hash)); 230 OnDictionaryUsed(server_hash));
231 } 231 }
232 232
233 SdchProblemCode SdchManager::CanFetchDictionary( 233 SdchProblemCode SdchManager::CanFetchDictionary(
234 const GURL& referring_url, 234 const GURL& referring_url,
235 const GURL& dictionary_url) const { 235 const GURL& dictionary_url) const {
236 DCHECK(thread_checker_.CalledOnValidThread()); 236 DCHECK(thread_checker_.CalledOnValidThread());
237 /* The user agent may retrieve a dictionary from the dictionary URL if all of 237 /* The user agent may retrieve a dictionary from the dictionary URL if all of
238 the following are true: 238 the following are true:
239 1 The dictionary URL host name matches the referrer URL host name and 239 1 The dictionary URL host name matches the referrer URL host name and
240 scheme. 240 scheme.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 DVLOG(1) << "Loaded dictionary with client hash " << client_hash 441 DVLOG(1) << "Loaded dictionary with client hash " << client_hash
442 << " and server hash " << server_hash; 442 << " and server hash " << server_hash;
443 SdchDictionary dictionary(dictionary_text, header_end + 2, client_hash, 443 SdchDictionary dictionary(dictionary_text, header_end + 2, client_hash,
444 server_hash, dictionary_url_normalized, domain, 444 server_hash, dictionary_url_normalized, domain,
445 path, expiration, ports); 445 path, expiration, ports);
446 dictionaries_[server_hash] = 446 dictionaries_[server_hash] =
447 new base::RefCountedData<SdchDictionary>(dictionary); 447 new base::RefCountedData<SdchDictionary>(dictionary);
448 if (server_hash_p) 448 if (server_hash_p)
449 *server_hash_p = server_hash; 449 *server_hash_p = server_hash;
450 450
451 FOR_EACH_OBSERVER(SdchObserver, observers_,
452 OnDictionaryAdded(dictionary_url, server_hash));
453
451 return SDCH_OK; 454 return SDCH_OK;
452 } 455 }
453 456
454 SdchProblemCode SdchManager::RemoveSdchDictionary( 457 SdchProblemCode SdchManager::RemoveSdchDictionary(
455 const std::string& server_hash) { 458 const std::string& server_hash) {
456 if (dictionaries_.find(server_hash) == dictionaries_.end()) 459 if (dictionaries_.find(server_hash) == dictionaries_.end())
457 return SDCH_DICTIONARY_HASH_NOT_FOUND; 460 return SDCH_DICTIONARY_HASH_NOT_FOUND;
458 461
459 dictionaries_.erase(server_hash); 462 dictionaries_.erase(server_hash);
463
464 FOR_EACH_OBSERVER(SdchObserver, observers_, OnDictionaryRemoved(server_hash));
465
460 return SDCH_OK; 466 return SDCH_OK;
461 } 467 }
462 468
463 // static 469 // static
464 scoped_ptr<SdchManager::DictionarySet> 470 scoped_ptr<SdchManager::DictionarySet>
465 SdchManager::CreateEmptyDictionarySetForTesting() { 471 SdchManager::CreateEmptyDictionarySetForTesting() {
466 return scoped_ptr<DictionarySet>(new DictionarySet).Pass(); 472 return scoped_ptr<DictionarySet>(new DictionarySet).Pass();
467 } 473 }
468 474
469 // For investigation of http://crbug.com/454198; remove when resolved. 475 // For investigation of http://crbug.com/454198; remove when resolved.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 entry_dict->SetInteger("tries", it->second.count); 523 entry_dict->SetInteger("tries", it->second.count);
518 entry_dict->SetInteger("reason", it->second.reason); 524 entry_dict->SetInteger("reason", it->second.reason);
519 entry_list->Append(entry_dict); 525 entry_list->Append(entry_dict);
520 } 526 }
521 value->Set("blacklisted", entry_list); 527 value->Set("blacklisted", entry_list);
522 528
523 return value; 529 return value;
524 } 530 }
525 531
526 } // namespace net 532 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698