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 2525743002: Make URLRequestContext a MemoryDumpProvider (Abandoned) (Closed)
Patch Set: self review 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::MemoryAllocatorDump* url_request_context_dump) const {
ssid 2016/12/02 21:36:35 Please pass ProcessMemoryDump* here instead.
332 std::string name = base::StringPrintf("net/sdch_manager_%p", this);
333 base::trace_event::MemoryAllocatorDump* sdch_manager_dump =
334 url_request_context_dump->process_memory_dump()->GetAllocatorDump(name);
ssid 2016/12/02 21:36:35 Please do not use process_memory_dump() method. I
335 // If |this| is shared with another URLRequestContext, add an Ownership Edge
336 // and return early.
337 if (sdch_manager_dump != nullptr) {
338 url_request_context_dump->process_memory_dump()->AddOwnershipEdge(
339 url_request_context_dump->guid(), sdch_manager_dump->guid());
340 return;
341 }
342 // If there are no dictionaries stored, return early without creating a new
343 // MemoryAllocatorDump.
344 size_t total_count = dictionaries_.size();
345 if (total_count == 0)
346 return;
347 sdch_manager_dump =
348 url_request_context_dump->process_memory_dump()->CreateAllocatorDump(
349 name);
350 url_request_context_dump->process_memory_dump()->AddOwnershipEdge(
351 url_request_context_dump->guid(), sdch_manager_dump->guid());
352 size_t total_size = 0;
353 for (const auto& dictionary : dictionaries_) {
354 total_size += dictionary.second->data.text().size();
355 }
356 sdch_manager_dump->AddScalar(
357 base::trace_event::MemoryAllocatorDump::kNameSize,
358 base::trace_event::MemoryAllocatorDump::kUnitsBytes, total_size);
359 sdch_manager_dump->AddScalar(
360 base::trace_event::MemoryAllocatorDump::kNameObjectCount,
361 base::trace_event::MemoryAllocatorDump::kUnitsObjects, total_count);
362 }
363
327 SdchProblemCode SdchManager::AddSdchDictionary( 364 SdchProblemCode SdchManager::AddSdchDictionary(
328 const std::string& dictionary_text, 365 const std::string& dictionary_text,
329 const GURL& dictionary_url, 366 const GURL& dictionary_url,
330 std::string* server_hash_p) { 367 std::string* server_hash_p) {
331 DCHECK(thread_checker_.CalledOnValidThread()); 368 DCHECK(thread_checker_.CalledOnValidThread());
332 std::string client_hash; 369 std::string client_hash;
333 std::string server_hash; 370 std::string server_hash;
334 GenerateHash(dictionary_text, &client_hash, &server_hash); 371 GenerateHash(dictionary_text, &client_hash, &server_hash);
335 if (dictionaries_.find(server_hash) != dictionaries_.end()) 372 if (dictionaries_.find(server_hash) != dictionaries_.end())
336 return SDCH_DICTIONARY_ALREADY_LOADED; // Already loaded. 373 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); 531 entry_dict->SetInteger("tries", it->second.count);
495 entry_dict->SetInteger("reason", it->second.reason); 532 entry_dict->SetInteger("reason", it->second.reason);
496 entry_list->Append(std::move(entry_dict)); 533 entry_list->Append(std::move(entry_dict));
497 } 534 }
498 value->Set("blacklisted", std::move(entry_list)); 535 value->Set("blacklisted", std::move(entry_list));
499 536
500 return std::move(value); 537 return std::move(value);
501 } 538 }
502 539
503 } // namespace net 540 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698