OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERATOR_
H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERATOR_
H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERATOR_
H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERATOR_
H_ |
7 | 7 |
8 #include <portabledeviceapi.h> | 8 #include <portabledeviceapi.h> |
9 | 9 |
10 #include <queue> | 10 #include <queue> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/win/scoped_comptr.h" | 17 #include "base/win/scoped_comptr.h" |
18 #include "chrome/browser/media_gallery/win/mtp_device_object_entry.h" | 18 #include "chrome/browser/media_gallery/win/mtp_device_object_entry.h" |
19 #include "webkit/fileapi/file_system_file_util.h" | 19 #include "webkit/fileapi/file_system_file_util.h" |
20 | 20 |
| 21 namespace base { |
21 class FilePath; | 22 class FilePath; |
| 23 } |
22 | 24 |
23 namespace chrome { | 25 namespace chrome { |
24 | 26 |
25 class MTPDeviceObjectEnumerator; | 27 class MTPDeviceObjectEnumerator; |
26 | 28 |
27 // RecursiveMTPDeviceObjectEnumerator is used to recursively enumerate the | 29 // RecursiveMTPDeviceObjectEnumerator is used to recursively enumerate the |
28 // media transfer protocol (MTP) device storage objects from a given media file | 30 // media transfer protocol (MTP) device storage objects from a given media file |
29 // object entries set. RecursiveMTPDeviceObjectEnumerator communicates with the | 31 // object entries set. RecursiveMTPDeviceObjectEnumerator communicates with the |
30 // MTP device to get the subdirectory object entries. | 32 // MTP device to get the subdirectory object entries. |
31 // RecursiveMTPDeviceObjectEnumerator uses MTPDeviceObjectEnumerator to iterate | 33 // RecursiveMTPDeviceObjectEnumerator uses MTPDeviceObjectEnumerator to iterate |
32 // the current directory objects. RecursiveMTPDeviceObjectEnumerator may only be | 34 // the current directory objects. RecursiveMTPDeviceObjectEnumerator may only be |
33 // used on a single thread. | 35 // used on a single thread. |
34 class RecursiveMTPDeviceObjectEnumerator | 36 class RecursiveMTPDeviceObjectEnumerator |
35 : public fileapi::FileSystemFileUtil::AbstractFileEnumerator { | 37 : public fileapi::FileSystemFileUtil::AbstractFileEnumerator { |
36 public: | 38 public: |
37 // MTP |device| should already be initialized and ready for communication. | 39 // MTP |device| should already be initialized and ready for communication. |
38 RecursiveMTPDeviceObjectEnumerator(IPortableDevice* device, | 40 RecursiveMTPDeviceObjectEnumerator(IPortableDevice* device, |
39 const MTPDeviceObjectEntries& entries); | 41 const MTPDeviceObjectEntries& entries); |
40 virtual ~RecursiveMTPDeviceObjectEnumerator(); | 42 virtual ~RecursiveMTPDeviceObjectEnumerator(); |
41 | 43 |
42 // AbstractFileEnumerator: | 44 // AbstractFileEnumerator: |
43 virtual FilePath Next() OVERRIDE; | 45 virtual base::FilePath Next() OVERRIDE; |
44 virtual int64 Size() OVERRIDE; | 46 virtual int64 Size() OVERRIDE; |
45 virtual bool IsDirectory() OVERRIDE; | 47 virtual bool IsDirectory() OVERRIDE; |
46 virtual base::Time LastModifiedTime() OVERRIDE; | 48 virtual base::Time LastModifiedTime() OVERRIDE; |
47 | 49 |
48 private: | 50 private: |
49 // Returns an enumerator for the next non-empty, untraversed subdirectory | 51 // Returns an enumerator for the next non-empty, untraversed subdirectory |
50 // from |untraversed_directory_object_ids_|. | 52 // from |untraversed_directory_object_ids_|. |
51 // Returns NULL if all subdirectories have been traversed. | 53 // Returns NULL if all subdirectories have been traversed. |
52 // The caller owns the returned MTPDeviceObjectEnumerator. | 54 // The caller owns the returned MTPDeviceObjectEnumerator. |
53 scoped_ptr<MTPDeviceObjectEnumerator> GetNextSubdirectoryEnumerator(); | 55 scoped_ptr<MTPDeviceObjectEnumerator> GetNextSubdirectoryEnumerator(); |
54 | 56 |
55 // The portable device. | 57 // The portable device. |
56 base::win::ScopedComPtr<IPortableDevice> device_; | 58 base::win::ScopedComPtr<IPortableDevice> device_; |
57 | 59 |
58 // Enumerator to access current directory Id/path entries. | 60 // Enumerator to access current directory Id/path entries. |
59 scoped_ptr<MTPDeviceObjectEnumerator> current_enumerator_; | 61 scoped_ptr<MTPDeviceObjectEnumerator> current_enumerator_; |
60 | 62 |
61 // Queue of untraversed subdirectories. | 63 // Queue of untraversed subdirectories. |
62 std::queue<string16> untraversed_directory_object_ids_; | 64 std::queue<string16> untraversed_directory_object_ids_; |
63 | 65 |
64 base::ThreadChecker thread_checker_; | 66 base::ThreadChecker thread_checker_; |
65 | 67 |
66 DISALLOW_COPY_AND_ASSIGN(RecursiveMTPDeviceObjectEnumerator); | 68 DISALLOW_COPY_AND_ASSIGN(RecursiveMTPDeviceObjectEnumerator); |
67 }; | 69 }; |
68 | 70 |
69 } // namespace chrome | 71 } // namespace chrome |
70 | 72 |
71 #endif // CHROME_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERAT
OR_H_ | 73 #endif // CHROME_BROWSER_MEDIA_GALLERY_WIN_RECURSIVE_MTP_DEVICE_OBJECT_ENUMERAT
OR_H_ |
OLD | NEW |