Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // MTPDeviceOperationsUtil provides support to media filesystem operations. | |
| 6 // It has several utility functions to open a media transfer protocol (MTP) | |
| 7 // device for communication, to enumerate the device contents, to read the | |
| 8 // device file object, etc. All these tasks may take an arbitary long time | |
| 9 // to complete. This class segregates those functionalities and runs them | |
| 10 // in the blocking pool thread rather than in the UI thread. | |
| 11 | |
| 12 #ifndef CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ | |
| 13 #define CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ | |
| 14 | |
| 15 #include <portabledeviceapi.h> | |
| 16 | |
| 17 #include <string> | |
| 18 | |
| 19 #include "base/string16.h" | |
| 20 #include "base/platform_file.h" | |
|
Lei Zhang
2012/11/01 02:34:57
move up 1 line
kmadhusu
2012/11/01 17:59:00
Done.
| |
| 21 #include "base/win/scoped_comptr.h" | |
| 22 #include "chrome/browser/media_gallery/win/mtp_device_object_entry.h" | |
| 23 | |
| 24 namespace chrome { | |
| 25 | |
| 26 // See the top of the file for complete class description. | |
| 27 class MTPDeviceOperationsUtil { | |
| 28 public: | |
| 29 // Opens the device for communication. |pnp_device_id| specifies the plug and | |
| 30 // play device ID string. On success, returns true and updates |device| with | |
| 31 // the portable device interface. | |
| 32 static bool OpenDevice(const string16& pnp_device_id, | |
|
kmadhusu
2012/11/01 01:17:24
I can reuse this function in portable_device_watch
| |
| 33 base::win::ScopedComPtr<IPortableDevice>* device); | |
| 34 | |
| 35 // Gets the details of the object specified by |object_id| from the given MTP | |
| 36 // |device|. On success, fills in |file_entry_info|. On failure, returns the | |
| 37 // corresponding platform file error and |file_entry_info| is not set. | |
| 38 static base::PlatformFileError GetFileEntryInfo( | |
| 39 IPortableDevice* device, | |
| 40 const string16& object_id, | |
| 41 base::PlatformFileInfo* file_entry_info); | |
| 42 | |
| 43 // Gets the entries of the directory specified by |directory_object_id| from | |
| 44 // the given MTP |device|. On success, returns true and fills in | |
| 45 // |object_entries|. On failure, returns false and |object_entries| are not | |
| 46 // set. | |
| 47 static bool GetDirectoryEntries(IPortableDevice* device, | |
| 48 const string16& directory_object_id, | |
| 49 MTPDeviceObjectEntries* object_entries); | |
| 50 | |
| 51 // Gets the data of the object specified by |file_object_id| from the given | |
| 52 // MTP |device|. On success, returns true and fills in |file_data|. On | |
| 53 // failure, returns false and |file_data| is not set. | |
| 54 static bool GetFileObjectData(IPortableDevice* device, | |
| 55 const string16& file_object_id, | |
| 56 std::string* file_data); | |
| 57 | |
| 58 // Returns the identifier of the object specified by the |object_name|. | |
| 59 // |parent_id| specifies the object's parent identifier. | |
| 60 static string16 GetObjectIdFromName(IPortableDevice* device, | |
| 61 const string16& parent_id, | |
| 62 const string16& object_name); | |
| 63 | |
| 64 private: | |
| 65 // All methods are static, this class should not be instantiated. | |
| 66 MTPDeviceOperationsUtil(); | |
| 67 | |
| 68 // Helper to create a MTP device object entry for the given |device| | |
| 69 // and |object_id|. On success, returns true and fills in |entry|. On | |
| 70 // failure, returns false and |entry| is not set. | |
| 71 static bool GetMTPDeviceObjectEntry(IPortableDevice* device, | |
|
Lei Zhang
2012/11/01 02:34:57
Can this go in the .cc file's anonymous namespace
kmadhusu
2012/11/01 17:59:00
Done.
| |
| 72 const string16& object_id, | |
| 73 MTPDeviceObjectEntry* entry); | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(MTPDeviceOperationsUtil); | |
| 76 }; | |
| 77 | |
| 78 } // namespace chrome | |
| 79 | |
| 80 #endif // CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ | |
| OLD | NEW |