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

Unified Diff: third_party/zlib/google/zip_reader.cc

Issue 166573007: Remove some PlatformFile uses from zlib (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Yet another rebase Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/zlib/google/zip_reader.h ('k') | third_party/zlib/google/zip_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()),
success_callback,
failure_callback,
progress_callback,
« no previous file with comments | « third_party/zlib/google/zip_reader.h ('k') | third_party/zlib/google/zip_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698