| 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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 // static | 482 // static |
| 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 scoped_ptr<base::Value> SdchManager::SdchInfoToValue() const { |
| 493 scoped_ptr<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 scoped_ptr<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 scoped_ptr<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()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 521 continue; | 521 continue; |
| 522 scoped_ptr<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.Pass()); | 527 entry_list->Append(entry_dict.Pass()); |
| 528 } | 528 } |
| 529 value->Set("blacklisted", entry_list.Pass()); | 529 value->Set("blacklisted", entry_list.Pass()); |
| 530 | 530 |
| 531 return value.release(); | 531 return value.Pass(); |
| 532 } | 532 } |
| 533 | 533 |
| 534 } // namespace net | 534 } // namespace net |
| OLD | NEW |