Chromium Code Reviews| Index: third_party/zlib/google/zip_reader.cc |
| diff --git a/third_party/zlib/google/zip_reader.cc b/third_party/zlib/google/zip_reader.cc |
| index 7b7870ee981daf4287255dc50475890f094901e7..5bcc264702f5a959f5dd4ff178ba21cc973d545a 100644 |
| --- a/third_party/zlib/google/zip_reader.cc |
| +++ b/third_party/zlib/google/zip_reader.cc |
| @@ -275,16 +275,10 @@ void ZipReader::ExtractCurrentEntryToFilePathAsync( |
| return; |
| } |
| - const int flags = (base::PLATFORM_FILE_CREATE_ALWAYS | |
| - base::PLATFORM_FILE_WRITE); |
| - bool created = false; |
| - base::PlatformFileError platform_file_error; |
| - base::PlatformFile output_file = CreatePlatformFile(output_file_path, |
| - flags, |
| - &created, |
| - &platform_file_error); |
| - |
| - if (platform_file_error != base::PLATFORM_FILE_OK) { |
| + const int flags = base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE; |
| + base::File output_file(output_file_path, flags); |
| + |
| + if (!output_file.IsValid()) { |
| DVLOG(1) << "Unzip failed: unable to create platform file at " |
| << output_file_path.value(); |
| base::MessageLoopProxy::current()->PostTask(FROM_HERE, failure_callback); |
| @@ -295,7 +289,7 @@ void ZipReader::ExtractCurrentEntryToFilePathAsync( |
| FROM_HERE, |
| base::Bind(&ZipReader::ExtractChunk, |
| weak_ptr_factory_.GetWeakPtr(), |
| - output_file, |
| + Passed(output_file.Pass()), |
| success_callback, |
| failure_callback, |
| progress_callback, |
| @@ -374,7 +368,7 @@ void ZipReader::Reset() { |
| current_entry_info_.reset(); |
| } |
| -void ZipReader::ExtractChunk(base::PlatformFile output_file, |
| +void ZipReader::ExtractChunk(base::File output_file, |
| const SuccessCallback& success_callback, |
| const FailureCallback& failure_callback, |
| const ProgressCallback& progress_callback, |
| @@ -387,20 +381,14 @@ void ZipReader::ExtractChunk(base::PlatformFile output_file, |
| if (num_bytes_read == 0) { |
| unzCloseCurrentFile(zip_file_); |
| - base::ClosePlatformFile(output_file); |
| success_callback.Run(); |
| } else if (num_bytes_read < 0) { |
| DVLOG(1) << "Unzip failed: error while reading zipfile " |
| << "(" << num_bytes_read << ")"; |
| - base::ClosePlatformFile(output_file); |
| failure_callback.Run(); |
| } else { |
| - if (num_bytes_read != base::WritePlatformFile(output_file, |
| - offset, |
| - buffer, |
| - num_bytes_read)) { |
| + if (num_bytes_read != output_file.Write(offset, buffer, num_bytes_read)) { |
| DVLOG(1) << "Unzip failed: unable to write all bytes to target."; |
| - base::ClosePlatformFile(output_file); |
| failure_callback.Run(); |
| return; |
| } |
| @@ -413,7 +401,7 @@ void ZipReader::ExtractChunk(base::PlatformFile output_file, |
| FROM_HERE, |
| base::Bind(&ZipReader::ExtractChunk, |
| weak_ptr_factory_.GetWeakPtr(), |
| - output_file, |
| + Passed(output_file.Pass()), |
|
Drew Haven
2014/02/20 18:38:14
Where does this Pass come from? output_file is no
hshi1
2014/02/20 18:53:14
Interestingly, scoped_ptr does not explicitly defi
|
| success_callback, |
| failure_callback, |
| progress_callback, |