OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium 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 "chrome/utility/safe_browsing/mac/udif.h" | 5 #include "chrome/utility/safe_browsing/mac/udif.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #include <bzlib.h> | 8 #include <bzlib.h> |
9 #include <libkern/OSByteOrder.h> | 9 #include <libkern/OSByteOrder.h> |
10 #include <uuid/uuid.h> | 10 #include <uuid/uuid.h> |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 DCHECK_LT(part_number, blocks_.size()); | 395 DCHECK_LT(part_number, blocks_.size()); |
396 auto size = | 396 auto size = |
397 base::CheckedNumeric<size_t>(blocks_[part_number]->sector_count()) * | 397 base::CheckedNumeric<size_t>(blocks_[part_number]->sector_count()) * |
398 block_size_; | 398 block_size_; |
399 return size.ValueOrDie(); | 399 return size.ValueOrDie(); |
400 } | 400 } |
401 | 401 |
402 std::unique_ptr<ReadStream> UDIFParser::GetPartitionReadStream( | 402 std::unique_ptr<ReadStream> UDIFParser::GetPartitionReadStream( |
403 size_t part_number) { | 403 size_t part_number) { |
404 DCHECK_LT(part_number, blocks_.size()); | 404 DCHECK_LT(part_number, blocks_.size()); |
405 return base::WrapUnique( | 405 return base::MakeUnique<UDIFPartitionReadStream>(stream_, block_size_, |
406 new UDIFPartitionReadStream(stream_, block_size_, blocks_[part_number])); | 406 blocks_[part_number]); |
407 } | 407 } |
408 | 408 |
409 bool UDIFParser::ParseBlkx() { | 409 bool UDIFParser::ParseBlkx() { |
410 UDIFResourceFile trailer; | 410 UDIFResourceFile trailer; |
411 off_t trailer_start = stream_->Seek(-sizeof(trailer), SEEK_END); | 411 off_t trailer_start = stream_->Seek(-sizeof(trailer), SEEK_END); |
412 if (trailer_start == -1) | 412 if (trailer_start == -1) |
413 return false; | 413 return false; |
414 | 414 |
415 if (!stream_->ReadType(&trailer)) { | 415 if (!stream_->ReadType(&trailer)) { |
416 DLOG(ERROR) << "Failed to read UDIFResourceFile"; | 416 DLOG(ERROR) << "Failed to read UDIFResourceFile"; |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 << chunk_->compressed_offset; | 857 << chunk_->compressed_offset; |
858 return false; | 858 return false; |
859 } | 859 } |
860 return true; | 860 return true; |
861 } | 861 } |
862 | 862 |
863 } // namespace | 863 } // namespace |
864 | 864 |
865 } // namespace dmg | 865 } // namespace dmg |
866 } // namespace safe_browsing | 866 } // namespace safe_browsing |
OLD | NEW |