diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 09:32:13 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 09:32:13 +0000 |
commit | 987b044ce86bca6971f21d0125a51ec9c390d64d (patch) | |
tree | b96ee2765d8385a7c8622330fbdde07aec4e1e8d /third_party/zlib | |
parent | 13dc64931ce67164365bc77ac6362f3eb3791735 (diff) | |
download | chromium_src-987b044ce86bca6971f21d0125a51ec9c390d64d.zip chromium_src-987b044ce86bca6971f21d0125a51ec9c390d64d.tar.gz chromium_src-987b044ce86bca6971f21d0125a51ec9c390d64d.tar.bz2 |
Stop using net::FileStream synchronously in third_party/zlib
Use base::File instead
BUG=351823
TEST=unit_tests
Review URL: https://codereview.chromium.org/204983012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258897 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/zlib')
-rw-r--r-- | third_party/zlib/google/DEPS | 3 | ||||
-rw-r--r-- | third_party/zlib/google/zip.cc | 13 | ||||
-rw-r--r-- | third_party/zlib/google/zip_reader.cc | 15 |
3 files changed, 12 insertions, 19 deletions
diff --git a/third_party/zlib/google/DEPS b/third_party/zlib/google/DEPS deleted file mode 100644 index 6a2f02e..0000000 --- a/third_party/zlib/google/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - "+net/base", -] diff --git a/third_party/zlib/google/zip.cc b/third_party/zlib/google/zip.cc index 52fc694..5fbfca9 100644 --- a/third_party/zlib/google/zip.cc +++ b/third_party/zlib/google/zip.cc @@ -8,12 +8,11 @@ #include <vector> #include "base/bind.h" -#include "base/file_util.h" +#include "base/files/file.h" #include "base/files/file_enumerator.h" #include "base/logging.h" #include "base/strings/string16.h" #include "base/strings/string_util.h" -#include "net/base/file_stream.h" #include "third_party/zlib/google/zip_internal.h" #include "third_party/zlib/google/zip_reader.h" @@ -60,18 +59,16 @@ zip_fileinfo GetFileInfoForZipping(const base::FilePath& path) { } bool AddFileToZip(zipFile zip_file, const base::FilePath& src_dir) { - net::FileStream stream(NULL); - int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; - if (stream.OpenSync(src_dir, flags) != 0) { - DLOG(ERROR) << "Could not open stream for path " - << src_dir.value(); + base::File file(src_dir, base::File::FLAG_OPEN | base::File::FLAG_READ); + if (!file.IsValid()) { + DLOG(ERROR) << "Could not open file for path " << src_dir.value(); return false; } int num_bytes; char buf[zip::internal::kZipBufSize]; do { - num_bytes = stream.ReadSync(buf, zip::internal::kZipBufSize); + num_bytes = file.ReadAtCurrentPos(buf, zip::internal::kZipBufSize); if (num_bytes > 0) { if (ZIP_OK != zipWriteInFileInZip(zip_file, buf, num_bytes)) { DLOG(ERROR) << "Could not write data to zip for path " diff --git a/third_party/zlib/google/zip_reader.cc b/third_party/zlib/google/zip_reader.cc index 915dbbc..f34f4f7 100644 --- a/third_party/zlib/google/zip_reader.cc +++ b/third_party/zlib/google/zip_reader.cc @@ -4,12 +4,12 @@ #include "third_party/zlib/google/zip_reader.h" -#include "base/file_util.h" +#include "base/bind.h" +#include "base/files/file.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "net/base/file_stream.h" #include "third_party/zlib/google/zip_internal.h" #if defined(USE_SYSTEM_MINIZIP) @@ -205,10 +205,9 @@ bool ZipReader::ExtractCurrentEntryToFilePath( if (!base::CreateDirectory(output_dir_path)) return false; - net::FileStream stream(NULL); - const int flags = (base::PLATFORM_FILE_CREATE_ALWAYS | - base::PLATFORM_FILE_WRITE); - if (stream.OpenSync(output_file_path, flags) != 0) + base::File file(output_file_path, + base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); + if (!file.IsValid()) return false; bool success = true; // This becomes false when something bad happens. @@ -225,14 +224,14 @@ bool ZipReader::ExtractCurrentEntryToFilePath( break; } else if (num_bytes_read > 0) { // Some data is read. Write it to the output file. - if (num_bytes_read != stream.WriteSync(buf, num_bytes_read)) { + if (num_bytes_read != file.WriteAtCurrentPos(buf, num_bytes_read)) { success = false; break; } } } - stream.CloseSync(); + file.Close(); unzCloseCurrentFile(zip_file_); if (current_entry_info()->last_modified() != base::Time::UnixEpoch()) |