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

Side by Side Diff: components/storage_monitor/media_transfer_protocol_device_observer_linux.cc

Issue 1234973004: Update SplitString calls in components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/storage_monitor/media_transfer_protocol_device_observer_lin ux.h" 5 #include "components/storage_monitor/media_transfer_protocol_device_observer_lin ux.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 18 matching lines...) Expand all
29 // E.g.: If the |storage_name| is "usb:2,2:12345" then "/usb:2,2:12345" is the 29 // E.g.: If the |storage_name| is "usb:2,2:12345" then "/usb:2,2:12345" is the
30 // device location. 30 // device location.
31 DCHECK(!storage_name.empty()); 31 DCHECK(!storage_name.empty());
32 return kRootPath + storage_name; 32 return kRootPath + storage_name;
33 } 33 }
34 34
35 // Returns the storage identifier of the device from the given |storage_name|. 35 // Returns the storage identifier of the device from the given |storage_name|.
36 // E.g. If the |storage_name| is "usb:2,2:65537", the storage identifier is 36 // E.g. If the |storage_name| is "usb:2,2:65537", the storage identifier is
37 // "65537". 37 // "65537".
38 std::string GetStorageIdFromStorageName(const std::string& storage_name) { 38 std::string GetStorageIdFromStorageName(const std::string& storage_name) {
39 std::vector<std::string> name_parts; 39 std::vector<base::StringPiece> name_parts = base::SplitStringPiece(
40 base::SplitString(storage_name, ':', &name_parts); 40 storage_name, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
41 return name_parts.size() == 3 ? name_parts[2] : std::string(); 41 return name_parts.size() == 3 ? name_parts[2].as_string() : std::string();
42 } 42 }
43 43
44 // Returns a unique device id from the given |storage_info|. 44 // Returns a unique device id from the given |storage_info|.
45 std::string GetDeviceIdFromStorageInfo(const MtpStorageInfo& storage_info) { 45 std::string GetDeviceIdFromStorageInfo(const MtpStorageInfo& storage_info) {
46 const std::string storage_id = 46 const std::string storage_id =
47 GetStorageIdFromStorageName(storage_info.storage_name()); 47 GetStorageIdFromStorageName(storage_info.storage_name());
48 if (storage_id.empty()) 48 if (storage_id.empty())
49 return std::string(); 49 return std::string();
50 50
51 // Some devices have multiple data stores. Therefore, include storage id as 51 // Some devices have multiple data stores. Therefore, include storage id as
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 if (it->second.device_id() == device_id) { 243 if (it->second.device_id() == device_id) {
244 *location = it->first; 244 *location = it->first;
245 return true; 245 return true;
246 } 246 }
247 } 247 }
248 248
249 return false; 249 return false;
250 } 250 }
251 251
252 } // namespace storage_monitor 252 } // namespace storage_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698