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

Side by Side Diff: chrome/browser/media_gallery/mac/mtp_device_delegate_impl_mac.h

Issue 11416089: [Media Galleries] Filesystem interface for Mac PTP/MTP devices using ImageCaptureCore (part 3) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move files Created 8 years 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
(Empty)
1 // Copyright (c) 2012 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.
4
5 #ifndef CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_MAC_H_
6 #define CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_MAC_H_
7
8 #include <vector>
9 #include "base/file_path.h"
10 #include "base/hash_tables.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/platform_file.h"
13 #include "base/synchronization/waitable_event.h"
14 #include "webkit/fileapi/file_system_file_util.h"
15 #include "webkit/fileapi/media/mtp_device_delegate.h"
16
17 namespace base {
18 class SequencedTaskRunner;
19 }
20
21 namespace chrome {
22
23 class CameraDeviceInterface;
24
25 // Delegate for presenting an Image Capture device through the filesystem
26 // API. The synthetic filesystem will be rooted at the constructed location,
27 // and names of non-directories notified through the ItemAdded call will be
28 // all appear as children of that directory.
29 class MTPDeviceDelegateImplMac : public fileapi::MTPDeviceDelegate {
30 public:
31 MTPDeviceDelegateImplMac(const FilePath::StringType& location,
32 base::SequencedTaskRunner* media_task_runner);
33 // Destructed via CancelPendingTasksAndDeleteDelegate. Do not call directly.
34 virtual ~MTPDeviceDelegateImplMac();
35
36 // MTPDeviceDelegate:
37 virtual base::PlatformFileError GetFileInfo(
38 const FilePath& file_path,
39 base::PlatformFileInfo* file_info) OVERRIDE;
40 virtual scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator>
41 CreateFileEnumerator(const FilePath& root, bool recursive) OVERRIDE;
42 virtual base::PlatformFileError CreateSnapshotFile(
43 const FilePath& device_file_path,
44 const FilePath& local_path,
45 base::PlatformFileInfo* file_info) OVERRIDE;
46 virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
47
48 // Forward delegates for ImageCaptureDeviceListener
49 virtual void ItemAdded(const std::string& name,
50 const base::PlatformFileInfo& info);
51 virtual void NoMoreItems();
52 virtual void DownloadedFile(const std::string& name,
53 base::PlatformFileError error);
54
55 // Implementation returned by |CreateFileEnumerator()|. Must be deleted
56 // before CancelPendingTeasksAndDeleteDelegate is called.
Lei Zhang 2012/12/22 02:44:35 typo
Greg Billock 2012/12/22 03:11:41 Done.
57 class Enumerator :
58 public fileapi::FileSystemFileUtil::AbstractFileEnumerator {
59 public:
60 explicit Enumerator(MTPDeviceDelegateImplMac* delegate);
61 virtual ~Enumerator();
62
63 virtual FilePath Next() OVERRIDE;
64 virtual int64 Size() OVERRIDE;
65 virtual base::Time LastModifiedTime() OVERRIDE;
66 virtual bool IsDirectory() OVERRIDE;
67
68 // Called by the delegate to signal any waiters that the received items
69 // list has changed state.
70 void ItemsChanged();
71
72 private:
73 MTPDeviceDelegateImplMac* delegate_;
74 size_t position_;
75 base::WaitableEvent wait_for_items_;
76 };
77
78 // GetFile and HasAllFiles called by enumerators.
79 FilePath GetFile(size_t index);
80 bool HasAllFiles();
81 void RemoveEnumerator(Enumerator* enumerator);
82
83 private:
84 std::string device_id_;
85 FilePath root_path_;
86
87 // Stores a reference to worker pool thread. All requests and response of file
88 // operations are posted on |media_task_runner_|. All callbacks from the
89 // camera will come through this task runner as well.
90 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
91
92 // Interface object for the camera underlying this MTP session.
93 scoped_ptr<CameraDeviceInterface> camera_interface_;
94
95 // Stores a map from filename to file metadata received from the camera.
96 base::hash_map<FilePath::StringType, base::PlatformFileInfo> file_info_;
97
98 // Notifications for all the files we're waiting on downloads for.
99 base::hash_map<std::string, base::WaitableEvent*> download_events_;
100
101 // Resulting error codes for downloads.
102 base::hash_map<std::string, base::PlatformFileError> download_errors_;
103
104 // List of files received from the camera.
105 std::vector<FilePath::StringType> file_paths_;
106
107 // List of enumerators which may be listening for files to come in.
108 std::vector<Enumerator*> enumerators_;
Lei Zhang 2012/12/22 02:44:35 I don't think we'll have multiple enumerators. Als
Greg Billock 2012/12/22 03:11:41 Oh, that does simplify things. I'll assume that.
109
110 // Set to true when all file metadata has been received from the camera.
111 bool received_all_files_;
112
113 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplMac);
114 };
115
116 } // namespace chrome
117
118 #endif // CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698