diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 07:18:06 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-02 07:18:06 +0000 |
commit | 20f067e1c97ada685a266799302b72be841cc86b (patch) | |
tree | 35efbc32456297d16264e6c2a8a532cdf585dfe7 | |
parent | 654f7115c0bfbf1308dfb424e92da496e7170545 (diff) | |
download | chromium_src-20f067e1c97ada685a266799302b72be841cc86b.zip chromium_src-20f067e1c97ada685a266799302b72be841cc86b.tar.gz chromium_src-20f067e1c97ada685a266799302b72be841cc86b.tar.bz2 |
[MediaGallery] Cleanup: Rename MtpDeviceDelegate* to MTPDeviceDelegate*.
Rename all function/class names to use "MTP" instead of "mtp"
BUG=none
TEST=none
TBR=kinuko
Review URL: https://chromiumcodereview.appspot.com/11364042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165639 0039d316-1c4b-4281-b951-d872f2087c98
10 files changed, 123 insertions, 120 deletions
diff --git a/chrome/browser/media_gallery/media_file_system_registry.cc b/chrome/browser/media_gallery/media_file_system_registry.cc index 030cb4b..ceda848 100644 --- a/chrome/browser/media_gallery/media_file_system_registry.cc +++ b/chrome/browser/media_gallery/media_file_system_registry.cc @@ -59,7 +59,7 @@ using content::WebContents; using fileapi::IsolatedContext; #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) -using fileapi::MtpDeviceMapService; +using fileapi::MTPDeviceMapService; #endif namespace chrome { @@ -126,56 +126,56 @@ MediaFileSystemInfo::MediaFileSystemInfo(const std::string& fs_name, MediaFileSystemInfo::MediaFileSystemInfo() {} #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) -// Class to manage MtpDeviceDelegateImpl object for the attached mtp device. -// Refcounted to reuse the same mtp device delegate entry across extensions. +// Class to manage MTPDeviceDelegateImpl object for the attached MTP device. +// Refcounted to reuse the same MTP device delegate entry across extensions. // This class supports WeakPtr (extends SupportsWeakPtr) to expose itself as // a weak pointer to MediaFileSystemRegistry. -class ScopedMtpDeviceMapEntry - : public base::RefCounted<ScopedMtpDeviceMapEntry>, - public base::SupportsWeakPtr<ScopedMtpDeviceMapEntry> { +class ScopedMTPDeviceMapEntry + : public base::RefCounted<ScopedMTPDeviceMapEntry>, + public base::SupportsWeakPtr<ScopedMTPDeviceMapEntry> { public: - // |no_references_callback| is called when the last ScopedMtpDeviceMapEntry + // |no_references_callback| is called when the last ScopedMTPDeviceMapEntry // reference goes away. - ScopedMtpDeviceMapEntry(const FilePath::StringType& device_location, + ScopedMTPDeviceMapEntry(const FilePath::StringType& device_location, const base::Closure& no_references_callback) : device_location_(device_location), - delegate_(new MtpDeviceDelegateImpl(device_location)), + delegate_(new MTPDeviceDelegateImpl(device_location)), no_references_callback_(no_references_callback) { DCHECK(delegate_); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - Bind(&MtpDeviceMapService::AddDelegate, - base::Unretained(MtpDeviceMapService::GetInstance()), + Bind(&MTPDeviceMapService::AddDelegate, + base::Unretained(MTPDeviceMapService::GetInstance()), device_location_, make_scoped_refptr(delegate_))); } private: // Friend declaration for ref counted implementation. - friend class base::RefCounted<ScopedMtpDeviceMapEntry>; + friend class base::RefCounted<ScopedMTPDeviceMapEntry>; // Private because this class is ref-counted. - ~ScopedMtpDeviceMapEntry() { + ~ScopedMTPDeviceMapEntry() { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - Bind(&MtpDeviceMapService::RemoveDelegate, - base::Unretained(MtpDeviceMapService::GetInstance()), + Bind(&MTPDeviceMapService::RemoveDelegate, + base::Unretained(MTPDeviceMapService::GetInstance()), device_location_)); no_references_callback_.Run(); } - // Store the mtp or ptp device location. + // Store the MTP or PTP device location. const FilePath::StringType device_location_; - // Store a raw pointer of MtpDeviceDelegateImpl object. - // MtpDeviceDelegateImpl is ref-counted and owned by MtpDeviceMapService. - // This class tells MtpDeviceMapService to dispose of it when the last + // Store a raw pointer of MTPDeviceDelegateImpl object. + // MTPDeviceDelegateImpl is ref-counted and owned by MTPDeviceMapService. + // This class tells MTPDeviceMapService to dispose of it when the last // reference to |this| goes away. - MtpDeviceDelegateImpl* delegate_; + MTPDeviceDelegateImpl* delegate_; // A callback to call when the last reference of this object goes away. base::Closure no_references_callback_; - DISALLOW_COPY_AND_ASSIGN(ScopedMtpDeviceMapEntry); + DISALLOW_COPY_AND_ASSIGN(ScopedMTPDeviceMapEntry); }; #endif @@ -247,10 +247,10 @@ class ExtensionGalleriesHost pref_id_map_.erase(gallery); #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) - MediaDeviceEntryReferencesMap::iterator mtp_device_host = + MediaDeviceEntryReferencesMap::iterator MTP_device_host = media_device_map_references_.find(id); - if (mtp_device_host != media_device_map_references_.end()) - media_device_map_references_.erase(mtp_device_host); + if (MTP_device_host != media_device_map_references_.end()) + media_device_map_references_.erase(MTP_device_host); #endif } @@ -282,7 +282,7 @@ class ExtensionGalleriesHost PrefIdFsInfoMap; #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) typedef std::map<MediaGalleryPrefId, - scoped_refptr<ScopedMtpDeviceMapEntry> > + scoped_refptr<ScopedMTPDeviceMapEntry> > MediaDeviceEntryReferencesMap; #endif typedef std::map<const RenderProcessHost*, std::set<const WebContents*> > @@ -365,11 +365,11 @@ class ExtensionGalleriesHost device_id, path); } else { #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) - scoped_refptr<ScopedMtpDeviceMapEntry> mtp_device_host; - fsid = file_system_context_->RegisterFileSystemForMtpDevice( - device_id, path, &mtp_device_host); - DCHECK(mtp_device_host.get()); - media_device_map_references_[pref_id] = mtp_device_host; + scoped_refptr<ScopedMTPDeviceMapEntry> MTP_device_host; + fsid = file_system_context_->RegisterFileSystemForMTPDevice( + device_id, path, &MTP_device_host); + DCHECK(MTP_device_host.get()); + media_device_map_references_[pref_id] = MTP_device_host; #else NOTIMPLEMENTED(); continue; @@ -634,9 +634,9 @@ class MediaFileSystemRegistry::MediaFileSystemContextImpl } #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) - virtual std::string RegisterFileSystemForMtpDevice( + virtual std::string RegisterFileSystemForMTPDevice( const std::string& device_id, const FilePath& path, - scoped_refptr<ScopedMtpDeviceMapEntry>* entry) { + scoped_refptr<ScopedMTPDeviceMapEntry>* entry) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(!MediaStorageUtil::IsMassStorageDevice(device_id)); @@ -649,7 +649,7 @@ class MediaFileSystemRegistry::MediaFileSystemContextImpl fileapi::kFileSystemTypeDeviceMedia, path, &fs_name); CHECK(!fsid.empty()); DCHECK(entry); - *entry = registry_->GetOrCreateScopedMtpDeviceMapEntry(path.value()); + *entry = registry_->GetOrCreateScopedMTPDeviceMapEntry(path.value()); return fsid; } #endif @@ -719,22 +719,22 @@ void MediaFileSystemRegistry::OnPreferenceChanged( } #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) -ScopedMtpDeviceMapEntry* -MediaFileSystemRegistry::GetOrCreateScopedMtpDeviceMapEntry( +ScopedMTPDeviceMapEntry* +MediaFileSystemRegistry::GetOrCreateScopedMTPDeviceMapEntry( const FilePath::StringType& device_location) { MTPDeviceDelegateMap::iterator delegate_it = mtp_delegate_map_.find(device_location); if (delegate_it != mtp_delegate_map_.end() && delegate_it->second.get()) return delegate_it->second; - ScopedMtpDeviceMapEntry* mtp_device_host = new ScopedMtpDeviceMapEntry( + ScopedMTPDeviceMapEntry* MTP_device_host = new ScopedMTPDeviceMapEntry( device_location, base::Bind( - &MediaFileSystemRegistry::RemoveScopedMtpDeviceMapEntry, + &MediaFileSystemRegistry::RemoveScopedMTPDeviceMapEntry, base::Unretained(this), device_location)); - mtp_delegate_map_[device_location] = mtp_device_host->AsWeakPtr(); - return mtp_device_host; + mtp_delegate_map_[device_location] = MTP_device_host->AsWeakPtr(); + return MTP_device_host; } -void MediaFileSystemRegistry::RemoveScopedMtpDeviceMapEntry( +void MediaFileSystemRegistry::RemoveScopedMTPDeviceMapEntry( const FilePath::StringType& device_location) { MTPDeviceDelegateMap::iterator delegate_it = mtp_delegate_map_.find(device_location); diff --git a/chrome/browser/media_gallery/media_file_system_registry.h b/chrome/browser/media_gallery/media_file_system_registry.h index bfc266d..1fc2ac1 100644 --- a/chrome/browser/media_gallery/media_file_system_registry.h +++ b/chrome/browser/media_gallery/media_file_system_registry.h @@ -41,7 +41,7 @@ namespace chrome { class ExtensionGalleriesHost; class MediaGalleriesPreferences; -class ScopedMtpDeviceMapEntry; +class ScopedMTPDeviceMapEntry; struct MediaFileSystemInfo { MediaFileSystemInfo(const std::string& fs_name, @@ -64,12 +64,12 @@ class MediaFileSystemContext { const std::string& device_id, const FilePath& path) = 0; #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) - // Registers and returns the file system id for the mtp or ptp device + // Registers and returns the file system id for the MTP or PTP device // specified by |device_id| and |path|. Updates |entry| with the corresponding - // ScopedMtpDeviceMapEntry object. - virtual std::string RegisterFileSystemForMtpDevice( + // ScopedMTPDeviceMapEntry object. + virtual std::string RegisterFileSystemForMTPDevice( const std::string& device_id, const FilePath& path, - scoped_refptr<ScopedMtpDeviceMapEntry>* entry) = 0; + scoped_refptr<ScopedMTPDeviceMapEntry>* entry) = 0; #endif // Revoke the passed |fsid|. @@ -120,10 +120,10 @@ class MediaFileSystemRegistry typedef std::map<Profile*, PrefChangeRegistrar*> PrefChangeRegistrarMap; #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) - // Map a mtp or ptp device location to the weak pointer of - // ScopedMtpDeviceMapEntry. + // Map a MTP or PTP device location to the weak pointer of + // ScopedMTPDeviceMapEntry. typedef std::map<const FilePath::StringType, - base::WeakPtr<ScopedMtpDeviceMapEntry> > + base::WeakPtr<ScopedMTPDeviceMapEntry> > MTPDeviceDelegateMap; #endif @@ -136,13 +136,13 @@ class MediaFileSystemRegistry const std::string& pref_name) OVERRIDE; #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) - // Returns ScopedMtpDeviceMapEntry object for the given |device_location|. - ScopedMtpDeviceMapEntry* GetOrCreateScopedMtpDeviceMapEntry( + // Returns ScopedMTPDeviceMapEntry object for the given |device_location|. + ScopedMTPDeviceMapEntry* GetOrCreateScopedMTPDeviceMapEntry( const FilePath::StringType& device_location); - // Removes the ScopedMtpDeviceMapEntry associated with the given + // Removes the ScopedMTPDeviceMapEntry associated with the given // |device_location|. - void RemoveScopedMtpDeviceMapEntry( + void RemoveScopedMTPDeviceMapEntry( const FilePath::StringType& device_location); #endif diff --git a/chrome/browser/media_gallery/mtp_device_delegate_impl.h b/chrome/browser/media_gallery/mtp_device_delegate_impl.h index 5fffdfd..535d681 100644 --- a/chrome/browser/media_gallery/mtp_device_delegate_impl.h +++ b/chrome/browser/media_gallery/mtp_device_delegate_impl.h @@ -18,9 +18,9 @@ namespace chrome { -// TODO(kmadhusu): Implement mtp device delegates on other platforms. +// TODO(kmadhusu): Implement MTP device delegates on other platforms. #if defined(OS_LINUX) // Implies OS_CHROMEOS -typedef class MtpDeviceDelegateImplLinux MtpDeviceDelegateImpl; +typedef class MTPDeviceDelegateImplLinux MTPDeviceDelegateImpl; #endif } // namespace chrome diff --git a/chrome/browser/media_gallery/mtp_device_delegate_impl_linux.cc b/chrome/browser/media_gallery/mtp_device_delegate_impl_linux.cc index 69e6f0d..501ed62 100644 --- a/chrome/browser/media_gallery/mtp_device_delegate_impl_linux.cc +++ b/chrome/browser/media_gallery/mtp_device_delegate_impl_linux.cc @@ -56,10 +56,10 @@ const char kRootPath[] = "/"; // Returns MediaTransferProtocolManager instance on success or NULL on failure. MediaTransferProtocolManager* GetMediaTransferProtocolManager() { - MediaTransferProtocolManager* mtp_dev_mgr = + MediaTransferProtocolManager* mtp_device_mgr = MediaTransferProtocolManager::GetInstance(); - DCHECK(mtp_dev_mgr); - return mtp_dev_mgr; + DCHECK(mtp_device_mgr); + return mtp_device_mgr; } // Does nothing. @@ -89,7 +89,7 @@ std::string GetDeviceRelativePath(const std::string& registered_dev_path, return actual_file_path; } -// Worker class to open a mtp device for communication. This class is +// Worker class to open a MTP device for communication. This class is // instantiated and destructed on |media_task_runner_|. In order to post a // request on Dbus thread, the caller should run on UI thread. Therefore, this // class posts the open device request on UI thread and receives the response @@ -146,7 +146,7 @@ class OpenStorageWorker // This object must be destructed on |media_task_runner_|. } - // Dispatches a request to MediaTransferProtocolManager to open the mtp + // Dispatches a request to MediaTransferProtocolManager to open the MTP // storage for communication. This is called on UI thread. void DoWorkOnUIThread() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -697,7 +697,7 @@ class RecursiveMediaFileEnumerator } // namespace -MtpDeviceDelegateImplLinux::MtpDeviceDelegateImplLinux( +MTPDeviceDelegateImplLinux::MTPDeviceDelegateImplLinux( const std::string& device_location) : device_path_(device_location), on_task_completed_event_(false, false), @@ -714,14 +714,14 @@ MtpDeviceDelegateImplLinux::MtpDeviceDelegateImplLinux( DCHECK(media_task_runner_); } -MtpDeviceDelegateImplLinux::~MtpDeviceDelegateImplLinux() { +MTPDeviceDelegateImplLinux::~MTPDeviceDelegateImplLinux() { registrar_.RemoveAll(); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); GetMediaTransferProtocolManager()->CloseStorage(device_handle_, Bind(&DoNothing)); } -PlatformFileError MtpDeviceDelegateImplLinux::GetFileInfo( +PlatformFileError MTPDeviceDelegateImplLinux::GetFileInfo( const FilePath& file_path, PlatformFileInfo* file_info) { if (!LazyInit()) @@ -735,7 +735,7 @@ PlatformFileError MtpDeviceDelegateImplLinux::GetFileInfo( } FileSystemFileUtil::AbstractFileEnumerator* -MtpDeviceDelegateImplLinux::CreateFileEnumerator( +MTPDeviceDelegateImplLinux::CreateFileEnumerator( const FilePath& root, bool recursive) { if (root.value().empty() || !LazyInit()) @@ -757,7 +757,7 @@ MtpDeviceDelegateImplLinux::CreateFileEnumerator( return new MediaFileEnumerator(worker->get_file_entries()); } -PlatformFileError MtpDeviceDelegateImplLinux::CreateSnapshotFile( +PlatformFileError MTPDeviceDelegateImplLinux::CreateSnapshotFile( const FilePath& device_file_path, const FilePath& local_path, PlatformFileInfo* file_info) { @@ -786,11 +786,11 @@ PlatformFileError MtpDeviceDelegateImplLinux::CreateSnapshotFile( return error; } -SequencedTaskRunner* MtpDeviceDelegateImplLinux::media_task_runner() { +SequencedTaskRunner* MTPDeviceDelegateImplLinux::GetMediaTaskRunner() { return media_task_runner_.get(); } -void MtpDeviceDelegateImplLinux::DeleteOnCorrectThread() const { +void MTPDeviceDelegateImplLinux::DeleteOnCorrectThread() const { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this); return; @@ -798,7 +798,7 @@ void MtpDeviceDelegateImplLinux::DeleteOnCorrectThread() const { delete this; } -void MtpDeviceDelegateImplLinux::Observe( +void MTPDeviceDelegateImplLinux::Observe( int type, const content::NotificationSource& source, const content::NotificationDetails& details) { @@ -807,7 +807,7 @@ void MtpDeviceDelegateImplLinux::Observe( on_task_completed_event_.Signal(); } -bool MtpDeviceDelegateImplLinux::LazyInit() { +bool MTPDeviceDelegateImplLinux::LazyInit() { DCHECK(media_task_runner_); DCHECK(media_task_runner_->RunsTasksOnCurrentThread()); diff --git a/chrome/browser/media_gallery/mtp_device_delegate_impl_linux.h b/chrome/browser/media_gallery/mtp_device_delegate_impl_linux.h index eb21b30..0560a04 100644 --- a/chrome/browser/media_gallery/mtp_device_delegate_impl_linux.h +++ b/chrome/browser/media_gallery/mtp_device_delegate_impl_linux.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_MEDIA_GALLERY_MTP_DEVICE_DELEGATE_IMPL_LINUX_H_ #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "base/platform_file.h" #include "base/synchronization/waitable_event.h" #include "content/public/browser/notification_observer.h" @@ -24,34 +25,35 @@ namespace chrome { // Helper class to communicate with MTP storage to complete isolated file system // operations. This class contains platform specific code to communicate with // the attached MTP storage. Instantiate this class per MTP storage. -// This class is ref-counted, because MtpDeviceDelegate is ref-counted. -class MtpDeviceDelegateImplLinux : public fileapi::MtpDeviceDelegate, +// This class is ref-counted, because MTPDeviceDelegate is ref-counted. +class MTPDeviceDelegateImplLinux : public fileapi::MTPDeviceDelegate, public content::NotificationObserver { public: // Constructed on UI thread. Defer the device initializations until the first // file operation request. Do all the initializations in LazyInit() function. - explicit MtpDeviceDelegateImplLinux(const std::string& device_location); + explicit MTPDeviceDelegateImplLinux(const std::string& device_location); - // Overridden from MtpDeviceDelegate. All the functions are called on + // Overridden from MTPDeviceDelegate. All the functions are called on // |media_task_runner_|. virtual base::PlatformFileError GetFileInfo( const FilePath& file_path, base::PlatformFileInfo* file_info) OVERRIDE; virtual fileapi::FileSystemFileUtil::AbstractFileEnumerator* - CreateFileEnumerator(const FilePath& root, bool recursive) OVERRIDE; + CreateFileEnumerator(const FilePath& root, + bool recursive) OVERRIDE; virtual base::PlatformFileError CreateSnapshotFile( const FilePath& device_file_path, const FilePath& local_path, base::PlatformFileInfo* file_info) OVERRIDE; - virtual base::SequencedTaskRunner* media_task_runner() OVERRIDE; + virtual base::SequencedTaskRunner* GetMediaTaskRunner() OVERRIDE; virtual void DeleteOnCorrectThread() const OVERRIDE; private: - friend struct fileapi::MtpDeviceDelegateDeleter; - friend class base::DeleteHelper<MtpDeviceDelegateImplLinux>; + friend struct fileapi::MTPDeviceDelegateDeleter; + friend class base::DeleteHelper<MTPDeviceDelegateImplLinux>; // Private because this class is ref-counted. - virtual ~MtpDeviceDelegateImplLinux(); + virtual ~MTPDeviceDelegateImplLinux(); // content::NotificationObserver implementation. virtual void Observe(int type, @@ -87,7 +89,7 @@ class MtpDeviceDelegateImplLinux : public fileapi::MtpDeviceDelegate, // Used to listen for application termination message. content::NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(MtpDeviceDelegateImplLinux); + DISALLOW_COPY_AND_ASSIGN(MTPDeviceDelegateImplLinux); }; } // namespace chrome diff --git a/webkit/fileapi/file_system_operation_context.h b/webkit/fileapi/file_system_operation_context.h index b376b21..067e0d8 100644 --- a/webkit/fileapi/file_system_operation_context.h +++ b/webkit/fileapi/file_system_operation_context.h @@ -38,11 +38,11 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemOperationContext { int64 allowed_bytes_growth() const { return allowed_bytes_growth_; } #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) - void set_mtp_device_delegate(MtpDeviceDelegate* delegate) { + void set_mtp_device_delegate(MTPDeviceDelegate* delegate) { mtp_device_delegate_ = delegate; } - MtpDeviceDelegate* mtp_device_delegate() const { + MTPDeviceDelegate* mtp_device_delegate() const { return mtp_device_delegate_.get(); } #endif @@ -92,7 +92,7 @@ class WEBKIT_STORAGE_EXPORT_PRIVATE FileSystemOperationContext { #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) // Store the current mtp device delegate. - scoped_refptr<MtpDeviceDelegate> mtp_device_delegate_; + scoped_refptr<MTPDeviceDelegate> mtp_device_delegate_; #endif }; diff --git a/webkit/fileapi/isolated_mount_point_provider.cc b/webkit/fileapi/isolated_mount_point_provider.cc index 2554edc..a11731d 100644 --- a/webkit/fileapi/isolated_mount_point_provider.cc +++ b/webkit/fileapi/isolated_mount_point_provider.cc @@ -123,16 +123,16 @@ FileSystemOperation* IsolatedMountPointProvider::CreateFileSystemOperation( #if defined(SUPPORT_MTP_DEVICE_FILESYSTEM) if (url.type() == kFileSystemTypeDeviceMedia) { - MtpDeviceMapService* map_service = MtpDeviceMapService::GetInstance(); - MtpDeviceDelegate* device_delegate = - map_service->GetMtpDeviceDelegate(url.filesystem_id()); + MTPDeviceMapService* map_service = MTPDeviceMapService::GetInstance(); + MTPDeviceDelegate* device_delegate = + map_service->GetMTPDeviceDelegate(url.filesystem_id()); if (!device_delegate) { if (error_code) *error_code = base::PLATFORM_FILE_ERROR_NOT_FOUND; return NULL; } operation_context->set_mtp_device_delegate(device_delegate); - operation_context->set_task_runner(device_delegate->media_task_runner()); + operation_context->set_task_runner(device_delegate->GetMediaTaskRunner()); operation_context->set_media_path_filter(media_path_filter_.get()); } #endif diff --git a/webkit/fileapi/media/mtp_device_delegate.h b/webkit/fileapi/media/mtp_device_delegate.h index a90fb61..5c031d2 100644 --- a/webkit/fileapi/media/mtp_device_delegate.h +++ b/webkit/fileapi/media/mtp_device_delegate.h @@ -7,6 +7,7 @@ #include "base/file_path.h" #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "base/platform_file.h" #include "base/sequenced_task_runner_helpers.h" #include "webkit/fileapi/file_system_file_util.h" @@ -19,14 +20,14 @@ class Time; namespace fileapi { -struct MtpDeviceDelegateDeleter; +struct MTPDeviceDelegateDeleter; -// Delegate for mtp device to perform media device isolated file system -// operations. Class that implements this delegate does the actual communication -// with the mtp device. -class MtpDeviceDelegate - : public base::RefCountedThreadSafe<MtpDeviceDelegate, - MtpDeviceDelegateDeleter> { +// Delegate for media transfer protocol (MTP_ device to perform media device +// isolated file system operations. Class that implements this delegate does +// the actual communication with the MTP device. +class MTPDeviceDelegate + : public base::RefCountedThreadSafe<MTPDeviceDelegate, + MTPDeviceDelegateDeleter> { public: // Returns information about the given file path. virtual base::PlatformFileError GetFileInfo( @@ -50,23 +51,23 @@ class MtpDeviceDelegate base::PlatformFileInfo* file_info) = 0; // Returns TaskRunner on which the operation is performed. - virtual base::SequencedTaskRunner* media_task_runner() = 0; + virtual base::SequencedTaskRunner* GetMediaTaskRunner() = 0; // Helper function to destruct the delegate object on UI thread. virtual void DeleteOnCorrectThread() const = 0; protected: - virtual ~MtpDeviceDelegate() {} + virtual ~MTPDeviceDelegate() {} private: - friend struct MtpDeviceDelegateDeleter; - friend class base::DeleteHelper<MtpDeviceDelegate>; - friend class base::RefCountedThreadSafe<MtpDeviceDelegate, - MtpDeviceDelegateDeleter>; + friend struct MTPDeviceDelegateDeleter; + friend class base::DeleteHelper<MTPDeviceDelegate>; + friend class base::RefCountedThreadSafe<MTPDeviceDelegate, + MTPDeviceDelegateDeleter>; }; -struct MtpDeviceDelegateDeleter { - static void Destruct(const MtpDeviceDelegate* delegate) { +struct MTPDeviceDelegateDeleter { + static void Destruct(const MTPDeviceDelegate* delegate) { delegate->DeleteOnCorrectThread(); } }; diff --git a/webkit/fileapi/media/mtp_device_map_service.cc b/webkit/fileapi/media/mtp_device_map_service.cc index 1dee157..68bf3d4 100644 --- a/webkit/fileapi/media/mtp_device_map_service.cc +++ b/webkit/fileapi/media/mtp_device_map_service.cc @@ -14,13 +14,13 @@ namespace fileapi { // static -MtpDeviceMapService* MtpDeviceMapService::GetInstance() { - return Singleton<MtpDeviceMapService>::get(); +MTPDeviceMapService* MTPDeviceMapService::GetInstance() { + return Singleton<MTPDeviceMapService>::get(); } -void MtpDeviceMapService::AddDelegate( +void MTPDeviceMapService::AddDelegate( const FilePath::StringType& device_location, - scoped_refptr<MtpDeviceDelegate> delegate) { + scoped_refptr<MTPDeviceDelegate> delegate) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(delegate.get()); DCHECK(!device_location.empty()); @@ -31,7 +31,7 @@ void MtpDeviceMapService::AddDelegate( delegate_map_[device_location] = delegate; } -void MtpDeviceMapService::RemoveDelegate( +void MTPDeviceMapService::RemoveDelegate( const FilePath::StringType& device_location) { DCHECK(thread_checker_.CalledOnValidThread()); DelegateMap::iterator it = delegate_map_.find(device_location); @@ -39,7 +39,7 @@ void MtpDeviceMapService::RemoveDelegate( delegate_map_.erase(it); } -MtpDeviceDelegate* MtpDeviceMapService::GetMtpDeviceDelegate( +MTPDeviceDelegate* MTPDeviceMapService::GetMTPDeviceDelegate( const std::string& filesystem_id) { DCHECK(thread_checker_.CalledOnValidThread()); FilePath device_path; @@ -56,12 +56,12 @@ MtpDeviceDelegate* MtpDeviceMapService::GetMtpDeviceDelegate( return it->second.get(); } -MtpDeviceMapService::MtpDeviceMapService() { +MTPDeviceMapService::MTPDeviceMapService() { // This object is constructed on UI Thread but the member functions are // accessed on IO thread. Therefore, detach from current thread. thread_checker_.DetachFromThread(); } -MtpDeviceMapService::~MtpDeviceMapService() {} +MTPDeviceMapService::~MTPDeviceMapService() {} } // namespace fileapi diff --git a/webkit/fileapi/media/mtp_device_map_service.h b/webkit/fileapi/media/mtp_device_map_service.h index 1b1ffd9..3002097 100644 --- a/webkit/fileapi/media/mtp_device_map_service.h +++ b/webkit/fileapi/media/mtp_device_map_service.h @@ -15,18 +15,18 @@ namespace fileapi { -class MtpDeviceDelegate; +class MTPDeviceDelegate; // Helper class to manage media device delegates which can communicate with mtp // devices to complete media file system operations. -class WEBKIT_STORAGE_EXPORT MtpDeviceMapService { +class WEBKIT_STORAGE_EXPORT MTPDeviceMapService { public: - static MtpDeviceMapService* GetInstance(); + static MTPDeviceMapService* GetInstance(); // Adds the media device delegate for the given |device_location|. Called on // IO thread. void AddDelegate(const FilePath::StringType& device_location, - scoped_refptr<MtpDeviceDelegate> delegate); + scoped_refptr<MTPDeviceDelegate> delegate); // Removes the media device delegate for the given |device_location| if // exists. Called on IO thread. @@ -35,19 +35,19 @@ class WEBKIT_STORAGE_EXPORT MtpDeviceMapService { // Gets the media device delegate associated with |filesystem_id|. // Return NULL if the |filesystem_id| is no longer valid (e.g. because the // corresponding device is detached etc). Called on IO thread. - MtpDeviceDelegate* GetMtpDeviceDelegate(const std::string& filesystem_id); + MTPDeviceDelegate* GetMTPDeviceDelegate(const std::string& filesystem_id); private: - friend struct DefaultSingletonTraits<MtpDeviceMapService>; + friend struct DefaultSingletonTraits<MTPDeviceMapService>; - typedef scoped_refptr<MtpDeviceDelegate> MtpDeviceDelegateObj; + typedef scoped_refptr<MTPDeviceDelegate> MTPDeviceDelegateObj; - // Mapping of device_location and MtpDeviceDelegate object. - typedef std::map<FilePath::StringType, MtpDeviceDelegateObj> DelegateMap; + // Mapping of device_location and MTPDeviceDelegate object. + typedef std::map<FilePath::StringType, MTPDeviceDelegateObj> DelegateMap; // Get access to this class using GetInstance() method. - MtpDeviceMapService(); - ~MtpDeviceMapService(); + MTPDeviceMapService(); + ~MTPDeviceMapService(); // Stores a map of attached mtp device delegates. DelegateMap delegate_map_; @@ -56,7 +56,7 @@ class WEBKIT_STORAGE_EXPORT MtpDeviceMapService { // called on same thread. base::ThreadChecker thread_checker_; - DISALLOW_COPY_AND_ASSIGN(MtpDeviceMapService); + DISALLOW_COPY_AND_ASSIGN(MTPDeviceMapService); }; } // namespace fileapi |