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

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

Issue 998803003: Checks to enforce relative lifetimes for SdchManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated comments and fixed else clause. Created 5 years, 9 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 | « net/base/sdch_manager.h ('k') | net/sdch/sdch_owner.h » ('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 "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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 236
237 void SdchManager::DictionarySet::AddDictionary( 237 void SdchManager::DictionarySet::AddDictionary(
238 const std::string& server_hash, 238 const std::string& server_hash,
239 const scoped_refptr<base::RefCountedData<SdchManager::Dictionary>>& 239 const scoped_refptr<base::RefCountedData<SdchManager::Dictionary>>&
240 dictionary) { 240 dictionary) {
241 DCHECK(dictionaries_.end() == dictionaries_.find(server_hash)); 241 DCHECK(dictionaries_.end() == dictionaries_.find(server_hash));
242 242
243 dictionaries_[server_hash] = dictionary; 243 dictionaries_[server_hash] = dictionary;
244 } 244 }
245 245
246 SdchManager::SdchManager() { 246 SdchManager::SdchManager() : factory_(this) {
247 DCHECK(thread_checker_.CalledOnValidThread()); 247 DCHECK(thread_checker_.CalledOnValidThread());
248 } 248 }
249 249
250 SdchManager::~SdchManager() { 250 SdchManager::~SdchManager() {
251 DCHECK(thread_checker_.CalledOnValidThread()); 251 DCHECK(thread_checker_.CalledOnValidThread());
252 while (!dictionaries_.empty()) { 252 while (!dictionaries_.empty()) {
253 auto it = dictionaries_.begin(); 253 auto it = dictionaries_.begin();
254 dictionaries_.erase(it->first); 254 dictionaries_.erase(it->first);
255 } 255 }
256 #if defined(OS_CHROMEOS) 256 #if defined(OS_CHROMEOS)
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 dictionaries_.erase(server_hash); 613 dictionaries_.erase(server_hash);
614 return SDCH_OK; 614 return SDCH_OK;
615 } 615 }
616 616
617 // static 617 // static
618 scoped_ptr<SdchManager::DictionarySet> 618 scoped_ptr<SdchManager::DictionarySet>
619 SdchManager::CreateEmptyDictionarySetForTesting() { 619 SdchManager::CreateEmptyDictionarySetForTesting() {
620 return scoped_ptr<DictionarySet>(new DictionarySet).Pass(); 620 return scoped_ptr<DictionarySet>(new DictionarySet).Pass();
621 } 621 }
622 622
623 // For investigation of http://crbug.com/454198; remove when resolved.
624 base::WeakPtr<SdchManager> SdchManager::GetWeakPtr() {
625 return factory_.GetWeakPtr();
626 }
627
623 // static 628 // static
624 void SdchManager::UrlSafeBase64Encode(const std::string& input, 629 void SdchManager::UrlSafeBase64Encode(const std::string& input,
625 std::string* output) { 630 std::string* output) {
626 // Since this is only done during a dictionary load, and hashes are only 8 631 // Since this is only done during a dictionary load, and hashes are only 8
627 // characters, we just do the simple fixup, rather than rewriting the encoder. 632 // characters, we just do the simple fixup, rather than rewriting the encoder.
628 base::Base64Encode(input, output); 633 base::Base64Encode(input, output);
629 std::replace(output->begin(), output->end(), '+', '-'); 634 std::replace(output->begin(), output->end(), '+', '-');
630 std::replace(output->begin(), output->end(), '/', '_'); 635 std::replace(output->begin(), output->end(), '/', '_');
631 } 636 }
632 637
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 entry_dict->SetInteger("tries", it->second.count); 671 entry_dict->SetInteger("tries", it->second.count);
667 entry_dict->SetInteger("reason", it->second.reason); 672 entry_dict->SetInteger("reason", it->second.reason);
668 entry_list->Append(entry_dict); 673 entry_list->Append(entry_dict);
669 } 674 }
670 value->Set("blacklisted", entry_list); 675 value->Set("blacklisted", entry_list);
671 676
672 return value; 677 return value;
673 } 678 }
674 679
675 } // namespace net 680 } // namespace net
OLDNEW
« no previous file with comments | « net/base/sdch_manager.h ('k') | net/sdch/sdch_owner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698