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

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

Issue 23727009: Cleanup: Remove chrome namespace for storage monitor and media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 7 years, 3 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
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 "chrome/browser/storage_monitor/media_storage_util.h" 23 #include "chrome/browser/storage_monitor/media_storage_util.h"
24 #include "chrome/browser/storage_monitor/removable_device_constants.h" 24 #include "chrome/browser/storage_monitor/removable_device_constants.h"
25 #include "chrome/browser/storage_monitor/storage_info.h" 25 #include "chrome/browser/storage_monitor/storage_info.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 27
28 namespace chrome {
29
30 namespace { 28 namespace {
31 29
32 // Name of the client application that communicates with the MTP device. 30 // Name of the client application that communicates with the MTP device.
33 const char16 kClientName[] = L"Chromium"; 31 const char16 kClientName[] = L"Chromium";
34 32
35 // Name of the sequenced task runner. 33 // Name of the sequenced task runner.
36 const char kMediaTaskRunnerName[] = "media-task-runner"; 34 const char kMediaTaskRunnerName[] = "media-task-runner";
37 35
38 // Returns true if |data| represents a class of portable devices. 36 // Returns true if |data| represents a class of portable devices.
39 bool IsPortableDeviceStructure(LPARAM data) { 37 bool IsPortableDeviceStructure(LPARAM data) {
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 void PortableDeviceWatcherWin::EjectDevice( 553 void PortableDeviceWatcherWin::EjectDevice(
556 const std::string& device_id, 554 const std::string& device_id,
557 base::Callback<void(StorageMonitor::EjectStatus)> callback) { 555 base::Callback<void(StorageMonitor::EjectStatus)> callback) {
558 // MTP devices on Windows don't have a detach API needed -- signal 556 // MTP devices on Windows don't have a detach API needed -- signal
559 // the object as if the device is gone and tell the caller it is OK 557 // the object as if the device is gone and tell the caller it is OK
560 // to remove. 558 // to remove.
561 string16 device_location; // The device_map_ key. 559 string16 device_location; // The device_map_ key.
562 string16 storage_object_id; 560 string16 storage_object_id;
563 if (!GetMTPStorageInfoFromDeviceId(device_id, 561 if (!GetMTPStorageInfoFromDeviceId(device_id,
564 &device_location, &storage_object_id)) { 562 &device_location, &storage_object_id)) {
565 callback.Run(chrome::StorageMonitor::EJECT_NO_SUCH_DEVICE); 563 callback.Run(StorageMonitor::EJECT_NO_SUCH_DEVICE);
566 return; 564 return;
567 } 565 }
568 HandleDeviceDetachEvent(device_location); 566 HandleDeviceDetachEvent(device_location);
569 567
570 callback.Run(chrome::StorageMonitor::EJECT_OK); 568 callback.Run(StorageMonitor::EJECT_OK);
571 } 569 }
572 570
573 void PortableDeviceWatcherWin::EnumerateAttachedDevices() { 571 void PortableDeviceWatcherWin::EnumerateAttachedDevices() {
574 DCHECK(media_task_runner_.get()); 572 DCHECK(media_task_runner_.get());
575 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 573 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
576 Devices* devices = new Devices; 574 Devices* devices = new Devices;
577 base::PostTaskAndReplyWithResult( 575 base::PostTaskAndReplyWithResult(
578 media_task_runner_, 576 media_task_runner_,
579 FROM_HERE, 577 FROM_HERE,
580 base::Bind(&EnumerateAttachedDevicesOnBlockingThread, devices), 578 base::Bind(&EnumerateAttachedDevicesOnBlockingThread, devices),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id); 658 MTPStorageMap::iterator storage_map_iter = storage_map_.find(storage_id);
661 DCHECK(storage_map_iter != storage_map_.end()); 659 DCHECK(storage_map_iter != storage_map_.end());
662 if (storage_notifications_) { 660 if (storage_notifications_) {
663 storage_notifications_->ProcessDetach( 661 storage_notifications_->ProcessDetach(
664 storage_map_iter->second.device_id()); 662 storage_map_iter->second.device_id());
665 } 663 }
666 storage_map_.erase(storage_map_iter); 664 storage_map_.erase(storage_map_iter);
667 } 665 }
668 device_map_.erase(device_iter); 666 device_map_.erase(device_iter);
669 } 667 }
670
671 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698