| OLD | NEW |
| 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 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" | 5 #include "chrome/browser/media_galleries/fileapi/mtp_device_map_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" | 11 #include "chrome/browser/media_galleries/fileapi/mtp_device_async_delegate.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "webkit/browser/fileapi/external_mount_points.h" | 13 #include "storage/browser/fileapi/external_mount_points.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 base::LazyInstance<MTPDeviceMapService> g_mtp_device_map_service = | 17 base::LazyInstance<MTPDeviceMapService> g_mtp_device_map_service = |
| 18 LAZY_INSTANCE_INITIALIZER; | 18 LAZY_INSTANCE_INITIALIZER; |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 // static | 22 // static |
| 23 MTPDeviceMapService* MTPDeviceMapService::GetInstance() { | 23 MTPDeviceMapService* MTPDeviceMapService::GetInstance() { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 AsyncDelegateMap::iterator it = async_delegate_map_.find(device_location); | 78 AsyncDelegateMap::iterator it = async_delegate_map_.find(device_location); |
| 79 DCHECK(it != async_delegate_map_.end()); | 79 DCHECK(it != async_delegate_map_.end()); |
| 80 it->second->CancelPendingTasksAndDeleteDelegate(); | 80 it->second->CancelPendingTasksAndDeleteDelegate(); |
| 81 async_delegate_map_.erase(it); | 81 async_delegate_map_.erase(it); |
| 82 } | 82 } |
| 83 | 83 |
| 84 MTPDeviceAsyncDelegate* MTPDeviceMapService::GetMTPDeviceAsyncDelegate( | 84 MTPDeviceAsyncDelegate* MTPDeviceMapService::GetMTPDeviceAsyncDelegate( |
| 85 const std::string& filesystem_id) { | 85 const std::string& filesystem_id) { |
| 86 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 86 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 87 base::FilePath device_path; | 87 base::FilePath device_path; |
| 88 if (!fileapi::ExternalMountPoints::GetSystemInstance()->GetRegisteredPath( | 88 if (!storage::ExternalMountPoints::GetSystemInstance()->GetRegisteredPath( |
| 89 filesystem_id, &device_path)) { | 89 filesystem_id, &device_path)) { |
| 90 return NULL; | 90 return NULL; |
| 91 } | 91 } |
| 92 | 92 |
| 93 const base::FilePath::StringType& device_location = device_path.value(); | 93 const base::FilePath::StringType& device_location = device_path.value(); |
| 94 DCHECK(!device_location.empty()); | 94 DCHECK(!device_location.empty()); |
| 95 AsyncDelegateMap::const_iterator it = | 95 AsyncDelegateMap::const_iterator it = |
| 96 async_delegate_map_.find(device_location); | 96 async_delegate_map_.find(device_location); |
| 97 return (it != async_delegate_map_.end()) ? it->second : NULL; | 97 return (it != async_delegate_map_.end()) ? it->second : NULL; |
| 98 } | 98 } |
| 99 | 99 |
| 100 MTPDeviceMapService::MTPDeviceMapService() { | 100 MTPDeviceMapService::MTPDeviceMapService() { |
| 101 } | 101 } |
| 102 | 102 |
| 103 MTPDeviceMapService::~MTPDeviceMapService() { | 103 MTPDeviceMapService::~MTPDeviceMapService() { |
| 104 DCHECK(mtp_device_usage_map_.empty()); | 104 DCHECK(mtp_device_usage_map_.empty()); |
| 105 } | 105 } |
| OLD | NEW |