OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_filter.h" | 5 #include "net/filter/sdch_filter.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
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/values.h" | 14 #include "base/values.h" |
15 #include "net/base/sdch_manager.h" | 15 #include "net/base/sdch_manager.h" |
16 #include "net/base/sdch_net_log_params.h" | 16 #include "net/base/sdch_net_log_params.h" |
17 #include "net/base/sdch_problem_codes.h" | 17 #include "net/base/sdch_problem_codes.h" |
| 18 #include "net/log/net_log_event_type.h" |
18 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
19 #include "sdch/open-vcdiff/src/google/vcdecoder.h" | 20 #include "sdch/open-vcdiff/src/google/vcdecoder.h" |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 const size_t kServerIdLength = 9; // Dictionary hash plus null from server. | 26 const size_t kServerIdLength = 9; // Dictionary hash plus null from server. |
26 | 27 |
27 // Disambiguate various types of responses that trigger a meta-refresh, | 28 // Disambiguate various types of responses that trigger a meta-refresh, |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // Use if statement rather than ?: because UMA_HISTOGRAM_ENUMERATION | 332 // Use if statement rather than ?: because UMA_HISTOGRAM_ENUMERATION |
332 // caches the histogram name based on the call site. | 333 // caches the histogram name based on the call site. |
333 if (filter_context_.IsCachedContent()) { | 334 if (filter_context_.IsCachedContent()) { |
334 UMA_HISTOGRAM_ENUMERATION( | 335 UMA_HISTOGRAM_ENUMERATION( |
335 "Sdch3.ResponseCorruptionDetection.Cached", cause, RESPONSE_MAX); | 336 "Sdch3.ResponseCorruptionDetection.Cached", cause, RESPONSE_MAX); |
336 } else { | 337 } else { |
337 UMA_HISTOGRAM_ENUMERATION( | 338 UMA_HISTOGRAM_ENUMERATION( |
338 "Sdch3.ResponseCorruptionDetection.Uncached", cause, RESPONSE_MAX); | 339 "Sdch3.ResponseCorruptionDetection.Uncached", cause, RESPONSE_MAX); |
339 } | 340 } |
340 filter_context_.GetNetLog().AddEvent( | 341 filter_context_.GetNetLog().AddEvent( |
341 NetLog::TYPE_SDCH_RESPONSE_CORRUPTION_DETECTION, | 342 NetLogEventType::SDCH_RESPONSE_CORRUPTION_DETECTION, |
342 base::Bind(&NetLogSdchResponseCorruptionDetectionCallback, cause, | 343 base::Bind(&NetLogSdchResponseCorruptionDetectionCallback, cause, |
343 filter_context_.IsCachedContent())); | 344 filter_context_.IsCachedContent())); |
344 | 345 |
345 if (decoding_status_ == PASS_THROUGH) { | 346 if (decoding_status_ == PASS_THROUGH) { |
346 dest_buffer_excess_ = dictionary_hash_; // Send what we scanned. | 347 dest_buffer_excess_ = dictionary_hash_; // Send what we scanned. |
347 } else { | 348 } else { |
348 // This is where we try to do the expensive meta-refresh. | 349 // This is where we try to do the expensive meta-refresh. |
349 if (std::string::npos == mime_type_.find("text/html")) { | 350 if (std::string::npos == mime_type_.find("text/html")) { |
350 // Since we can't do a meta-refresh (along with an exponential | 351 // Since we can't do a meta-refresh (along with an exponential |
351 // backoff), we'll just make sure this NEVER happens again. | 352 // backoff), we'll just make sure this NEVER happens again. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); | 555 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); |
555 dest_buffer_excess_.clear(); | 556 dest_buffer_excess_.clear(); |
556 dest_buffer_excess_index_ = 0; | 557 dest_buffer_excess_index_ = 0; |
557 } | 558 } |
558 return amount; | 559 return amount; |
559 } | 560 } |
560 | 561 |
561 void SdchFilter::LogSdchProblem(SdchProblemCode problem) { | 562 void SdchFilter::LogSdchProblem(SdchProblemCode problem) { |
562 SdchManager::SdchErrorRecovery(problem); | 563 SdchManager::SdchErrorRecovery(problem); |
563 filter_context_.GetNetLog().AddEvent( | 564 filter_context_.GetNetLog().AddEvent( |
564 NetLog::TYPE_SDCH_DECODING_ERROR, | 565 NetLogEventType::SDCH_DECODING_ERROR, |
565 base::Bind(&NetLogSdchResourceProblemCallback, problem)); | 566 base::Bind(&NetLogSdchResourceProblemCallback, problem)); |
566 } | 567 } |
567 | 568 |
568 } // namespace net | 569 } // namespace net |
OLD | NEW |