Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / utility / safe_browsing / mac / dmg_iterator.h
blob763285c2903dc628b81327f8c128f77e45f747f6
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
3 // found in the LICENSE file.
5 #ifndef CHROME_UTILITY_SAFE_BROWSING_MAC_DMG_ITERATOR_H_
6 #define CHROME_UTILITY_SAFE_BROWSING_MAC_DMG_ITERATOR_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/strings/string16.h"
12 #include "chrome/utility/safe_browsing/mac/udif.h"
14 namespace safe_browsing {
15 namespace dmg {
17 class HFSIterator;
18 class ReadStream;
20 // DMGIterator provides iterator access over all of the concrete files located
21 // on HFS+ and HFSX volumes in a UDIF/DMG file. This class maintains the
22 // limitations of its composed components.
23 class DMGIterator {
24 public:
25 // Creates a DMGIterator from a ReadStream. In most cases, this will be a
26 // FileReadStream opened from a DMG file. This does not take ownership
27 // of the stream.
28 explicit DMGIterator(ReadStream* stream);
29 ~DMGIterator();
31 // Opens the DMG file for iteration. This must be called before any other
32 // method. If this returns false, it is illegal to call any other methods
33 // on this class. If this returns true, the iterator is advanced to an
34 // invalid element before the first item.
35 bool Open();
37 // Advances the iterator to the next file item. Returns true on success
38 // and false on end-of-iterator.
39 bool Next();
41 // Returns the full path in a DMG filesystem to the current file item.
42 base::string16 GetPath();
44 // Returns a ReadStream for the current file item.
45 scoped_ptr<ReadStream> GetReadStream();
47 private:
48 UDIFParser udif_; // The UDIF parser that accesses the partitions.
49 ScopedVector<ReadStream> partitions_; // Streams for all the HFS partitions.
50 size_t current_partition_; // The index in |partitions_| of the current one.
51 scoped_ptr<HFSIterator> hfs_; // The HFSIterator for |current_partition_|.
53 DISALLOW_COPY_AND_ASSIGN(DMGIterator);
56 } // namespace dmg
57 } // namespace safe_browsing
59 #endif // CHROME_UTILITY_SAFE_BROWSING_MAC_DMG_ITERATOR_H_