OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_DATA_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_DATA_PROVIDER_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_DATA_PROVIDER_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_DATA_PROVIDER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/files/file.h" | 14 #include "base/files/file.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/files/file_path_watcher.h" | 16 #include "base/files/file_path_watcher.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "chrome/browser/media_galleries/fileapi/file_path_watcher_util.h" |
21 #include "chrome/common/media_galleries/picasa_types.h" | 22 #include "chrome/common/media_galleries/picasa_types.h" |
22 | 23 |
23 namespace picasa { | 24 namespace picasa { |
24 | 25 |
25 class SafePicasaAlbumTableReader; | 26 class SafePicasaAlbumTableReader; |
26 class SafePicasaAlbumsIndexer; | 27 class SafePicasaAlbumsIndexer; |
27 | 28 |
28 // Created and owned by ImportedMediaGalleryRegistryTaskRunnerValues | 29 // Created and owned by ImportedMediaGalleryRegistryTaskRunnerValues |
29 class PicasaDataProvider { | 30 class PicasaDataProvider { |
30 public: | 31 public: |
(...skipping 29 matching lines...) Expand all Loading... |
60 INVALID_DATA_STATE, | 61 INVALID_DATA_STATE, |
61 LIST_OF_ALBUMS_AND_FOLDERS_FRESH_STATE, | 62 LIST_OF_ALBUMS_AND_FOLDERS_FRESH_STATE, |
62 ALBUMS_IMAGES_FRESH_STATE | 63 ALBUMS_IMAGES_FRESH_STATE |
63 }; | 64 }; |
64 | 65 |
65 friend class PicasaFileUtilTest; | 66 friend class PicasaFileUtilTest; |
66 friend class TestPicasaDataProvider; | 67 friend class TestPicasaDataProvider; |
67 | 68 |
68 // Called when the FilePathWatcher for Picasa's temp directory has started. | 69 // Called when the FilePathWatcher for Picasa's temp directory has started. |
69 virtual void OnTempDirWatchStarted( | 70 virtual void OnTempDirWatchStarted( |
70 std::unique_ptr<base::FilePathWatcher> temp_dir_watcher); | 71 MediaFilePathWatcherUniquePtr temp_dir_watcher); |
71 | 72 |
72 // Called when Picasa's temp directory has changed. Virtual for testing. | 73 // Called when Picasa's temp directory has changed. Virtual for testing. |
73 virtual void OnTempDirChanged(const base::FilePath& temp_dir_path, | 74 virtual void OnTempDirChanged(const base::FilePath& temp_dir_path, |
74 bool error); | 75 bool error); |
75 | 76 |
76 // Kicks off utility processes needed to fulfill any pending callbacks. | 77 // Kicks off utility processes needed to fulfill any pending callbacks. |
77 void DoRefreshIfNecessary(); | 78 void DoRefreshIfNecessary(); |
78 | 79 |
79 void OnAlbumTableReaderDone(scoped_refptr<SafePicasaAlbumTableReader> reader, | 80 void OnAlbumTableReaderDone(scoped_refptr<SafePicasaAlbumTableReader> reader, |
80 bool parse_success, | 81 bool parse_success, |
(...skipping 21 matching lines...) Expand all Loading... |
102 std::vector<ReadyCallback> albums_index_ready_callbacks_; | 103 std::vector<ReadyCallback> albums_index_ready_callbacks_; |
103 | 104 |
104 // Stores the "live" in-flight utility processes. Callbacks from other | 105 // Stores the "live" in-flight utility processes. Callbacks from other |
105 // (older) utility processes are stale and ignored. Only one of these at a | 106 // (older) utility processes are stale and ignored. Only one of these at a |
106 // time should be non-NULL. | 107 // time should be non-NULL. |
107 scoped_refptr<SafePicasaAlbumTableReader> album_table_reader_; | 108 scoped_refptr<SafePicasaAlbumTableReader> album_table_reader_; |
108 scoped_refptr<SafePicasaAlbumsIndexer> albums_indexer_; | 109 scoped_refptr<SafePicasaAlbumsIndexer> albums_indexer_; |
109 | 110 |
110 // We watch the temp dir, as we can't detect database file modifications on | 111 // We watch the temp dir, as we can't detect database file modifications on |
111 // Mac, but we are able to detect creation and deletion of temporary files. | 112 // Mac, but we are able to detect creation and deletion of temporary files. |
112 std::unique_ptr<base::FilePathWatcher> temp_dir_watcher_; | 113 MediaFilePathWatcherUniquePtr temp_dir_watcher_; |
113 | 114 |
114 base::WeakPtrFactory<PicasaDataProvider> weak_factory_; | 115 base::WeakPtrFactory<PicasaDataProvider> weak_factory_; |
115 | 116 |
116 DISALLOW_COPY_AND_ASSIGN(PicasaDataProvider); | 117 DISALLOW_COPY_AND_ASSIGN(PicasaDataProvider); |
117 }; | 118 }; |
118 | 119 |
119 } // namespace picasa | 120 } // namespace picasa |
120 | 121 |
121 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_DATA_PROVIDER_H_ | 122 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_PICASA_DATA_PROVIDER_H_ |
OLD | NEW |