| 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 | |
| 10 #include <algorithm> | 9 #include <algorithm> |
| 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/url_request/url_request_context.h" | 18 #include "net/url_request/url_request_context.h" |
| 19 | |
| 20 #include "sdch/open-vcdiff/src/google/vcdecoder.h" | 19 #include "sdch/open-vcdiff/src/google/vcdecoder.h" |
| 21 | 20 |
| 22 namespace net { | 21 namespace net { |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 const size_t kServerIdLength = 9; // Dictionary hash plus null from server. | 25 const size_t kServerIdLength = 9; // Dictionary hash plus null from server. |
| 27 | 26 |
| 28 // Disambiguate various types of responses that trigger a meta-refresh, | 27 // Disambiguate various types of responses that trigger a meta-refresh, |
| 29 // failure, or fallback to pass-through. | 28 // failure, or fallback to pass-through. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return cause_string; | 89 return cause_string; |
| 91 } | 90 } |
| 92 | 91 |
| 93 scoped_ptr<base::Value> NetLogSdchResponseCorruptionDetectionCallback( | 92 scoped_ptr<base::Value> NetLogSdchResponseCorruptionDetectionCallback( |
| 94 ResponseCorruptionDetectionCause cause, | 93 ResponseCorruptionDetectionCause cause, |
| 95 bool cached, | 94 bool cached, |
| 96 NetLogCaptureMode capture_mode) { | 95 NetLogCaptureMode capture_mode) { |
| 97 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 96 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 98 dict->SetString("cause", ResponseCorruptionDetectionCauseToString(cause)); | 97 dict->SetString("cause", ResponseCorruptionDetectionCauseToString(cause)); |
| 99 dict->SetBoolean("cached", cached); | 98 dict->SetBoolean("cached", cached); |
| 100 return dict.Pass(); | 99 return std::move(dict); |
| 101 } | 100 } |
| 102 | 101 |
| 103 } // namespace | 102 } // namespace |
| 104 | 103 |
| 105 SdchFilter::SdchFilter(FilterType type, const FilterContext& filter_context) | 104 SdchFilter::SdchFilter(FilterType type, const FilterContext& filter_context) |
| 106 : Filter(type), | 105 : Filter(type), |
| 107 filter_context_(filter_context), | 106 filter_context_(filter_context), |
| 108 decoding_status_(DECODING_UNINITIALIZED), | 107 decoding_status_(DECODING_UNINITIALIZED), |
| 109 dictionary_hash_(), | 108 dictionary_hash_(), |
| 110 dictionary_hash_is_plausible_(false), | 109 dictionary_hash_is_plausible_(false), |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 559 } |
| 561 | 560 |
| 562 void SdchFilter::LogSdchProblem(SdchProblemCode problem) { | 561 void SdchFilter::LogSdchProblem(SdchProblemCode problem) { |
| 563 SdchManager::SdchErrorRecovery(problem); | 562 SdchManager::SdchErrorRecovery(problem); |
| 564 filter_context_.GetNetLog().AddEvent( | 563 filter_context_.GetNetLog().AddEvent( |
| 565 NetLog::TYPE_SDCH_DECODING_ERROR, | 564 NetLog::TYPE_SDCH_DECODING_ERROR, |
| 566 base::Bind(&NetLogSdchResourceProblemCallback, problem)); | 565 base::Bind(&NetLogSdchResourceProblemCallback, problem)); |
| 567 } | 566 } |
| 568 | 567 |
| 569 } // namespace net | 568 } // namespace net |
| OLD | NEW |