Commit 789640a1 authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup: Fix some misc issues in Linux media galleries MTP code.

Review URL: https://codereview.chromium.org/380863002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282252 0039d316-1c4b-4281-b951-d872f2087c98
parent c355fdb0
...@@ -24,20 +24,25 @@ const char kRootPath[] = "/"; ...@@ -24,20 +24,25 @@ const char kRootPath[] = "/";
// Returns the device relative file path given |file_path|. // Returns the device relative file path given |file_path|.
// E.g.: If the |file_path| is "/usb:2,2:12345/DCIM" and |registered_dev_path| // E.g.: If the |file_path| is "/usb:2,2:12345/DCIM" and |registered_dev_path|
// is "/usb:2,2:12345", this function returns the device relative path which is // is "/usb:2,2:12345", this function returns the device relative path which is
// "/DCIM". // "DCIM".
// In the special case when |registered_dev_path| and |file_path| are the same,
// return |kRootPath|.
std::string GetDeviceRelativePath(const base::FilePath& registered_dev_path, std::string GetDeviceRelativePath(const base::FilePath& registered_dev_path,
const base::FilePath& file_path) { const base::FilePath& file_path) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO); DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
DCHECK(!registered_dev_path.empty()); DCHECK(!registered_dev_path.empty());
DCHECK(!file_path.empty()); DCHECK(!file_path.empty());
if (registered_dev_path == file_path) std::string result;
return kRootPath; if (registered_dev_path == file_path) {
result = kRootPath;
base::FilePath relative_path; } else {
if (!registered_dev_path.AppendRelativePath(file_path, &relative_path)) base::FilePath relative_path;
return std::string(); if (registered_dev_path.AppendRelativePath(file_path, &relative_path)) {
DCHECK(!relative_path.empty()); DCHECK(!relative_path.empty());
return relative_path.value(); result = relative_path.value();
}
}
return result;
} }
// Returns the MTPDeviceTaskHelper object associated with the MTP device // Returns the MTPDeviceTaskHelper object associated with the MTP device
......
...@@ -45,7 +45,7 @@ base::Time MTPDeviceObjectEnumerator::LastModifiedTime() { ...@@ -45,7 +45,7 @@ base::Time MTPDeviceObjectEnumerator::LastModifiedTime() {
return base::Time::FromTimeT(file_entries_[index_].modification_time()); return base::Time::FromTimeT(file_entries_[index_].modification_time());
} }
bool MTPDeviceObjectEnumerator::GetEntryId(uint32_t* entry_id) const { bool MTPDeviceObjectEnumerator::GetEntryId(uint32* entry_id) const {
DCHECK(entry_id); DCHECK(entry_id);
if (!IsIndexReadyAndInRange()) if (!IsIndexReadyAndInRange())
return false; return false;
......
...@@ -25,7 +25,7 @@ class MTPDeviceObjectEnumerator { ...@@ -25,7 +25,7 @@ class MTPDeviceObjectEnumerator {
// If the current file entry is valid, returns true and fills in |entry_id| // If the current file entry is valid, returns true and fills in |entry_id|
// with the entry identifier else returns false and |entry_id| is not set. // with the entry identifier else returns false and |entry_id| is not set.
bool GetEntryId(uint32_t* entry_id) const; bool GetEntryId(uint32* entry_id) const;
private: private:
// Returns true if the enumerator has more entries to traverse, false // Returns true if the enumerator has more entries to traverse, false
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment