Give names to all utility processes.
[chromium-blink-merge.git] / chrome / browser / media_galleries / fileapi / iphoto_data_provider.h
blob26f0ccc91837c1e926f4b7b34d8926831c245a9f
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_FILEAPI_IPHOTO_DATA_PROVIDER_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IPHOTO_DATA_PROVIDER_H_
8 #include <map>
9 #include <set>
10 #include <string>
12 #include "base/basictypes.h"
13 #include "base/callback_forward.h"
14 #include "base/containers/hash_tables.h"
15 #include "base/files/file_path.h"
16 #include "base/files/file_path_watcher.h"
17 #include "base/memory/weak_ptr.h"
18 #include "chrome/browser/media_galleries/fileapi/iapps_data_provider.h"
19 #include "chrome/browser/media_galleries/fileapi/safe_iapps_library_parser.h"
20 #include "chrome/common/media_galleries/iphoto_library.h"
22 namespace iphoto {
24 // This class is the holder for iPhoto parsed data. Given a path to the iPhoto
25 // library XML file it will read it in, parse the data, and provide convenient
26 // methods to access it. When the file changes, it will update the data.
27 // It is not thread safe, but can be run on any thread with IO access.
28 class IPhotoDataProvider : public iapps::IAppsDataProvider {
29 public:
30 explicit IPhotoDataProvider(const base::FilePath& library_path);
31 ~IPhotoDataProvider() override;
33 // Parse the library xml file.
34 void DoParseLibrary(const base::FilePath& library_path,
35 const ReadyCallback& ready_callback) override;
37 virtual std::vector<std::string> GetAlbumNames() const;
38 virtual std::map<std::string, base::FilePath> GetAlbumContents(
39 const std::string& album) const;
40 virtual base::FilePath GetPhotoLocationInAlbum(
41 const std::string& album,
42 const std::string& filename) const;
44 virtual bool HasOriginals(const std::string& album) const;
45 virtual std::map<std::string, base::FilePath> GetOriginals(
46 const std::string& album) const;
47 virtual base::FilePath GetOriginalPhotoLocation(
48 const std::string& album,
49 const std::string& filename) const;
51 private:
52 typedef base::hash_map<std::string, base::FilePath> FileIndex;
53 // Map from album name to a map of filename to path.
54 typedef base::hash_map<std::string, FileIndex> DirIndex;
56 void OnLibraryParsed(const ReadyCallback& ready_callback,
57 bool result,
58 const parser::Library& library);
60 void BuildIndices(const parser::Library& library);
62 // Index for library data as it is presented in the virtual FS.
63 DirIndex dir_index_;
65 // Index for originals data.
66 DirIndex originals_index_;
68 scoped_refptr<iapps::SafeIAppsLibraryParser> xml_parser_;
70 base::WeakPtrFactory<IPhotoDataProvider> weak_factory_;
72 DISALLOW_COPY_AND_ASSIGN(IPhotoDataProvider);
75 } // namespace iphoto
77 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_IPHOTO_DATA_PROVIDER_H_