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

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

Issue 321283002: Clear SDCH information on "Clear browsing data" path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments. Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « net/base/sdch_manager_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 329 }
330 dictionary_hash_.append(next_stream_data_, bytes_needed); 330 dictionary_hash_.append(next_stream_data_, bytes_needed);
331 DCHECK(kServerIdLength == dictionary_hash_.size()); 331 DCHECK(kServerIdLength == dictionary_hash_.size());
332 stream_data_len_ -= bytes_needed; 332 stream_data_len_ -= bytes_needed;
333 DCHECK_LE(0, stream_data_len_); 333 DCHECK_LE(0, stream_data_len_);
334 if (stream_data_len_ > 0) 334 if (stream_data_len_ > 0)
335 next_stream_data_ += bytes_needed; 335 next_stream_data_ += bytes_needed;
336 else 336 else
337 next_stream_data_ = NULL; 337 next_stream_data_ = NULL;
338 338
339 DCHECK(!dictionary_.get()); 339 DCHECK(!dictionary_);
340 dictionary_hash_is_plausible_ = true; // Assume plausible, but check. 340 dictionary_hash_is_plausible_ = true; // Assume plausible, but check.
341 341
342 SdchManager::Dictionary* dictionary = NULL;
343 if ('\0' == dictionary_hash_[kServerIdLength - 1]) { 342 if ('\0' == dictionary_hash_[kServerIdLength - 1]) {
344 SdchManager* manager(url_request_context_->sdch_manager()); 343 SdchManager* manager(url_request_context_->sdch_manager());
345 manager->GetVcdiffDictionary( 344 manager->GetVcdiffDictionary(
346 std::string(dictionary_hash_, 0, kServerIdLength - 1), 345 std::string(dictionary_hash_, 0, kServerIdLength - 1),
347 url_, &dictionary); 346 url_, &dictionary_);
348 } else { 347 } else {
349 dictionary_hash_is_plausible_ = false; 348 dictionary_hash_is_plausible_ = false;
350 } 349 }
351 350
352 if (!dictionary) { 351 if (!dictionary_) {
353 DCHECK(dictionary_hash_.size() == kServerIdLength); 352 DCHECK(dictionary_hash_.size() == kServerIdLength);
354 // Since dictionary was not found, check to see if hash was even plausible. 353 // Since dictionary was not found, check to see if hash was even plausible.
355 for (size_t i = 0; i < kServerIdLength - 1; ++i) { 354 for (size_t i = 0; i < kServerIdLength - 1; ++i) {
356 char base64_char = dictionary_hash_[i]; 355 char base64_char = dictionary_hash_[i];
357 if (!isalnum(base64_char) && '-' != base64_char && '_' != base64_char) { 356 if (!isalnum(base64_char) && '-' != base64_char && '_' != base64_char) {
358 dictionary_hash_is_plausible_ = false; 357 dictionary_hash_is_plausible_ = false;
359 break; 358 break;
360 } 359 }
361 } 360 }
362 if (dictionary_hash_is_plausible_) 361 if (dictionary_hash_is_plausible_)
363 SdchManager::SdchErrorRecovery(SdchManager::DICTIONARY_HASH_NOT_FOUND); 362 SdchManager::SdchErrorRecovery(SdchManager::DICTIONARY_HASH_NOT_FOUND);
364 else 363 else
365 SdchManager::SdchErrorRecovery(SdchManager::DICTIONARY_HASH_MALFORMED); 364 SdchManager::SdchErrorRecovery(SdchManager::DICTIONARY_HASH_MALFORMED);
366 decoding_status_ = DECODING_ERROR; 365 decoding_status_ = DECODING_ERROR;
367 return FILTER_ERROR; 366 return FILTER_ERROR;
368 } 367 }
369 dictionary_ = dictionary;
370 vcdiff_streaming_decoder_.reset(new open_vcdiff::VCDiffStreamingDecoder); 368 vcdiff_streaming_decoder_.reset(new open_vcdiff::VCDiffStreamingDecoder);
371 vcdiff_streaming_decoder_->SetAllowVcdTarget(false); 369 vcdiff_streaming_decoder_->SetAllowVcdTarget(false);
372 vcdiff_streaming_decoder_->StartDecoding(dictionary_->text().data(), 370 vcdiff_streaming_decoder_->StartDecoding(dictionary_->text().data(),
373 dictionary_->text().size()); 371 dictionary_->text().size());
374 decoding_status_ = DECODING_IN_PROGRESS; 372 decoding_status_ = DECODING_IN_PROGRESS;
375 return FILTER_OK; 373 return FILTER_OK;
376 } 374 }
377 375
378 int SdchFilter::OutputBufferExcess(char* const dest_buffer, 376 int SdchFilter::OutputBufferExcess(char* const dest_buffer,
379 size_t available_space) { 377 size_t available_space) {
380 if (dest_buffer_excess_.empty()) 378 if (dest_buffer_excess_.empty())
381 return 0; 379 return 0;
382 DCHECK(dest_buffer_excess_.size() > dest_buffer_excess_index_); 380 DCHECK(dest_buffer_excess_.size() > dest_buffer_excess_index_);
383 size_t amount = std::min(available_space, 381 size_t amount = std::min(available_space,
384 dest_buffer_excess_.size() - dest_buffer_excess_index_); 382 dest_buffer_excess_.size() - dest_buffer_excess_index_);
385 memcpy(dest_buffer, dest_buffer_excess_.data() + dest_buffer_excess_index_, 383 memcpy(dest_buffer, dest_buffer_excess_.data() + dest_buffer_excess_index_,
386 amount); 384 amount);
387 dest_buffer_excess_index_ += amount; 385 dest_buffer_excess_index_ += amount;
388 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) { 386 if (dest_buffer_excess_.size() <= dest_buffer_excess_index_) {
389 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_); 387 DCHECK(dest_buffer_excess_.size() == dest_buffer_excess_index_);
390 dest_buffer_excess_.clear(); 388 dest_buffer_excess_.clear();
391 dest_buffer_excess_index_ = 0; 389 dest_buffer_excess_index_ = 0;
392 } 390 }
393 return amount; 391 return amount;
394 } 392 }
395 393
396 } // namespace net 394 } // namespace net
OLDNEW
« no previous file with comments | « net/base/sdch_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698