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

Side by Side Diff: net/filter/brotli_source_stream.cc

Issue 2540233002: Instrument SourceStream using MemoryDumpProvider
Patch Set: Rebased 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
« no previous file with comments | « no previous file | net/filter/filter_source_stream.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/filter/brotli_source_stream.h" 5 #include "net/filter/brotli_source_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bit_cast.h" 8 #include "base/bit_cast.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/stringprintf.h"
14 #include "base/trace_event/memory_allocator_dump.h"
15 #include "base/trace_event/process_memory_dump.h"
13 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
14 #include "third_party/brotli/include/brotli/decode.h" 17 #include "third_party/brotli/include/brotli/decode.h"
15 18
16 namespace net { 19 namespace net {
17 20
18 namespace { 21 namespace {
19 22
20 const char kBrotli[] = "BROTLI"; 23 const char kBrotli[] = "BROTLI";
21 const uint8_t kGzipHeader[] = {0x1f, 0x8b, 0x08}; 24 const uint8_t kGzipHeader[] = {0x1f, 0x8b, 0x08};
22 25
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 71
69 // All code here is for gathering stats, and can be removed when 72 // All code here is for gathering stats, and can be removed when
70 // BrotliSourceStream is considered stable. 73 // BrotliSourceStream is considered stable.
71 const int kBuckets = 48; 74 const int kBuckets = 48;
72 const int64_t kMaxKb = 1 << (kBuckets / 3); // 64MiB in KiB 75 const int64_t kMaxKb = 1 << (kBuckets / 3); // 64MiB in KiB
73 UMA_HISTOGRAM_CUSTOM_COUNTS("BrotliFilter.UsedMemoryKB", 76 UMA_HISTOGRAM_CUSTOM_COUNTS("BrotliFilter.UsedMemoryKB",
74 used_memory_maximum_ / 1024, 1, kMaxKb, 77 used_memory_maximum_ / 1024, 1, kMaxKb,
75 kBuckets); 78 kBuckets);
76 } 79 }
77 80
81 void DumpMemoryStatsImpl(
82 base::trace_event::ProcessMemoryDump* pmd,
83 const std::string& parent_dump_absolute_name) const override {
84 // Log pointer address to avoid duplication though in practice there is
85 // often only one BrotliSourceStream per URLRequest.
86 base::trace_event::MemoryAllocatorDump* brotli_dump =
87 pmd->CreateAllocatorDump(base::StringPrintf(
88 "%s/brotli_%p", parent_dump_absolute_name.c_str(), this));
89 brotli_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
90 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
91 used_memory_);
92 }
93
78 private: 94 private:
79 // Reported in UMA and must be kept in sync with the histograms.xml file. 95 // Reported in UMA and must be kept in sync with the histograms.xml file.
80 enum class DecodingStatus : int { 96 enum class DecodingStatus : int {
81 DECODING_IN_PROGRESS = 0, 97 DECODING_IN_PROGRESS = 0,
82 DECODING_DONE, 98 DECODING_DONE,
83 DECODING_ERROR, 99 DECODING_ERROR,
84 100
85 DECODING_STATUS_COUNT 101 DECODING_STATUS_COUNT
86 // DECODING_STATUS_COUNT must always be the last element in this enum. 102 // DECODING_STATUS_COUNT must always be the last element in this enum.
87 }; 103 };
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 }; 210 };
195 211
196 } // namespace 212 } // namespace
197 213
198 std::unique_ptr<FilterSourceStream> CreateBrotliSourceStream( 214 std::unique_ptr<FilterSourceStream> CreateBrotliSourceStream(
199 std::unique_ptr<SourceStream> previous) { 215 std::unique_ptr<SourceStream> previous) {
200 return base::WrapUnique(new BrotliSourceStream(std::move(previous))); 216 return base::WrapUnique(new BrotliSourceStream(std::move(previous)));
201 } 217 }
202 218
203 } // namespace net 219 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/filter/filter_source_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698