OLD | NEW |
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/sdch_source_stream.h" | 5 #include "net/filter/sdch_source_stream.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/trace_event/memory_allocator_dump.h" |
| 13 #include "base/trace_event/process_memory_dump.h" |
11 #include "base/values.h" | 14 #include "base/values.h" |
12 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
13 #include "net/log/net_log_capture_mode.h" | 16 #include "net/log/net_log_capture_mode.h" |
14 #include "sdch/open-vcdiff/src/google/vcdecoder.h" | 17 #include "sdch/open-vcdiff/src/google/vcdecoder.h" |
15 | 18 |
16 namespace net { | 19 namespace net { |
17 | 20 |
18 namespace { | 21 namespace { |
19 | 22 |
20 const size_t kServerIdLength = 9; | 23 const size_t kServerIdLength = 9; |
(...skipping 26 matching lines...) Expand all Loading... |
47 decoding_not_finished); | 50 decoding_not_finished); |
48 } | 51 } |
49 | 52 |
50 std::string SdchSourceStream::GetTypeAsString() const { | 53 std::string SdchSourceStream::GetTypeAsString() const { |
51 if (type() == TYPE_SDCH) | 54 if (type() == TYPE_SDCH) |
52 return kSdch; | 55 return kSdch; |
53 DCHECK_EQ(TYPE_SDCH_POSSIBLE, type()); | 56 DCHECK_EQ(TYPE_SDCH_POSSIBLE, type()); |
54 return kSdchPossible; | 57 return kSdchPossible; |
55 } | 58 } |
56 | 59 |
| 60 void SdchSourceStream::DumpMemoryStatsImpl( |
| 61 base::trace_event::ProcessMemoryDump* pmd, |
| 62 const std::string& parent_dump_absolute_name) const { |
| 63 // Log pointer address to avoid duplication though in practice there is |
| 64 // often only one SdchSourceStream per URLRequest. |
| 65 base::trace_event::MemoryAllocatorDump* sdch_dump = |
| 66 pmd->CreateAllocatorDump(base::StringPrintf( |
| 67 "%s/sdch_%p", parent_dump_absolute_name.c_str(), this)); |
| 68 sdch_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 69 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 70 buffered_output_.size()); |
| 71 } |
| 72 |
57 int SdchSourceStream::FilterData(IOBuffer* output_buffer, | 73 int SdchSourceStream::FilterData(IOBuffer* output_buffer, |
58 int output_buffer_size, | 74 int output_buffer_size, |
59 IOBuffer* input_buffer, | 75 IOBuffer* input_buffer, |
60 int input_buffer_size, | 76 int input_buffer_size, |
61 int* consumed_bytes, | 77 int* consumed_bytes, |
62 bool /*upstream_end_reached*/) { | 78 bool /*upstream_end_reached*/) { |
63 DCHECK_LE(0, input_buffer_size); | 79 DCHECK_LE(0, input_buffer_size); |
64 int input_data_size = input_buffer_size; | 80 int input_data_size = input_buffer_size; |
65 char* input_data = input_buffer->data(); | 81 char* input_data = input_buffer->data(); |
66 int bytes_out = 0; | 82 int bytes_out = 0; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 input_state_ = STATE_PASS_THROUGH; | 202 input_state_ = STATE_PASS_THROUGH; |
187 break; | 203 break; |
188 case Delegate::REPLACE_OUTPUT: | 204 case Delegate::REPLACE_OUTPUT: |
189 input_state_ = STATE_OUTPUT_REPLACE; | 205 input_state_ = STATE_OUTPUT_REPLACE; |
190 break; | 206 break; |
191 } | 207 } |
192 return true; | 208 return true; |
193 } | 209 } |
194 | 210 |
195 } // namespace net | 211 } // namespace net |
OLD | NEW |