| OLD | NEW |
| 1 // Copyright 2014 The Chromium OS Authors. All rights reserved. | 1 // Copyright 2014 The Chromium OS 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 "volume.h" | 5 #include "volume.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "request.h" | 10 #include "request.h" |
| 11 #include "volume_archive_libarchive.h" | 11 #include "volume_archive_libarchive.h" |
| 12 #include "volume_reader_javascript_stream.h" | 12 #include "volume_reader_javascript_stream.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 #define LOG(x) \ | 16 #define LOG(x) \ |
| 17 do { \ | 17 do { \ |
| 18 std::stringstream fmt; \ | 18 std::stringstream fmt; \ |
| 19 fmt << x; \ | 19 fmt << x; \ |
| 20 message_sender_->CONSOLE_LOG(file_system_id_, request_id, fmt.str()); \ | 20 message_sender_->CONSOLE_LOG(file_system_id_, request_id, fmt.str()); \ |
| 21 } while (0) | 21 } while (0) |
| 22 | 22 |
| 23 typedef std::map<std::string, VolumeArchive*>::const_iterator | 23 typedef std::map<std::string, VolumeArchive*>::const_iterator |
| 24 volume_archive_iterator; | 24 volume_archive_iterator; |
| 25 | 25 |
| 26 const char kPathDelimiter[] = "/"; | 26 const char kPathDelimiter[] = "/"; |
| 27 | 27 |
| 28 // size is int64_t and modification_time is time_t because this is how | 28 // size is int64_t and modification_time is time_t because this is how |
| 29 // libarchive is going to pass them to us. | 29 // minizip is going to pass them to us. |
| 30 pp::VarDictionary CreateEntry(int64_t index, | 30 pp::VarDictionary CreateEntry(int64_t index, |
| 31 const std::string& name, | 31 const std::string& name, |
| 32 bool is_directory, | 32 bool is_directory, |
| 33 int64_t size, | 33 int64_t size, |
| 34 time_t modification_time) { | 34 time_t modification_time) { |
| 35 pp::VarDictionary entry_metadata; | 35 pp::VarDictionary entry_metadata; |
| 36 // index is int64_t, unsupported by pp::Var | 36 // index is int64_t, unsupported by pp::Var |
| 37 std::stringstream ss_index; | 37 std::stringstream ss_index; |
| 38 ss_index << index; | 38 ss_index << index; |
| 39 entry_metadata.Set("index", ss_index.str()); | 39 entry_metadata.Set("index", ss_index.str()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 Volume* volume_; | 139 Volume* volume_; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 // An internal implementation of VolumeArchiveFactoryInterface for default | 142 // An internal implementation of VolumeArchiveFactoryInterface for default |
| 143 // Volume constructor. | 143 // Volume constructor. |
| 144 class VolumeArchiveFactory : public VolumeArchiveFactoryInterface { | 144 class VolumeArchiveFactory : public VolumeArchiveFactoryInterface { |
| 145 public: | 145 public: |
| 146 virtual VolumeArchive* Create(VolumeReader* reader) { | 146 virtual VolumeArchive* Create(VolumeReader* reader) { |
| 147 return new VolumeArchiveLibarchive(reader); | 147 return new VolumeArchiveMinizip(reader); |
| 148 } | 148 } |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 // An internal implementation of VolumeReaderFactoryInterface for default Volume | 151 // An internal implementation of VolumeReaderFactoryInterface for default Volume |
| 152 // constructor. | 152 // constructor. |
| 153 class VolumeReaderFactory : public VolumeReaderFactoryInterface { | 153 class VolumeReaderFactory : public VolumeReaderFactoryInterface { |
| 154 public: | 154 public: |
| 155 // VolumeReaderFactory does not own the volume pointer. | 155 // VolumeReaderFactory does not own the volume pointer. |
| 156 explicit VolumeReaderFactory(Volume* volume) : volume_(volume) {} | 156 explicit VolumeReaderFactory(Volume* volume) : volume_(volume) {} |
| 157 | 157 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 } | 509 } |
| 510 volume_archive_->MaybeDecompressAhead(); | 510 volume_archive_->MaybeDecompressAhead(); |
| 511 } | 511 } |
| 512 | 512 |
| 513 | 513 |
| 514 void Volume::ClearJob() { | 514 void Volume::ClearJob() { |
| 515 job_lock_.Acquire(); | 515 job_lock_.Acquire(); |
| 516 reader_request_id_ = ""; | 516 reader_request_id_ = ""; |
| 517 job_lock_.Release(); | 517 job_lock_.Release(); |
| 518 } | 518 } |
| OLD | NEW |