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

Side by Side Diff: chrome/browser/media_gallery/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: Rebase to current image capture api state 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 explicit MTPDeviceDelegateImplMac(
Lei Zhang 2012/12/21 21:05:44 not explicit
Greg Billock 2012/12/22 00:10:28 Oops! Didn't work through a rebase way back somewh
32 const FilePath::StringType& location,
33 base::SequencedTaskRunner* media_task_runner);
34
35 // MTPDeviceDelegate:
36 virtual base::PlatformFileError GetFileInfo(
37 const FilePath& file_path,
38 base::PlatformFileInfo* file_info) OVERRIDE;
39 virtual scoped_ptr<fileapi::FileSystemFileUtil::AbstractFileEnumerator>
40 CreateFileEnumerator(const FilePath& root, bool recursive) OVERRIDE;
41 virtual base::PlatformFileError CreateSnapshotFile(
42 const FilePath& device_file_path,
43 const FilePath& local_path,
44 base::PlatformFileInfo* file_info) OVERRIDE;
45 virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
46
47 // Forward delegates for ImageCaptureDeviceListener
48 virtual void ItemAdded(const std::string& name,
49 const base::PlatformFileInfo& info);
50 virtual void NoMoreItems();
51 virtual void DownloadedFile(const std::string& name,
52 base::PlatformFileError error);
53
54 // Implementation returned by |CreateFileEnumerator()|. Must be deleted
55 // before CancelPendingTeasksAndDeleteDelegate is called.
56 class Enumerator :
57 public fileapi::FileSystemFileUtil::AbstractFileEnumerator {
58 public:
59 explicit Enumerator(MTPDeviceDelegateImplMac* delegate);
60 virtual ~Enumerator();
61
62 virtual FilePath Next() OVERRIDE;
63 virtual int64 Size() OVERRIDE;
64 virtual base::Time LastModifiedTime() OVERRIDE;
65 virtual bool IsDirectory() OVERRIDE;
66
67 // Called by the delegate to signal any waiters that the received items
68 // list has changed state.
69 void ItemsChanged();
70
71 private:
72 MTPDeviceDelegateImplMac* delegate_;
73 int position_;
74 base::WaitableEvent wait_for_items_;
75 };
76
77 // GetFile and HasAllFiles called by enumerators.
78 FilePath GetFile(int index);
79 bool HasAllFiles();
80 void RemoveEnumerator(Enumerator* enumerator);
81
82 // Callback bound by CancelPendingTasksAndDeleteDelegate.
83 void DeleteDelegateOnTaskRunner();
84
85 private:
86 // Destructed via DeleteDelegateOnTaskRunner(). Do all the clean up in
87 // DeleteDelegateOnTaskRunner().
88 virtual ~MTPDeviceDelegateImplMac();
89
90 std::string device_id_;
91 FilePath root_path_;
92
93 // Stores a reference to worker pool thread. All requests and response of file
94 // operations are posted on |media_task_runner_|. All callbacks from the
95 // camera will come through this task runner as well.
96 scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
97
98 // Interface object for the camera underlying this MTP session.
99 scoped_ptr<CameraDeviceInterface> camera_interface_;
100
101 // Stores a map from filename to file metadata received from the camera.
102 base::hash_map<FilePath::StringType, base::PlatformFileInfo> file_info_;
103
104 // Notifications for all the files we're waiting on downloads for.
105 base::hash_map<std::string, base::WaitableEvent*> download_events_;
106
107 // Resulting error codes for downloads.
108 base::hash_map<std::string, base::PlatformFileError> download_errors_;
109
110 // List of files received from the camera.
111 std::vector<FilePath::StringType> file_paths_;
112
113 // List of enumerators which may be listening for files to come in.
114 std::vector<Enumerator*> enumerators_;
115
116 // Set to true when all file metadata has been received from the camera.
117 bool received_all_files_;
118
119 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplMac);
120 };
121
122 } // namespace chrome
123
124 #endif // CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698