| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file has several utility functions to open a media transfer protocol |
| 6 // (MTP) device for communication, to enumerate the device contents, to read the |
| 7 // device file object, etc. All these tasks may take an arbitary long time |
| 8 // to complete. This file segregates those functionalities and runs them |
| 9 // in the blocking pool thread rather than in the UI thread. |
| 10 |
| 11 #ifndef CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ |
| 12 #define CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ |
| 13 |
| 14 #include <portabledeviceapi.h> |
| 15 |
| 16 #include <string> |
| 17 |
| 18 #include "base/platform_file.h" |
| 19 #include "base/string16.h" |
| 20 #include "base/win/scoped_comptr.h" |
| 21 #include "chrome/browser/media_gallery/win/mtp_device_object_entry.h" |
| 22 |
| 23 namespace chrome { |
| 24 |
| 25 namespace media_transfer_protocol { |
| 26 |
| 27 // Opens the device for communication. |pnp_device_id| specifies the plug and |
| 28 // play device ID string. On success, returns the IPortableDevice interface. |
| 29 // On failure, returns NULL. |
| 30 base::win::ScopedComPtr<IPortableDevice> OpenDevice( |
| 31 const string16& pnp_device_id); |
| 32 |
| 33 // Gets the details of the object specified by |object_id| from the given MTP |
| 34 // |device|. On success, returns no error (base::PLATFORM_FILE_OK) and fills in |
| 35 // |file_entry_info|. On failure, returns the corresponding platform file error |
| 36 // and |file_entry_info| is not set. |
| 37 base::PlatformFileError GetFileEntryInfo( |
| 38 IPortableDevice* device, |
| 39 const string16& object_id, |
| 40 base::PlatformFileInfo* file_entry_info); |
| 41 |
| 42 // Gets the entries of the directory specified by |directory_object_id| from |
| 43 // the given MTP |device|. On success, returns true and fills in |
| 44 // |object_entries|. On failure, returns false and |object_entries| is not |
| 45 // set. |
| 46 bool GetDirectoryEntries(IPortableDevice* device, |
| 47 const string16& directory_object_id, |
| 48 MTPDeviceObjectEntries* object_entries); |
| 49 |
| 50 // Writes the data of the object specified by |file_object_id| from the given |
| 51 // MTP |device| to the file specified by |local_path|. On success, returns |
| 52 // true and writes the object data in |local_path|. On failure, returns false. |
| 53 bool WriteFileObjectContentToPath(IPortableDevice* device, |
| 54 const string16& file_object_id, |
| 55 const FilePath& local_path); |
| 56 |
| 57 // Returns the identifier of the object specified by the |object_name|. |
| 58 // |parent_id| specifies the object's parent identifier. |
| 59 // |object_name| specifies the friendly name of the object. |
| 60 string16 GetObjectIdFromName(IPortableDevice* device, |
| 61 const string16& parent_id, |
| 62 const string16& object_name); |
| 63 |
| 64 } // namespace media_transfer_protocol |
| 65 |
| 66 } // namespace chrome |
| 67 |
| 68 #endif // CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ |
| OLD | NEW |