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

Unified Diff: chrome/browser/media_gallery/win/mtp_device_operations_util.h

Issue 11297002: [Media Gallery] Added code to support mtp device media file system on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified LazyInit() to handle GetDeviceStorageInfo failure Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
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..d30da86123ff5558462ee813d4f1308cc0388cdd
--- /dev/null
+++ b/chrome/browser/media_gallery/win/mtp_device_operations_util.h
@@ -0,0 +1,68 @@
+// 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/platform_file.h"
+#include "base/string16.h"
+#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,
+ 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);
+
+ // Writes the data of the object specified by |file_object_id| from the given
+ // MTP |device| to the file specified by |local_path|. On success, returns
+ // true and writes the object data in |local_path|. On failure, returns false.
+ static bool WriteFileObjectData(IPortableDevice* device,
+ const string16& file_object_id,
+ const FilePath& local_path);
+
+ // 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);
Ryan Sleevi 2013/01/05 03:00:58 DESIGN: Given that you take an |IPortableDevice*|
kmadhusu 2013/01/07 19:17:26 I thought an util class with a bunch of static met
Ryan Sleevi 2013/01/07 19:29:29 Classes that are static-method-holders are discour
kmadhusu 2013/01/07 19:36:43 Fair enough. Will fix it in the next patch.
kmadhusu 2013/01/08 03:19:40 Fixed. Created free functions in the chrome namesp
Peter Kasting 2013/01/08 04:34:01 If you're going to use namespaces, consider puttin
kmadhusu 2013/01/08 20:55:18 brettw@ is OOO today. I have sent an email to him
kmadhusu 2013/01/09 19:25:46 rsleevi@: brettw@ replied that he is a bit overloa
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(MTPDeviceOperationsUtil);
+};
+
+} // namespace chrome
+
+#endif // CHROME_BROWSER_MEDIA_GALLERY_WIN_MTP_DEVICE_OPERATIONS_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698