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 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 } | 331 } |
332 dictionary_hash_.append(next_stream_data_, bytes_needed); | 332 dictionary_hash_.append(next_stream_data_, bytes_needed); |
333 DCHECK(kServerIdLength == dictionary_hash_.size()); | 333 DCHECK(kServerIdLength == dictionary_hash_.size()); |
334 stream_data_len_ -= bytes_needed; | 334 stream_data_len_ -= bytes_needed; |
335 DCHECK_LE(0, stream_data_len_); | 335 DCHECK_LE(0, stream_data_len_); |
336 if (stream_data_len_ > 0) | 336 if (stream_data_len_ > 0) |
337 next_stream_data_ += bytes_needed; | 337 next_stream_data_ += bytes_needed; |
338 else | 338 else |
339 next_stream_data_ = NULL; | 339 next_stream_data_ = NULL; |
340 | 340 |
341 DCHECK(!dictionary_); | 341 DCHECK(!dictionary_.get()); |
342 dictionary_hash_is_plausible_ = true; // Assume plausible, but check. | 342 dictionary_hash_is_plausible_ = true; // Assume plausible, but check. |
343 | 343 |
344 if ('\0' == dictionary_hash_[kServerIdLength - 1]) { | 344 if ('\0' == dictionary_hash_[kServerIdLength - 1]) { |
345 SdchManager* manager(url_request_context_->sdch_manager()); | 345 SdchManager* manager(url_request_context_->sdch_manager()); |
346 manager->GetVcdiffDictionary( | 346 manager->GetVcdiffDictionary( |
347 std::string(dictionary_hash_, 0, kServerIdLength - 1), | 347 std::string(dictionary_hash_, 0, kServerIdLength - 1), |
348 url_, &dictionary_); | 348 url_, &dictionary_); |
349 } else { | 349 } else { |
350 dictionary_hash_is_plausible_ = false; | 350 dictionary_hash_is_plausible_ = false; |
351 } | 351 } |
352 | 352 |
353 if (!dictionary_) { | 353 if (!dictionary_.get()) { |
354 DCHECK(dictionary_hash_.size() == kServerIdLength); | 354 DCHECK(dictionary_hash_.size() == kServerIdLength); |
355 // Since dictionary was not found, check to see if hash was even plausible. | 355 // Since dictionary was not found, check to see if hash was even plausible. |
356 for (size_t i = 0; i < kServerIdLength - 1; ++i) { | 356 for (size_t i = 0; i < kServerIdLength - 1; ++i) { |
357 char base64_char = dictionary_hash_[i]; | 357 char base64_char = dictionary_hash_[i]; |
358 if (!isalnum(base64_char) && '-' != base64_char && '_' != base64_char) { | 358 if (!isalnum(base64_char) && '-' != base64_char && '_' != base64_char) { |
359 dictionary_hash_is_plausible_ = false; | 359 dictionary_hash_is_plausible_ = false; |
360 break; | 360 break; |
361 } | 361 } |
362 } | 362 } |
363 if (dictionary_hash_is_plausible_) | 363 if (dictionary_hash_is_plausible_) |
(...skipping 23 matching lines...) Expand all Loading... |
387 dest_buffer_excess_index_ += amount; | 387 dest_buffer_excess_index_ += amount; |
388 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) { | 388 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) { |
389 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); | 389 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); |
390 dest_buffer_excess_.clear(); | 390 dest_buffer_excess_.clear(); |
391 dest_buffer_excess_index_ = 0; | 391 dest_buffer_excess_index_ = 0; |
392 } | 392 } |
393 return amount; | 393 return amount; |
394 } | 394 } |
395 | 395 |
396 } // namespace net | 396 } // namespace net |
OLD | NEW |