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

Side by Side Diff: chrome/utility/safe_browsing/mac/udif.h

Issue 2926473002: Mac Archive Type Sniffing (Closed)
Patch Set: minor edit to comment Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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 #ifndef CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ 5 #ifndef CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_
6 #define CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ 6 #define CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_
7 7
8 #include <CoreFoundation/CoreFoundation.h> 8 #include <CoreFoundation/CoreFoundation.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 12
13 #include <memory> 13 #include <memory>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/mac/scoped_cftyperef.h" 17 #include "base/mac/scoped_cftyperef.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 19
20 namespace safe_browsing { 20 namespace safe_browsing {
21 namespace dmg { 21 namespace dmg {
22 22
23 class ReadStream; 23 class ReadStream;
24 class UDIFBlock; 24 class UDIFBlock;
25 25
Robert Sesek 2017/06/12 20:52:34 nit: no blank line (and sort by type name between
mortonm 2017/06/12 21:39:49 Done.
26 struct UDIFResourceFile;
27
26 // UDIFParser parses a Universal Disk Image Format file, allowing access to the 28 // UDIFParser parses a Universal Disk Image Format file, allowing access to the
27 // name, types, and data of the partitions held within the file. There is no 29 // name, types, and data of the partitions held within the file. There is no
28 // canonical documentation for UDIF, and not all disk images use UDIF (though 30 // canonical documentation for UDIF, and not all disk images use UDIF (though
29 // the majority do). Note that this implementation only handles UDIF and SPARSE 31 // the majority do). Note that this implementation only handles UDIF and SPARSE
30 // image types, not SPARSEBUNDLE. 32 // image types, not SPARSEBUNDLE.
31 // 33 //
32 // No guarantees are made about the position of ReadStream when using an 34 // No guarantees are made about the position of ReadStream when using an
33 // instance of this class. 35 // instance of this class.
34 // 36 //
35 // Note that this implementation relies on the UDIF blkx table to provide 37 // Note that this implementation relies on the UDIF blkx table to provide
(...skipping 28 matching lines...) Expand all
64 std::string GetPartitionType(size_t part_number); 66 std::string GetPartitionType(size_t part_number);
65 67
66 // Returns the size of the partition in bytes. 68 // Returns the size of the partition in bytes.
67 size_t GetPartitionSize(size_t part_number); 69 size_t GetPartitionSize(size_t part_number);
68 70
69 // Returns a stream of the raw partition data for the given partition 71 // Returns a stream of the raw partition data for the given partition
70 // number. 72 // number.
71 std::unique_ptr<ReadStream> GetPartitionReadStream(size_t part_number); 73 std::unique_ptr<ReadStream> GetPartitionReadStream(size_t part_number);
72 74
73 private: 75 private:
74 // Parses the blkx plist trailer structure. 76 // Parses the trailer structure. Only actually parses data from the file the
77 // first time it is called -- after that just returns the previous result when
78 // parsing was attempted.
79 bool ParseTrailer();
80
81 // Parses the blkx plist structure.
75 bool ParseBlkx(); 82 bool ParseBlkx();
76 83
77 ReadStream* const stream_; // The stream backing the UDIF image. Weak. 84 ReadStream* const stream_; // The stream backing the UDIF image. Weak.
78 std::vector<std::string> partition_names_; // The names of all partitions. 85 std::vector<std::string> partition_names_; // The names of all partitions.
79 // All blocks in the UDIF image. 86 // All blocks in the UDIF image.
80 std::vector<std::unique_ptr<const UDIFBlock>> blocks_; 87 std::vector<std::unique_ptr<const UDIFBlock>> blocks_;
81 uint16_t block_size_; // The image's block size, in bytes. 88 uint16_t block_size_; // The image's block size, in bytes.
89 std::unique_ptr<UDIFResourceFile> trailer_;
Robert Sesek 2017/06/12 20:52:34 These two members need comments.
mortonm 2017/06/12 21:39:49 Done.
90 bool trailer_successfully_parsed_;
82 91
83 DISALLOW_COPY_AND_ASSIGN(UDIFParser); 92 DISALLOW_COPY_AND_ASSIGN(UDIFParser);
84 }; 93 };
85 94
86 } // namespace dmg 95 } // namespace dmg
87 } // namespace safe_browsing 96 } // namespace safe_browsing
88 97
89 #endif // CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_ 98 #endif // CHROME_UTILITY_SAFE_BROWSING_MAC_UDIF_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698