OLD | NEW |
---|---|
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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 void SdchManager::UrlSafeBase64Encode(const std::string& input, | 483 void SdchManager::UrlSafeBase64Encode(const std::string& input, |
484 std::string* output) { | 484 std::string* output) { |
485 // Since this is only done during a dictionary load, and hashes are only 8 | 485 // Since this is only done during a dictionary load, and hashes are only 8 |
486 // characters, we just do the simple fixup, rather than rewriting the encoder. | 486 // characters, we just do the simple fixup, rather than rewriting the encoder. |
487 base::Base64Encode(input, output); | 487 base::Base64Encode(input, output); |
488 std::replace(output->begin(), output->end(), '+', '-'); | 488 std::replace(output->begin(), output->end(), '+', '-'); |
489 std::replace(output->begin(), output->end(), '/', '_'); | 489 std::replace(output->begin(), output->end(), '/', '_'); |
490 } | 490 } |
491 | 491 |
492 base::Value* SdchManager::SdchInfoToValue() const { | 492 base::Value* SdchManager::SdchInfoToValue() const { |
493 base::DictionaryValue* value = new base::DictionaryValue(); | 493 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
494 | 494 |
495 value->SetBoolean("sdch_enabled", sdch_enabled()); | 495 value->SetBoolean("sdch_enabled", sdch_enabled()); |
496 value->SetBoolean("secure_scheme_support", secure_scheme_supported()); | 496 value->SetBoolean("secure_scheme_support", secure_scheme_supported()); |
497 | 497 |
498 base::ListValue* entry_list = new base::ListValue(); | 498 scoped_ptr<base::ListValue> entry_list(new base::ListValue()); |
499 for (const auto& entry: dictionaries_) { | 499 for (const auto& entry: dictionaries_) { |
500 base::DictionaryValue* entry_dict = new base::DictionaryValue(); | 500 scoped_ptr<base::DictionaryValue> entry_dict(new base::DictionaryValue()); |
501 entry_dict->SetString("url", entry.second->data.url().spec()); | 501 entry_dict->SetString("url", entry.second->data.url().spec()); |
502 entry_dict->SetString("client_hash", entry.second->data.client_hash()); | 502 entry_dict->SetString("client_hash", entry.second->data.client_hash()); |
503 entry_dict->SetString("domain", entry.second->data.domain()); | 503 entry_dict->SetString("domain", entry.second->data.domain()); |
504 entry_dict->SetString("path", entry.second->data.path()); | 504 entry_dict->SetString("path", entry.second->data.path()); |
505 base::ListValue* port_list = new base::ListValue(); | 505 scoped_ptr<base::ListValue> port_list(new base::ListValue()); |
506 for (std::set<int>::const_iterator port_it = | 506 for (std::set<int>::const_iterator port_it = |
507 entry.second->data.ports().begin(); | 507 entry.second->data.ports().begin(); |
508 port_it != entry.second->data.ports().end(); ++port_it) { | 508 port_it != entry.second->data.ports().end(); ++port_it) { |
509 port_list->AppendInteger(*port_it); | 509 port_list->AppendInteger(*port_it); |
510 } | 510 } |
511 entry_dict->Set("ports", port_list); | 511 entry_dict->Set("ports", port_list.Pass()); |
512 entry_dict->SetString("server_hash", entry.first); | 512 entry_dict->SetString("server_hash", entry.first); |
513 entry_list->Append(entry_dict); | 513 entry_list->Append(entry_dict.Pass()); |
514 } | 514 } |
515 value->Set("dictionaries", entry_list); | 515 value->Set("dictionaries", entry_list.Pass()); |
516 | 516 |
517 entry_list = new base::ListValue(); | 517 entry_list.reset(); |
eroman
2015/05/22 15:38:28
The bug is here
| |
518 for (DomainBlacklistInfo::const_iterator it = blacklisted_domains_.begin(); | 518 for (DomainBlacklistInfo::const_iterator it = blacklisted_domains_.begin(); |
519 it != blacklisted_domains_.end(); ++it) { | 519 it != blacklisted_domains_.end(); ++it) { |
520 if (it->second.count == 0) | 520 if (it->second.count == 0) |
521 continue; | 521 continue; |
522 base::DictionaryValue* entry_dict = new base::DictionaryValue(); | 522 scoped_ptr<base::DictionaryValue> entry_dict(new base::DictionaryValue()); |
523 entry_dict->SetString("domain", it->first); | 523 entry_dict->SetString("domain", it->first); |
524 if (it->second.count != INT_MAX) | 524 if (it->second.count != INT_MAX) |
525 entry_dict->SetInteger("tries", it->second.count); | 525 entry_dict->SetInteger("tries", it->second.count); |
526 entry_dict->SetInteger("reason", it->second.reason); | 526 entry_dict->SetInteger("reason", it->second.reason); |
527 entry_list->Append(entry_dict); | 527 entry_list->Append(entry_dict.Pass()); |
528 } | 528 } |
529 value->Set("blacklisted", entry_list); | 529 value->Set("blacklisted", entry_list.Pass()); |
530 | 530 |
531 return value; | 531 return value.release(); |
532 } | 532 } |
533 | 533 |
534 } // namespace net | 534 } // namespace net |
OLD | NEW |