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

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

Issue 11297002: [Media Gallery] Added code to support mtp device media file system on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed class comments and removed file comments 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 if (!IsPortableDeviceStructure(data)) 509 if (!IsPortableDeviceStructure(data))
510 return; 510 return;
511 511
512 string16 device_id = GetPnpDeviceId(data); 512 string16 device_id = GetPnpDeviceId(data);
513 if (event_type == DBT_DEVICEARRIVAL) 513 if (event_type == DBT_DEVICEARRIVAL)
514 HandleDeviceAttachEvent(device_id); 514 HandleDeviceAttachEvent(device_id);
515 else if (event_type == DBT_DEVICEREMOVECOMPLETE) 515 else if (event_type == DBT_DEVICEREMOVECOMPLETE)
516 HandleDeviceDetachEvent(device_id); 516 HandleDeviceDetachEvent(device_id);
517 } 517 }
518 518
519 bool PortableDeviceWatcherWin::GetMTPStorageInfoFromDeviceId(
520 const std::string& storage_device_id,
521 string16* device_location,
522 string16* storage_object_id) {
523 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
524 DCHECK(device_location);
525 DCHECK(storage_object_id);
526 MTPStorageMap::const_iterator storage_map_iter =
527 storage_map_.find(storage_device_id);
528 if (storage_map_iter == storage_map_.end())
529 return false;
530
531 *device_location = storage_map_iter->second.location;
532 MTPDeviceMap::const_iterator device_iter = device_map_.find(*device_location);
533 DCHECK(device_iter != device_map_.end());
Ryan Sleevi 2013/01/09 20:22:25 This DCHECK leaves me a lil squicky, since AIUI, t
kmadhusu 2013/01/10 04:59:19 When the device is removed, line 528 will be true
534 const StorageObjects& storage_objects = device_iter->second;
535 for (StorageObjects::const_iterator storage_object_iter =
536 storage_objects.begin(); storage_object_iter != storage_objects.end();
537 ++storage_object_iter) {
538 if (storage_device_id == storage_object_iter->object_persistent_id) {
539 *storage_object_id = storage_object_iter->object_temporary_id;
540 break;
541 }
542 }
543 return !storage_object_id->empty();
544 }
545
519 void PortableDeviceWatcherWin::EnumerateAttachedDevices() { 546 void PortableDeviceWatcherWin::EnumerateAttachedDevices() {
520 DCHECK(media_task_runner_.get()); 547 DCHECK(media_task_runner_.get());
521 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 548 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
522 Devices* devices = new Devices; 549 Devices* devices = new Devices;
523 base::PostTaskAndReplyWithResult( 550 base::PostTaskAndReplyWithResult(
524 media_task_runner_, 551 media_task_runner_,
525 FROM_HERE, 552 FROM_HERE,
526 base::Bind(&EnumerateAttachedDevicesOnBlockingThread, devices), 553 base::Bind(&EnumerateAttachedDevicesOnBlockingThread, devices),
527 base::Bind(&PortableDeviceWatcherWin::OnDidEnumerateAttachedDevices, 554 base::Bind(&PortableDeviceWatcherWin::OnDidEnumerateAttachedDevices,
528 weak_ptr_factory_.GetWeakPtr(), base::Owned(devices))); 555 weak_ptr_factory_.GetWeakPtr(), base::Owned(devices)));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id); 636 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id);
610 DCHECK(storage_map_iter != storage_map_.end()); 637 DCHECK(storage_map_iter != storage_map_.end());
611 system_monitor->ProcessRemovableStorageDetached( 638 system_monitor->ProcessRemovableStorageDetached(
612 storage_map_iter->second.device_id); 639 storage_map_iter->second.device_id);
613 storage_map_.erase(storage_map_iter); 640 storage_map_.erase(storage_map_iter);
614 } 641 }
615 device_map_.erase(device_iter); 642 device_map_.erase(device_iter);
616 } 643 }
617 644
618 } // namespace chrome 645 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698