Chromium Code Reviews| Index: chrome/browser/media_gallery/win/mtp_device_operations_util.h |
| diff --git a/chrome/browser/media_gallery/win/mtp_device_operations_util.h b/chrome/browser/media_gallery/win/mtp_device_operations_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0bf5c98dd90d3b62e17a8182cbdd635e3c3fea36 |
| --- /dev/null |
| +++ b/chrome/browser/media_gallery/win/mtp_device_operations_util.h |
| @@ -0,0 +1,80 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// MTPDeviceOperationsUtil provides support to media filesystem operations. |
| +// It has several utility functions to open a media transfer protocol (MTP) |
| +// device for communication, to enumerate the device contents, to read the |
| +// device file object, etc. All these tasks may take an arbitary long time |
| +// to complete. This class segregates those functionalities and runs them |
| +// in the blocking pool thread rather than in the UI thread. |
| + |
| +#ifndef CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ |
| +#define CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ |
| + |
| +#include <portabledeviceapi.h> |
| + |
| +#include <string> |
| + |
| +#include "base/string16.h" |
| +#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.
|
| +#include "base/win/scoped_comptr.h" |
| +#include "chrome/browser/media_gallery/win/mtp_device_object_entry.h" |
| + |
| +namespace chrome { |
| + |
| +// See the top of the file for complete class description. |
| +class MTPDeviceOperationsUtil { |
| + public: |
| + // Opens the device for communication. |pnp_device_id| specifies the plug and |
| + // play device ID string. On success, returns true and updates |device| with |
| + // the portable device interface. |
| + static bool OpenDevice(const string16& pnp_device_id, |
|
kmadhusu
2012/11/01 01:17:24
I can reuse this function in portable_device_watch
|
| + base::win::ScopedComPtr<IPortableDevice>* device); |
| + |
| + // Gets the details of the object specified by |object_id| from the given MTP |
| + // |device|. On success, fills in |file_entry_info|. On failure, returns the |
| + // corresponding platform file error and |file_entry_info| is not set. |
| + static base::PlatformFileError GetFileEntryInfo( |
| + IPortableDevice* device, |
| + const string16& object_id, |
| + base::PlatformFileInfo* file_entry_info); |
| + |
| + // Gets the entries of the directory specified by |directory_object_id| from |
| + // the given MTP |device|. On success, returns true and fills in |
| + // |object_entries|. On failure, returns false and |object_entries| are not |
| + // set. |
| + static bool GetDirectoryEntries(IPortableDevice* device, |
| + const string16& directory_object_id, |
| + MTPDeviceObjectEntries* object_entries); |
| + |
| + // Gets the data of the object specified by |file_object_id| from the given |
| + // MTP |device|. On success, returns true and fills in |file_data|. On |
| + // failure, returns false and |file_data| is not set. |
| + static bool GetFileObjectData(IPortableDevice* device, |
| + const string16& file_object_id, |
| + std::string* file_data); |
| + |
| + // Returns the identifier of the object specified by the |object_name|. |
| + // |parent_id| specifies the object's parent identifier. |
| + static string16 GetObjectIdFromName(IPortableDevice* device, |
| + const string16& parent_id, |
| + const string16& object_name); |
| + |
| + private: |
| + // All methods are static, this class should not be instantiated. |
| + MTPDeviceOperationsUtil(); |
| + |
| + // Helper to create a MTP device object entry for the given |device| |
| + // and |object_id|. On success, returns true and fills in |entry|. On |
| + // failure, returns false and |entry| is not set. |
| + 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.
|
| + const string16& object_id, |
| + MTPDeviceObjectEntry* entry); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MTPDeviceOperationsUtil); |
| +}; |
| + |
| +} // namespace chrome |
| + |
| +#endif // CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_ |