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 // Any tasks that communicates with the portable device may take >100ms to | 5 // Any tasks that communicates with the portable device may take >100ms to |
6 // complete. Those tasks should be run on an blocking thread instead of the | 6 // complete. Those tasks should be run on an blocking thread instead of the |
7 // UI thread. | 7 // UI thread. |
8 | 8 |
9 #include "components/storage_monitor/portable_device_watcher_win.h" | 9 #include "components/storage_monitor/portable_device_watcher_win.h" |
10 | 10 |
11 #include <dbt.h> | 11 #include <dbt.h> |
12 #include <portabledevice.h> | 12 #include <portabledevice.h> |
13 | 13 |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
20 #include "base/win/scoped_co_mem.h" | 20 #include "base/win/scoped_co_mem.h" |
21 #include "base/win/scoped_comptr.h" | 21 #include "base/win/scoped_comptr.h" |
22 #include "base/win/scoped_propvariant.h" | 22 #include "base/win/scoped_propvariant.h" |
23 #include "components/storage_monitor/media_storage_util.h" | |
24 #include "components/storage_monitor/removable_device_constants.h" | 23 #include "components/storage_monitor/removable_device_constants.h" |
25 #include "components/storage_monitor/storage_info.h" | 24 #include "components/storage_monitor/storage_info.h" |
26 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
27 | 26 |
28 namespace storage_monitor { | 27 namespace storage_monitor { |
29 | 28 |
30 namespace { | 29 namespace { |
31 | 30 |
32 // Name of the client application that communicates with the MTP device. | 31 // Name of the client application that communicates with the MTP device. |
33 const base::char16 kClientName[] = L"Chromium"; | 32 const base::char16 kClientName[] = L"Chromium"; |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 | 624 |
626 const StorageObjects& storage_objects = device_details->storage_objects; | 625 const StorageObjects& storage_objects = device_details->storage_objects; |
627 const base::string16& name = device_details->name; | 626 const base::string16& name = device_details->name; |
628 const base::string16& location = device_details->location; | 627 const base::string16& location = device_details->location; |
629 DCHECK(!base::ContainsKey(device_map_, location)); | 628 DCHECK(!base::ContainsKey(device_map_, location)); |
630 for (StorageObjects::const_iterator storage_iter = storage_objects.begin(); | 629 for (StorageObjects::const_iterator storage_iter = storage_objects.begin(); |
631 storage_iter != storage_objects.end(); ++storage_iter) { | 630 storage_iter != storage_objects.end(); ++storage_iter) { |
632 const std::string& storage_id = storage_iter->object_persistent_id; | 631 const std::string& storage_id = storage_iter->object_persistent_id; |
633 DCHECK(!base::ContainsKey(storage_map_, storage_id)); | 632 DCHECK(!base::ContainsKey(storage_map_, storage_id)); |
634 | 633 |
635 // Keep track of storage id and storage name to see how often we receive | |
636 // empty values. | |
637 MediaStorageUtil::RecordDeviceInfoHistogram(false, storage_id, name); | |
638 if (storage_id.empty() || name.empty()) | 634 if (storage_id.empty() || name.empty()) |
639 return; | 635 return; |
640 | 636 |
641 // Device can have several data partitions. Therefore, add the | 637 // Device can have several data partitions. Therefore, add the |
642 // partition identifier to the model name. E.g.: "Nexus 7 (s10001)" | 638 // partition identifier to the model name. E.g.: "Nexus 7 (s10001)" |
643 base::string16 model_name(name + L" (" + | 639 base::string16 model_name(name + L" (" + |
644 storage_iter->object_temporary_id + L')'); | 640 storage_iter->object_temporary_id + L')'); |
645 StorageInfo info(storage_id, location, base::string16(), base::string16(), | 641 StorageInfo info(storage_id, location, base::string16(), base::string16(), |
646 model_name, 0); | 642 model_name, 0); |
647 storage_map_[storage_id] = info; | 643 storage_map_[storage_id] = info; |
(...skipping 22 matching lines...) Expand all Loading... |
670 if (storage_notifications_) { | 666 if (storage_notifications_) { |
671 storage_notifications_->ProcessDetach( | 667 storage_notifications_->ProcessDetach( |
672 storage_map_iter->second.device_id()); | 668 storage_map_iter->second.device_id()); |
673 } | 669 } |
674 storage_map_.erase(storage_map_iter); | 670 storage_map_.erase(storage_map_iter); |
675 } | 671 } |
676 device_map_.erase(device_iter); | 672 device_map_.erase(device_iter); |
677 } | 673 } |
678 | 674 |
679 } // namespace storage_monitor | 675 } // namespace storage_monitor |
OLD | NEW |