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

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

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/network_change_notifier_win.cc ('k') | net/base/trace_net_log_observer.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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 scoped_ptr<SdchManager::DictionarySet> 449 scoped_ptr<SdchManager::DictionarySet>
450 SdchManager::GetDictionarySetByHash( 450 SdchManager::GetDictionarySetByHash(
451 const GURL& target_url, 451 const GURL& target_url,
452 const std::string& server_hash, 452 const std::string& server_hash,
453 SdchProblemCode* problem_code) { 453 SdchProblemCode* problem_code) {
454 scoped_ptr<SdchManager::DictionarySet> result; 454 scoped_ptr<SdchManager::DictionarySet> result;
455 455
456 *problem_code = SDCH_DICTIONARY_HASH_NOT_FOUND; 456 *problem_code = SDCH_DICTIONARY_HASH_NOT_FOUND;
457 const auto& it = dictionaries_.find(server_hash); 457 const auto& it = dictionaries_.find(server_hash);
458 if (it == dictionaries_.end()) 458 if (it == dictionaries_.end())
459 return result; 459 return result.Pass();
460 460
461 *problem_code = it->second->data.CanUse(target_url); 461 *problem_code = it->second->data.CanUse(target_url);
462 if (*problem_code != SDCH_OK) 462 if (*problem_code != SDCH_OK)
463 return result; 463 return result.Pass();
464 464
465 result.reset(new DictionarySet); 465 result.reset(new DictionarySet);
466 result->AddDictionary(it->first, it->second); 466 result->AddDictionary(it->first, it->second);
467 return result; 467 return result.Pass();
468 } 468 }
469 469
470 // static 470 // static
471 void SdchManager::GenerateHash(const std::string& dictionary_text, 471 void SdchManager::GenerateHash(const std::string& dictionary_text,
472 std::string* client_hash, std::string* server_hash) { 472 std::string* client_hash, std::string* server_hash) {
473 char binary_hash[32]; 473 char binary_hash[32];
474 crypto::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash)); 474 crypto::SHA256HashString(dictionary_text, binary_hash, sizeof(binary_hash));
475 475
476 std::string first_48_bits(&binary_hash[0], 6); 476 std::string first_48_bits(&binary_hash[0], 6);
477 std::string second_48_bits(&binary_hash[6], 6); 477 std::string second_48_bits(&binary_hash[6], 6);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 entry_dict->SetInteger("tries", it->second.count); 666 entry_dict->SetInteger("tries", it->second.count);
667 entry_dict->SetInteger("reason", it->second.reason); 667 entry_dict->SetInteger("reason", it->second.reason);
668 entry_list->Append(entry_dict); 668 entry_list->Append(entry_dict);
669 } 669 }
670 value->Set("blacklisted", entry_list); 670 value->Set("blacklisted", entry_list);
671 671
672 return value; 672 return value;
673 } 673 }
674 674
675 } // namespace net 675 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_change_notifier_win.cc ('k') | net/base/trace_net_log_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698