1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_IMPORTED_MEDIA_GALLERY_REGISTRY_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_IMPORTED_MEDIA_GALLERY_REGISTRY_H_
11 #include "base/basictypes.h"
12 #include "base/files/file_path.h"
13 #include "base/lazy_instance.h"
14 #include "base/memory/scoped_ptr.h"
17 class IPhotoDataProvider
;
18 class IPhotoDataProviderTest
;
22 class ITunesDataProvider
;
23 class ITunesDataProviderTest
;
27 class PicasaDataProvider
;
28 class PicasaDataProviderTest
;
31 // This class lives on the MediaTaskRunner thread. It has some static
32 // methods which are called on the UI thread.
34 // MediaTaskRunner is not guaranteed to be one thread, but it is guaranteed
35 // to be a series of sequential calls. See SequencedTaskRunner for details.
36 class ImportedMediaGalleryRegistry
{
38 static ImportedMediaGalleryRegistry
* GetInstance();
40 // Should be called on the UI thread only.
41 std::string
RegisterPicasaFilesystemOnUIThread(
42 const base::FilePath
& database_path
);
44 std::string
RegisterITunesFilesystemOnUIThread(
45 const base::FilePath
& xml_library_path
);
47 std::string
RegisterIPhotoFilesystemOnUIThread(
48 const base::FilePath
& xml_library_path
);
50 bool RevokeImportedFilesystemOnUIThread(const std::string
& fsid
);
52 // Should be called on the MediaTaskRunner thread only.
53 #if defined(OS_WIN) || defined(OS_MACOSX)
54 static picasa::PicasaDataProvider
* PicasaDataProvider();
55 static itunes::ITunesDataProvider
* ITunesDataProvider();
56 #endif // defined(OS_WIN) || defined(OS_MACOSX)
58 #if defined(OS_MACOSX)
59 static iphoto::IPhotoDataProvider
* IPhotoDataProvider();
60 #endif // defined(OS_MACOSX)
63 friend struct base::DefaultLazyInstanceTraits
<ImportedMediaGalleryRegistry
>;
64 friend class iphoto::IPhotoDataProviderTest
;
65 friend class itunes::ITunesDataProviderTest
;
66 friend class picasa::PicasaDataProviderTest
;
68 ImportedMediaGalleryRegistry();
69 virtual ~ImportedMediaGalleryRegistry();
71 #if defined(OS_WIN) || defined(OS_MACOSX)
72 void RegisterPicasaFileSystem(const base::FilePath
& database_path
);
73 void RevokePicasaFileSystem();
75 void RegisterITunesFileSystem(const base::FilePath
& xml_library_path
);
76 void RevokeITunesFileSystem();
77 #endif // defined(OS_WIN) || defined(OS_MACOSX)
79 #if defined(OS_MACOSX)
80 void RegisterIPhotoFileSystem(const base::FilePath
& xml_library_path
);
81 void RevokeIPhotoFileSystem();
82 #endif // defined(OS_MACOSX)
84 #if defined(OS_WIN) || defined(OS_MACOSX)
85 // The data providers are only set or accessed on the task runner thread.
86 scoped_ptr
<picasa::PicasaDataProvider
> picasa_data_provider_
;
87 scoped_ptr
<itunes::ITunesDataProvider
> itunes_data_provider_
;
89 // The remaining members are only accessed on the IO thread.
90 std::set
<std::string
> picasa_fsids_
;
91 std::set
<std::string
> itunes_fsids_
;
94 base::FilePath picasa_database_path_
;
95 base::FilePath itunes_xml_library_path_
;
97 #endif // defined(OS_WIN) || defined(OS_MACOSX)
99 #if defined(OS_MACOSX)
100 scoped_ptr
<iphoto::IPhotoDataProvider
> iphoto_data_provider_
;
102 std::set
<std::string
> iphoto_fsids_
;
105 base::FilePath iphoto_xml_library_path_
;
107 #endif // defined(OS_MACOSX)
109 DISALLOW_COPY_AND_ASSIGN(ImportedMediaGalleryRegistry
);
112 #endif // CHROME_BROWSER_MEDIA_GALLERIES_IMPORTED_MEDIA_GALLERY_REGISTRY_H_