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

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

Issue 1152103003: Returning scoped_ptr in SdchInfoToValue() instead of raw pointers in net/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review comments 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
« no previous file with comments | « net/base/sdch_manager.h ('k') | net/log/net_log_util.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 "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
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
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
OLDNEW
« no previous file with comments | « net/base/sdch_manager.h ('k') | net/log/net_log_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698