OLD | NEW |
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_chr
omeos.h" | 5 #include "components/storage_monitor/media_transfer_protocol_device_observer_chr
omeos.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" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "components/storage_monitor/media_storage_util.h" | |
15 #include "components/storage_monitor/removable_device_constants.h" | 14 #include "components/storage_monitor/removable_device_constants.h" |
16 #include "device/media_transfer_protocol/mtp_storage_info.pb.h" | 15 #include "device/media_transfer_protocol/mtp_storage_info.pb.h" |
17 | 16 |
18 namespace storage_monitor { | 17 namespace storage_monitor { |
19 | 18 |
20 namespace { | 19 namespace { |
21 | 20 |
22 // Device root path constant. | 21 // Device root path constant. |
23 const char kRootPath[] = "/"; | 22 const char kRootPath[] = "/"; |
24 | 23 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 if (is_attached) { | 194 if (is_attached) { |
196 std::string device_id; | 195 std::string device_id; |
197 base::string16 storage_label; | 196 base::string16 storage_label; |
198 std::string location; | 197 std::string location; |
199 base::string16 vendor_name; | 198 base::string16 vendor_name; |
200 base::string16 product_name; | 199 base::string16 product_name; |
201 get_storage_info_func_(storage_name, mtp_manager_, &device_id, | 200 get_storage_info_func_(storage_name, mtp_manager_, &device_id, |
202 &storage_label, &location, &vendor_name, | 201 &storage_label, &location, &vendor_name, |
203 &product_name); | 202 &product_name); |
204 | 203 |
205 // Keep track of device id and device name to see how often we receive | |
206 // empty values. | |
207 MediaStorageUtil::RecordDeviceInfoHistogram(false, device_id, | |
208 storage_label); | |
209 if (device_id.empty() || storage_label.empty()) | 204 if (device_id.empty() || storage_label.empty()) |
210 return; | 205 return; |
211 | 206 |
212 DCHECK(!base::ContainsKey(storage_map_, location)); | 207 DCHECK(!base::ContainsKey(storage_map_, location)); |
213 | 208 |
214 StorageInfo storage_info(device_id, location, storage_label, vendor_name, | 209 StorageInfo storage_info(device_id, location, storage_label, vendor_name, |
215 product_name, 0); | 210 product_name, 0); |
216 storage_map_[location] = storage_info; | 211 storage_map_[location] = storage_info; |
217 notifications_->ProcessAttach(storage_info); | 212 notifications_->ProcessAttach(storage_info); |
218 } else { | 213 } else { |
(...skipping 24 matching lines...) Expand all Loading... |
243 if (it->second.device_id() == device_id) { | 238 if (it->second.device_id() == device_id) { |
244 *location = it->first; | 239 *location = it->first; |
245 return true; | 240 return true; |
246 } | 241 } |
247 } | 242 } |
248 | 243 |
249 return false; | 244 return false; |
250 } | 245 } |
251 | 246 |
252 } // namespace storage_monitor | 247 } // namespace storage_monitor |
OLD | NEW |