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

Side by Side Diff: third_party/zlib/google/zip_reader.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « third_party/zlib/google.patch ('k') | third_party/zlib/gzlib.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "third_party/zlib/google/zip_reader.h" 5 #include "third_party/zlib/google/zip_reader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 357
358 const int open_result = unzOpenCurrentFile(zip_file_); 358 const int open_result = unzOpenCurrentFile(zip_file_);
359 if (open_result != UNZ_OK) 359 if (open_result != UNZ_OK)
360 return false; 360 return false;
361 361
362 // The original_size() is the best hint for the real size, so it saves 362 // The original_size() is the best hint for the real size, so it saves
363 // doing reallocations for the common case when the uncompressed size is 363 // doing reallocations for the common case when the uncompressed size is
364 // correct. However, we need to assume that the uncompressed size could be 364 // correct. However, we need to assume that the uncompressed size could be
365 // incorrect therefore this function needs to read as much data as possible. 365 // incorrect therefore this function needs to read as much data as possible.
366 std::string contents; 366 std::string contents;
367 contents.reserve(std::min<size_t>( 367 contents.reserve(static_cast<size_t>(std::min(
368 max_read_bytes, current_entry_info()->original_size())); 368 static_cast<int64>(max_read_bytes),
369 current_entry_info()->original_size())));
369 370
370 bool success = true; // This becomes false when something bad happens. 371 bool success = true; // This becomes false when something bad happens.
371 char buf[internal::kZipBufSize]; 372 char buf[internal::kZipBufSize];
372 while (true) { 373 while (true) {
373 const int num_bytes_read = unzReadCurrentFile(zip_file_, buf, 374 const int num_bytes_read = unzReadCurrentFile(zip_file_, buf,
374 internal::kZipBufSize); 375 internal::kZipBufSize);
375 if (num_bytes_read == 0) { 376 if (num_bytes_read == 0) {
376 // Reached the end of the file. 377 // Reached the end of the file.
377 break; 378 break;
378 } else if (num_bytes_read < 0) { 379 } else if (num_bytes_read < 0) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 success_callback, 456 success_callback,
456 failure_callback, 457 failure_callback,
457 progress_callback, 458 progress_callback,
458 current_progress)); 459 current_progress));
459 460
460 } 461 }
461 } 462 }
462 463
463 464
464 } // namespace zip 465 } // namespace zip
OLDNEW
« no previous file with comments | « third_party/zlib/google.patch ('k') | third_party/zlib/gzlib.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698