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

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

Issue 2525743002: Make URLRequestContext a MemoryDumpProvider (Abandoned) (Closed)
Patch Set: rebased to 7f3d142161b15869f6bea58ac43c5f52ce5834ac Created 4 years 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
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 <limits.h> 7 #include <limits.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/base64url.h" 11 #include "base/base64url.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h"
16 #include "base/time/default_clock.h" 17 #include "base/time/default_clock.h"
18 #include "base/trace_event/memory_allocator_dump.h"
19 #include "base/trace_event/process_memory_dump.h"
17 #include "base/values.h" 20 #include "base/values.h"
18 #include "crypto/sha2.h" 21 #include "crypto/sha2.h"
19 #include "net/base/parse_number.h" 22 #include "net/base/parse_number.h"
20 #include "net/base/sdch_net_log_params.h" 23 #include "net/base/sdch_net_log_params.h"
21 #include "net/base/sdch_observer.h" 24 #include "net/base/sdch_observer.h"
22 #include "net/url_request/url_request_http_job.h" 25 #include "net/url_request/url_request_http_job.h"
23 26
24 namespace { 27 namespace {
25 28
26 void StripTrailingDot(GURL* gurl) { 29 void StripTrailingDot(GURL* gurl) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 320 }
318 321
319 void SdchManager::AddObserver(SdchObserver* observer) { 322 void SdchManager::AddObserver(SdchObserver* observer) {
320 observers_.AddObserver(observer); 323 observers_.AddObserver(observer);
321 } 324 }
322 325
323 void SdchManager::RemoveObserver(SdchObserver* observer) { 326 void SdchManager::RemoveObserver(SdchObserver* observer) {
324 observers_.RemoveObserver(observer); 327 observers_.RemoveObserver(observer);
325 } 328 }
326 329
330 void SdchManager::DumpMemoryStats(
331 base::trace_event::ProcessMemoryDump* pmd) const {
332 std::string name = base::StringPrintf("net/sdch_manager_%p", this);
333 base::trace_event::MemoryAllocatorDump* dictionary_dump =
334 pmd->GetAllocatorDump(name);
335 if (dictionary_dump)
eroman 2016/11/29 22:22:50 What are the circumstances when this would be reac
xunjieli 2016/11/30 16:02:03 Done. URLRequestContexts currently don't share a
336 return;
337 size_t total_size = 0;
338 size_t total_count = 0;
339 for (const auto& dictionary : dictionaries_) {
340 total_size += dictionary.second->data.text().size();
341 ++total_count;
eroman 2016/11/29 22:22:50 maybe just dictionaries_.size() outside of loop?
xunjieli 2016/11/30 16:02:03 Done.
342 }
343 if (total_count == 0)
344 return;
345 dictionary_dump = pmd->CreateAllocatorDump(name);
346 dictionary_dump->AddScalar(
347 base::trace_event::MemoryAllocatorDump::kNameSize,
348 base::trace_event::MemoryAllocatorDump::kUnitsBytes, total_size);
349
350 // Use the existing column name so as not to add a new column.
eroman 2016/11/29 22:22:50 I am not sure what this comment means regarding "e
xunjieli 2016/11/30 16:02:03 Done. Sorry, there is a constant (base::trace_even
351 dictionary_dump->AddScalar(
352 "count", base::trace_event::MemoryAllocatorDump::kUnitsObjects,
353 total_count);
354 }
355
327 SdchProblemCode SdchManager::AddSdchDictionary( 356 SdchProblemCode SdchManager::AddSdchDictionary(
328 const std::string& dictionary_text, 357 const std::string& dictionary_text,
329 const GURL& dictionary_url, 358 const GURL& dictionary_url,
330 std::string* server_hash_p) { 359 std::string* server_hash_p) {
331 DCHECK(thread_checker_.CalledOnValidThread()); 360 DCHECK(thread_checker_.CalledOnValidThread());
332 std::string client_hash; 361 std::string client_hash;
333 std::string server_hash; 362 std::string server_hash;
334 GenerateHash(dictionary_text, &client_hash, &server_hash); 363 GenerateHash(dictionary_text, &client_hash, &server_hash);
335 if (dictionaries_.find(server_hash) != dictionaries_.end()) 364 if (dictionaries_.find(server_hash) != dictionaries_.end())
336 return SDCH_DICTIONARY_ALREADY_LOADED; // Already loaded. 365 return SDCH_DICTIONARY_ALREADY_LOADED; // Already loaded.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 entry_dict->SetInteger("tries", it->second.count); 523 entry_dict->SetInteger("tries", it->second.count);
495 entry_dict->SetInteger("reason", it->second.reason); 524 entry_dict->SetInteger("reason", it->second.reason);
496 entry_list->Append(std::move(entry_dict)); 525 entry_list->Append(std::move(entry_dict));
497 } 526 }
498 value->Set("blacklisted", std::move(entry_list)); 527 value->Set("blacklisted", std::move(entry_list));
499 528
500 return std::move(value); 529 return std::move(value);
501 } 530 }
502 531
503 } // namespace net 532 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698