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

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

Issue 145303002: Convert Media Galleries to use base::File (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_GALLERIES_MAC_MTP_DEVICE_DELEGATE_IMPL_MAC_H_ 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_MAC_MTP_DEVICE_DELEGATE_IMPL_MAC_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_MAC_MTP_DEVICE_DELEGATE_IMPL_MAC_H_ 6 #define CHROME_BROWSER_MEDIA_GALLERIES_MAC_MTP_DEVICE_DELEGATE_IMPL_MAC_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
13 #include "base/files/file.h"
13 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/platform_file.h"
16 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" 16 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h"
17 17
18 // Delegate for presenting an Image Capture device through the filesystem 18 // Delegate for presenting an Image Capture device through the filesystem
19 // API. The synthetic filesystem will be rooted at the constructed location, 19 // API. The synthetic filesystem will be rooted at the constructed location,
20 // and names of all files notified through the ItemAdded call will be 20 // and names of all files notified through the ItemAdded call will be
21 // all appear as children of that directory. (ItemAdded calls with directories 21 // all appear as children of that directory. (ItemAdded calls with directories
22 // will be ignored.) 22 // will be ignored.)
23 // Note on thread management: This class is thread-compatible: it can be created 23 // Note on thread management: This class is thread-compatible: it can be created
24 // on any thread, but then mutates all state on the UI thread. The async 24 // on any thread, but then mutates all state on the UI thread. The async
25 // delegate interface can be invoked on any thread, as it simply forwards calls 25 // delegate interface can be invoked on any thread, as it simply forwards calls
(...skipping 27 matching lines...) Expand all
53 virtual void ReadBytes( 53 virtual void ReadBytes(
54 const base::FilePath& device_file_path, 54 const base::FilePath& device_file_path,
55 net::IOBuffer* buf, int64 offset, int buf_len, 55 net::IOBuffer* buf, int64 offset, int buf_len,
56 const ReadBytesSuccessCallback& success_callback, 56 const ReadBytesSuccessCallback& success_callback,
57 const ErrorCallback& error_callback) OVERRIDE; 57 const ErrorCallback& error_callback) OVERRIDE;
58 virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE; 58 virtual void CancelPendingTasksAndDeleteDelegate() OVERRIDE;
59 59
60 // Forward delegates for ImageCaptureDeviceListener. These are 60 // Forward delegates for ImageCaptureDeviceListener. These are
61 // invoked in callbacks of the ImageCapture library on the UI thread. 61 // invoked in callbacks of the ImageCapture library on the UI thread.
62 virtual void ItemAdded(const std::string& name, 62 virtual void ItemAdded(const std::string& name,
63 const base::PlatformFileInfo& info); 63 const base::File::Info& info);
64 virtual void NoMoreItems(); 64 virtual void NoMoreItems();
65 virtual void DownloadedFile(const std::string& name, 65 virtual void DownloadedFile(const std::string& name,
66 base::PlatformFileError error); 66 base::File::Error error);
67 67
68 // Scheduled when early directory reads are requested. The 68 // Scheduled when early directory reads are requested. The
69 // timeout will signal an ABORT error to the caller if the 69 // timeout will signal an ABORT error to the caller if the
70 // device metadata cannot be read. 70 // device metadata cannot be read.
71 void ReadDirectoryTimeout(const base::FilePath& root); 71 void ReadDirectoryTimeout(const base::FilePath& root);
72 72
73 private: 73 private:
74 class DeviceListener; 74 class DeviceListener;
75 75
76 virtual ~MTPDeviceDelegateImplMac(); 76 virtual ~MTPDeviceDelegateImplMac();
77 77
78 // Delegate for GetFileInfo, called on the UI thread. 78 // Delegate for GetFileInfo, called on the UI thread.
79 void GetFileInfoImpl(const base::FilePath& file_path, 79 void GetFileInfoImpl(const base::FilePath& file_path,
80 base::PlatformFileInfo* file_info, 80 base::File::Info* file_info,
81 base::PlatformFileError* error); 81 base::File::Error* error);
82 82
83 // Delegate for ReadDirectory, called on the UI thread. 83 // Delegate for ReadDirectory, called on the UI thread.
84 void ReadDirectoryImpl( 84 void ReadDirectoryImpl(
85 const base::FilePath& root, 85 const base::FilePath& root,
86 const ReadDirectorySuccessCallback& success_callback, 86 const ReadDirectorySuccessCallback& success_callback,
87 const ErrorCallback& error_callback); 87 const ErrorCallback& error_callback);
88 88
89 // Delegate for CreateSnapshotFile, called on the UI thread. 89 // Delegate for CreateSnapshotFile, called on the UI thread.
90 void DownloadFile( 90 void DownloadFile(
91 const base::FilePath& device_file_path, 91 const base::FilePath& device_file_path,
(...skipping 13 matching lines...) Expand all
105 void NotifyReadDir(); 105 void NotifyReadDir();
106 106
107 std::string device_id_; 107 std::string device_id_;
108 base::FilePath root_path_; 108 base::FilePath root_path_;
109 109
110 // Interface object for the camera underlying this MTP session. 110 // Interface object for the camera underlying this MTP session.
111 scoped_ptr<DeviceListener> camera_interface_; 111 scoped_ptr<DeviceListener> camera_interface_;
112 112
113 // Stores a map from filename to file metadata received from the camera. 113 // Stores a map from filename to file metadata received from the camera.
114 base::hash_map<base::FilePath::StringType, 114 base::hash_map<base::FilePath::StringType,
115 base::PlatformFileInfo> file_info_; 115 base::File::Info> file_info_;
116 116
117 // List of filenames received from the camera. 117 // List of filenames received from the camera.
118 std::vector<base::FilePath> file_paths_; 118 std::vector<base::FilePath> file_paths_;
119 119
120 // Set to true when all file metadata has been received from the camera. 120 // Set to true when all file metadata has been received from the camera.
121 bool received_all_files_; 121 bool received_all_files_;
122 122
123 struct ReadFileRequest { 123 struct ReadFileRequest {
124 ReadFileRequest(); 124 ReadFileRequest();
125 ReadFileRequest(const std::string& request_file, 125 ReadFileRequest(const std::string& request_file,
(...skipping 25 matching lines...) Expand all
151 151
152 ReadFileTransactionList read_file_transactions_; 152 ReadFileTransactionList read_file_transactions_;
153 ReadDirTransactionList read_dir_transactions_; 153 ReadDirTransactionList read_dir_transactions_;
154 154
155 base::WeakPtrFactory<MTPDeviceDelegateImplMac> weak_factory_; 155 base::WeakPtrFactory<MTPDeviceDelegateImplMac> weak_factory_;
156 156
157 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplMac); 157 DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplMac);
158 }; 158 };
159 159
160 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MAC_MTP_DEVICE_DELEGATE_IMPL_MAC_H_ 160 #endif // CHROME_BROWSER_MEDIA_GALLERIES_MAC_MTP_DEVICE_DELEGATE_IMPL_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698