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

Unified Diff: ui/file_manager/zip_archiver/cpp/volume.cc

Issue 2807063002: Replace Libarchive with MiniZip. (Closed)
Patch Set: Delete BUILD.gn Created 3 years, 8 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
Index: ui/file_manager/zip_archiver/cpp/volume.cc
diff --git a/ui/file_manager/zip_archiver/cpp/volume.cc b/ui/file_manager/zip_archiver/cpp/volume.cc
index 588698f57c291199ede886f2c899912420dfeacc..9fdc3145f1da146257e75cb4df327135296b9b69 100644
--- a/ui/file_manager/zip_archiver/cpp/volume.cc
+++ b/ui/file_manager/zip_archiver/cpp/volume.cc
@@ -330,36 +330,55 @@ void Volume::ReadMetadataCallback(int32_t /*result*/,
// Read and construct metadata.
pp::VarDictionary root_metadata = CreateEntry(-1, "" /* name */, true, 0, 0);
- const char* path_name = NULL;
+ std::string path_name;
int64_t size = 0;
bool is_directory = false;
time_t modification_time = 0;
int64_t index = 0;
for (;;) {
- VolumeArchive::Result ret = volume_archive_->GetNextHeader(
- &path_name, &size, &is_directory, &modification_time);
- if (ret == VolumeArchive::RESULT_FAIL) {
- message_sender_->SendFileSystemError(
- file_system_id_, request_id, volume_archive_->error_message());
+ path_name.clear();
+ if (volume_archive_->GetCurrentFileInfo(
+ &path_name,
+ &size,
+ &is_directory,
+ &modification_time) == VolumeArchive::RESULT_FAIL) {
+ message_sender_->SendFileSystemError(file_system_id_, request_id,
+ volume_archive_->error_message());
ClearJob();
delete volume_archive_;
volume_archive_ = NULL;
return;
- } else if (ret == VolumeArchive::RESULT_EOF)
+ }
+
+ if (path_name.empty()) // End of archive.
break;
- ConstructMetadata(index, path_name, size, is_directory, modification_time,
- &root_metadata);
+ ConstructMetadata(index, path_name.c_str(), size, is_directory,
+ modification_time, &root_metadata);
+
+ index_to_pathname_[index] = path_name;
++index;
+
+ int return_value = volume_archive_->GoToNextFile();
mtomasz 2017/04/10 07:15:09 Please check performance of opening large files. I
takise 2017/04/11 06:00:51 I compared the time to open https://github.com/tor
mtomasz 2017/04/11 06:36:45 Thanks for checking. 2 times slower on such a larg
+ if (return_value == VolumeArchive::RESULT_FAIL) {
+ message_sender_->SendFileSystemError(file_system_id_, request_id,
+ volume_archive_->error_message());
+ ClearJob();
+ delete volume_archive_;
+ volume_archive_ = NULL;
+ return;
+ }
+ if (return_value == VolumeArchive::RESULT_EOF)
+ break;
}
ClearJob();
// Send metadata back to JavaScript.
- message_sender_->SendReadMetadataDone(
- file_system_id_, request_id, root_metadata);
+ message_sender_->SendReadMetadataDone(file_system_id_, request_id,
+ root_metadata);
}
void Volume::OpenFileCallback(int32_t /*result*/,
@@ -379,21 +398,31 @@ void Volume::OpenFileCallback(int32_t /*result*/,
job_lock_.Release();
return;
}
- static_cast<VolumeReaderJavaScriptStream*>(volume_archive_->reader())->
- SetRequestId(args.request_id);
+
+ static_cast<VolumeReaderJavaScriptStream*>(volume_archive_->reader())
+ ->SetRequestId(args.request_id);
reader_request_id_ = args.request_id;
job_lock_.Release();
- if (!volume_archive_->SeekHeader(args.index)) {
- message_sender_->SendFileSystemError(
- file_system_id_, args.request_id, volume_archive_->error_message());
+ std::string path_name = index_to_pathname_[args.index];
+ int64_t size = 0;
+ bool is_directory = false;
+ time_t modification_time = 0;
+
+ if (!volume_archive_->SeekHeader(path_name)) {
+ message_sender_->SendFileSystemError(file_system_id_, args.request_id,
+ volume_archive_->error_message());
ClearJob();
return;
}
- if (volume_archive_->GetNextHeader() == VolumeArchive::RESULT_FAIL) {
- message_sender_->SendFileSystemError(
- file_system_id_, args.request_id, volume_archive_->error_message());
+ if (volume_archive_->GetCurrentFileInfo(
+ &path_name,
+ &size,
+ &is_directory,
+ &modification_time) != VolumeArchive::RESULT_SUCCESS) {
+ message_sender_->SendFileSystemError(file_system_id_, args.request_id,
+ volume_archive_->error_message());
ClearJob();
return;
}

Powered by Google App Engine
This is Rietveld 408576698