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

Side by Side Diff: chrome/browser/storage_monitor/portable_device_watcher_win.cc

Issue 15294020: StorageMonitor: Make StorageInfo a real class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address nits Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/storage_monitor/portable_device_watcher_win.h" 9 #include "chrome/browser/storage_monitor/portable_device_watcher_win.h"
10 10
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 string16* storage_object_id) const { 515 string16* storage_object_id) const {
516 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 516 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
517 DCHECK(device_location); 517 DCHECK(device_location);
518 DCHECK(storage_object_id); 518 DCHECK(storage_object_id);
519 MTPStorageMap::const_iterator storage_map_iter = 519 MTPStorageMap::const_iterator storage_map_iter =
520 storage_map_.find(storage_device_id); 520 storage_map_.find(storage_device_id);
521 if (storage_map_iter == storage_map_.end()) 521 if (storage_map_iter == storage_map_.end())
522 return false; 522 return false;
523 523
524 MTPDeviceMap::const_iterator device_iter = 524 MTPDeviceMap::const_iterator device_iter =
525 device_map_.find(storage_map_iter->second.location); 525 device_map_.find(storage_map_iter->second.location());
526 if (device_iter == device_map_.end()) 526 if (device_iter == device_map_.end())
527 return false; 527 return false;
528 const StorageObjects& storage_objects = device_iter->second; 528 const StorageObjects& storage_objects = device_iter->second;
529 for (StorageObjects::const_iterator storage_object_iter = 529 for (StorageObjects::const_iterator storage_object_iter =
530 storage_objects.begin(); storage_object_iter != storage_objects.end(); 530 storage_objects.begin(); storage_object_iter != storage_objects.end();
531 ++storage_object_iter) { 531 ++storage_object_iter) {
532 if (storage_device_id == storage_object_iter->object_persistent_id) { 532 if (storage_device_id == storage_object_iter->object_persistent_id) {
533 *device_location = storage_map_iter->second.location; 533 *device_location = storage_map_iter->second.location();
534 *storage_object_id = storage_object_iter->object_temporary_id; 534 *storage_object_id = storage_object_iter->object_temporary_id;
535 return true; 535 return true;
536 } 536 }
537 } 537 }
538 return false; 538 return false;
539 } 539 }
540 540
541 // static 541 // static
542 string16 PortableDeviceWatcherWin::GetStoragePathFromStorageId( 542 string16 PortableDeviceWatcherWin::GetStoragePathFromStorageId(
543 const std::string& storage_unique_id) { 543 const std::string& storage_unique_id) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return; 619 return;
620 620
621 // Device can have several data partitions. Therefore, add the 621 // Device can have several data partitions. Therefore, add the
622 // partition identifier to the storage name. E.g.: "Nexus 7 (s10001)" 622 // partition identifier to the storage name. E.g.: "Nexus 7 (s10001)"
623 string16 storage_name(name + L" (" + storage_iter->object_temporary_id + 623 string16 storage_name(name + L" (" + storage_iter->object_temporary_id +
624 L')'); 624 L')');
625 StorageInfo info(storage_id, storage_name, location, 625 StorageInfo info(storage_id, storage_name, location,
626 string16(), string16(), string16(), 0); 626 string16(), string16(), string16(), 0);
627 storage_map_[storage_id] = info; 627 storage_map_[storage_id] = info;
628 if (storage_notifications_) { 628 if (storage_notifications_) {
629 info.location = GetStoragePathFromStorageId(storage_id); 629 info.set_location(GetStoragePathFromStorageId(storage_id));
630 storage_notifications_->ProcessAttach(info); 630 storage_notifications_->ProcessAttach(info);
631 } 631 }
632 } 632 }
633 device_map_[location] = storage_objects; 633 device_map_[location] = storage_objects;
634 } 634 }
635 635
636 void PortableDeviceWatcherWin::HandleDeviceDetachEvent( 636 void PortableDeviceWatcherWin::HandleDeviceDetachEvent(
637 const string16& pnp_device_id) { 637 const string16& pnp_device_id) {
638 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 638 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
639 MTPDeviceMap::iterator device_iter = device_map_.find(pnp_device_id); 639 MTPDeviceMap::iterator device_iter = device_map_.find(pnp_device_id);
640 if (device_iter == device_map_.end()) 640 if (device_iter == device_map_.end())
641 return; 641 return;
642 642
643 const StorageObjects& storage_objects = device_iter->second; 643 const StorageObjects& storage_objects = device_iter->second;
644 for (StorageObjects::const_iterator storage_object_iter = 644 for (StorageObjects::const_iterator storage_object_iter =
645 storage_objects.begin(); storage_object_iter != storage_objects.end(); 645 storage_objects.begin(); storage_object_iter != storage_objects.end();
646 ++storage_object_iter) { 646 ++storage_object_iter) {
647 std::string storage_id = storage_object_iter->object_persistent_id; 647 std::string storage_id = storage_object_iter->object_persistent_id;
648 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id); 648 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id);
649 DCHECK(storage_map_iter != storage_map_.end()); 649 DCHECK(storage_map_iter != storage_map_.end());
650 if (storage_notifications_) 650 if (storage_notifications_) {
651 storage_notifications_->ProcessDetach(storage_map_iter->second.device_id); 651 storage_notifications_->ProcessDetach(
652 storage_map_iter->second.device_id());
653 }
652 storage_map_.erase(storage_map_iter); 654 storage_map_.erase(storage_map_iter);
653 } 655 }
654 device_map_.erase(device_iter); 656 device_map_.erase(device_iter);
655 } 657 }
656 658
657 } // namespace chrome 659 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698