| OLD | NEW |
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 510 } |
| 511 | 511 |
| 512 // FileWriterDelegate ---------------------------------------------------------- | 512 // FileWriterDelegate ---------------------------------------------------------- |
| 513 | 513 |
| 514 FileWriterDelegate::FileWriterDelegate(base::File* file) | 514 FileWriterDelegate::FileWriterDelegate(base::File* file) |
| 515 : file_(file), | 515 : file_(file), |
| 516 file_length_(0) { | 516 file_length_(0) { |
| 517 } | 517 } |
| 518 | 518 |
| 519 FileWriterDelegate::~FileWriterDelegate() { | 519 FileWriterDelegate::~FileWriterDelegate() { |
| 520 #if !defined(NDEBUG) | 520 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 521 const bool success = | 521 const bool success = |
| 522 #endif | 522 #endif |
| 523 file_->SetLength(file_length_); | 523 file_->SetLength(file_length_); |
| 524 DPLOG_IF(ERROR, !success) << "Failed updating length of written file"; | 524 DPLOG_IF(ERROR, !success) << "Failed updating length of written file"; |
| 525 } | 525 } |
| 526 | 526 |
| 527 bool FileWriterDelegate::PrepareOutput() { | 527 bool FileWriterDelegate::PrepareOutput() { |
| 528 return file_->Seek(base::File::FROM_BEGIN, 0) >= 0; | 528 return file_->Seek(base::File::FROM_BEGIN, 0) >= 0; |
| 529 } | 529 } |
| 530 | 530 |
| 531 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { | 531 bool FileWriterDelegate::WriteBytes(const char* data, int num_bytes) { |
| 532 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes); | 532 int bytes_written = file_->WriteAtCurrentPos(data, num_bytes); |
| 533 if (bytes_written > 0) | 533 if (bytes_written > 0) |
| 534 file_length_ += bytes_written; | 534 file_length_ += bytes_written; |
| 535 return bytes_written == num_bytes; | 535 return bytes_written == num_bytes; |
| 536 } | 536 } |
| 537 | 537 |
| 538 } // namespace zip | 538 } // namespace zip |
| OLD | NEW |