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

Unified Diff: chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc

Issue 380863002: Cleanup: Fix some misc issues in Linux media galleries MTP code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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_galleries/linux/mtp_device_delegate_impl_linux.cc
diff --git a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc
index 0c70ad555fb11a852b42d33a62a7eb049cea022a..0cdbb83f1890058a40727abdc3f5a841e5c6e5ad 100644
--- a/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc
+++ b/chrome/browser/media_galleries/linux/mtp_device_delegate_impl_linux.cc
@@ -24,20 +24,25 @@ const char kRootPath[] = "/";
// 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|
// 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,
const base::FilePath& file_path) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
DCHECK(!registered_dev_path.empty());
DCHECK(!file_path.empty());
- if (registered_dev_path == file_path)
- return kRootPath;
-
- base::FilePath relative_path;
- if (!registered_dev_path.AppendRelativePath(file_path, &relative_path))
- return std::string();
- DCHECK(!relative_path.empty());
- return relative_path.value();
+ std::string result;
+ if (registered_dev_path == file_path) {
+ result = kRootPath;
+ } else {
+ base::FilePath relative_path;
+ if (registered_dev_path.AppendRelativePath(file_path, &relative_path)) {
+ DCHECK(!relative_path.empty());
+ result = relative_path.value();
+ }
+ }
+ return result;
}
// Returns the MTPDeviceTaskHelper object associated with the MTP device

Powered by Google App Engine
This is Rietveld 408576698