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

Unified Diff: chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.cc

Issue 10938019: Clean up: Use StringPrintf instead of string concatenation operator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.cc
diff --git a/chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.cc b/chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.cc
index 4afddf94fdabc3dd73c3615fe300e56fdea2cc18..636748b9368783822c61cdbe7c8304b2bbd32b0c 100644
--- a/chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.cc
+++ b/chrome/browser/system_monitor/media_transfer_protocol_device_observer_chromeos.cc
@@ -73,6 +73,13 @@ std::string GetDeviceIdFromStorageInfo(const MtpStorageInfo& storage_info) {
unique_id);
}
+// Returns the |data_store_id| string in the required format.
+// If the |data_store_id| is 65537, this function returns "(65537)".
+std::string GetFormattedIdString(const std::string& data_store_id) {
+ return base::StringPrintf("%s%s%s", chrome::kLeftParen, data_store_id.c_str(),
+ chrome::kRightParen);
+}
+
// Helper function to get device label from storage information.
string16 GetDeviceLabelFromStorageInfo(const MtpStorageInfo& storage_info) {
std::string device_label;
@@ -90,15 +97,12 @@ string16 GetDeviceLabelFromStorageInfo(const MtpStorageInfo& storage_info) {
if (!device_label.empty()) {
const std::string& volume_id = storage_info.volume_identifier();
if (!volume_id.empty()) {
- // TODO(kmadhusu): Use StringPrintf here and on line 98.
- device_label += chrome::kLeftParen + volume_id + chrome::kRightParen;
+ device_label += GetFormattedIdString(volume_id);
} else {
const std::string data_store_id =
GetStorageIdFromStorageName(storage_info.storage_name());
- if (!data_store_id.empty()) {
- device_label += chrome::kLeftParen + data_store_id +
- chrome::kRightParen;
- }
+ if (!data_store_id.empty())
+ device_label += GetFormattedIdString(data_store_id);
}
}
return UTF8ToUTF16(device_label);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698