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

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

Issue 11573048: [Media Galleries] Move RemovableStorageInfo notifications to chrome namespace (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to head Created 7 years, 11 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/system_monitor/portable_device_watcher_win.h" 9 #include "chrome/browser/system_monitor/portable_device_watcher_win.h"
10 10
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 const DeviceDetails* device_details, const bool result) { 558 const DeviceDetails* device_details, const bool result) {
559 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 559 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
560 DCHECK(device_details); 560 DCHECK(device_details);
561 if (!result) 561 if (!result)
562 return; 562 return;
563 563
564 const StorageObjects& storage_objects = device_details->storage_objects; 564 const StorageObjects& storage_objects = device_details->storage_objects;
565 const string16& name = device_details->name; 565 const string16& name = device_details->name;
566 const string16& location = device_details->location; 566 const string16& location = device_details->location;
567 DCHECK(!ContainsKey(device_map_, location)); 567 DCHECK(!ContainsKey(device_map_, location));
568 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); 568 RemovableStorageNotifications* notifications =
569 DCHECK(system_monitor); 569 RemovableStorageNotifications::Get();
570 DCHECK(notifications);
570 for (StorageObjects::const_iterator storage_iter = storage_objects.begin(); 571 for (StorageObjects::const_iterator storage_iter = storage_objects.begin();
571 storage_iter != storage_objects.end(); ++storage_iter) { 572 storage_iter != storage_objects.end(); ++storage_iter) {
572 const std::string& storage_id = storage_iter->object_persistent_id; 573 const std::string& storage_id = storage_iter->object_persistent_id;
573 DCHECK(!ContainsKey(storage_map_, storage_id)); 574 DCHECK(!ContainsKey(storage_map_, storage_id));
574 575
575 // Keep track of storage id and storage name to see how often we receive 576 // Keep track of storage id and storage name to see how often we receive
576 // empty values. 577 // empty values.
577 MediaStorageUtil::RecordDeviceInfoHistogram(false, storage_id, name); 578 MediaStorageUtil::RecordDeviceInfoHistogram(false, storage_id, name);
578 if (storage_id.empty() || name.empty()) 579 if (storage_id.empty() || name.empty())
579 return; 580 return;
580 581
581 // Device can have several data partitions. Therefore, add the 582 // Device can have several data partitions. Therefore, add the
582 // partition identifier to the storage name. E.g.: "Nexus 7 (s10001)" 583 // partition identifier to the storage name. E.g.: "Nexus 7 (s10001)"
583 string16 storage_name(name + L" (" + storage_iter->object_temporary_id + 584 string16 storage_name(name + L" (" + storage_iter->object_temporary_id +
584 L')'); 585 L')');
585 storage_map_[storage_id] = 586 storage_map_[storage_id] =
586 base::SystemMonitor::RemovableStorageInfo(storage_id, storage_name, 587 RemovableStorageInfo(storage_id, storage_name,
587 location); 588 location);
588 system_monitor->ProcessRemovableStorageAttached( 589 notifications->ProcessRemovableStorageAttached(
589 storage_id, storage_name, GetStoragePathFromStorageId(storage_id)); 590 storage_id, storage_name, GetStoragePathFromStorageId(storage_id));
590 } 591 }
591 device_map_[location] = storage_objects; 592 device_map_[location] = storage_objects;
592 } 593 }
593 594
594 void PortableDeviceWatcherWin::HandleDeviceDetachEvent( 595 void PortableDeviceWatcherWin::HandleDeviceDetachEvent(
595 const string16& pnp_device_id) { 596 const string16& pnp_device_id) {
596 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 597 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
597 MTPDeviceMap::iterator device_iter = device_map_.find(pnp_device_id); 598 MTPDeviceMap::iterator device_iter = device_map_.find(pnp_device_id);
598 if (device_iter == device_map_.end()) 599 if (device_iter == device_map_.end())
599 return; 600 return;
600 601
601 base::SystemMonitor* system_monitor = base::SystemMonitor::Get(); 602 RemovableStorageNotifications* notifications =
602 DCHECK(system_monitor); 603 RemovableStorageNotifications::Get();
604 DCHECK(notifications);
603 605
604 const StorageObjects& storage_objects = device_iter->second; 606 const StorageObjects& storage_objects = device_iter->second;
605 for (StorageObjects::const_iterator storage_object_iter = 607 for (StorageObjects::const_iterator storage_object_iter =
606 storage_objects.begin(); storage_object_iter != storage_objects.end(); 608 storage_objects.begin(); storage_object_iter != storage_objects.end();
607 ++storage_object_iter) { 609 ++storage_object_iter) {
608 std::string storage_id = storage_object_iter->object_persistent_id; 610 std::string storage_id = storage_object_iter->object_persistent_id;
609 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id); 611 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id);
610 DCHECK(storage_map_iter != storage_map_.end()); 612 DCHECK(storage_map_iter != storage_map_.end());
611 system_monitor->ProcessRemovableStorageDetached( 613 notifications->ProcessRemovableStorageDetached(
612 storage_map_iter->second.device_id); 614 storage_map_iter->second.device_id);
613 storage_map_.erase(storage_map_iter); 615 storage_map_.erase(storage_map_iter);
614 } 616 }
615 device_map_.erase(device_iter); 617 device_map_.erase(device_iter);
616 } 618 }
617 619
618 } // namespace chrome 620 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698