Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2323)

Unified Diff: chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h

Issue 23499006: Media Galleries API Picasa: Add file watch to invalidate database data on disk write. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h
diff --git a/chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h b/chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h
index 7170d646ae4eda21a931e4ac49c91136eb87c449..61b66b63bfaf9e24badef63d2d2fc4449e2e3916 100644
--- a/chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h
+++ b/chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h
@@ -10,8 +10,10 @@
#include <string>
#include <vector>
-#include "base/callback.h"
+#include "base/basictypes.h"
+#include "base/callback_forward.h"
#include "base/files/file_path.h"
+#include "base/files/file_path_watcher.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
@@ -38,8 +40,6 @@ class PicasaDataProvider {
// Ask the data provider to refresh the data if necessary. |ready_callback|
// will be called when the data is up to date.
- // TODO(tommycli): Investigate having the callback return a bool indicating
- // success or failure - and handling it intelligently in PicasaFileUtil.
void RefreshData(DataType needed_data, const ReadyCallback& ready_callback);
// These methods return scoped_ptrs because we want to return a copy that
@@ -50,6 +50,10 @@ class PicasaDataProvider {
scoped_ptr<AlbumImages> FindAlbumImages(const std::string& key,
base::PlatformFileError* error);
+ protected:
+ // Notifies data provider that any currently cached data is stale.
+ virtual void InvalidateData();
+
private:
enum State {
STALE_DATA_STATE,
@@ -59,12 +63,15 @@ class PicasaDataProvider {
};
friend class PicasaFileUtilTest;
- friend class PicasaDataProviderInvalidateSimpleTest;
- friend class PicasaDataProviderInvalidateInflightTableReaderTest;
- friend class PicasaDataProviderInvalidateInflightAlbumsIndexerTest;
+ friend class TestPicasaDataProvider;
- // Notifies data provider that any currently cached data is stale.
- void InvalidateData();
+ // Called when the FilePathWatcher for Picasa's temp directory has started.
+ void OnTempDirWatchStarted(
+ scoped_ptr<base::FilePathWatcher> temp_dir_watcher);
+
+ // Called when Picasa's temp directory has changed. Virtual for testing.
+ virtual void OnTempDirChanged(const base::FilePath& temp_dir_path,
+ bool error);
// Kicks off utility processes needed to fulfill any pending callbacks.
void DoRefreshIfNecessary();
@@ -82,11 +89,6 @@ class PicasaDataProvider {
static void UniquifyNames(const std::vector<AlbumInfo>& info_list,
AlbumMap* result_map);
- // Methods are used in the browser test to tweak internal data for testing.
- void SetDatabasePathForTesting(const base::FilePath& database_path);
- void SetAlbumMapsForTesting(const AlbumMap& album_map,
- const AlbumMap& folder_map);
-
AlbumMap album_map_;
AlbumMap folder_map_;
AlbumImagesMap albums_images_;
@@ -105,6 +107,10 @@ class PicasaDataProvider {
scoped_refptr<SafePicasaAlbumTableReader> album_table_reader_;
scoped_refptr<SafePicasaAlbumsIndexer> albums_indexer_;
+ // We watch the temp dir, as we can't detect database file modifications on
+ // Mac, but we are able to detect creation and deletion of temporary files.
+ scoped_ptr<base::FilePathWatcher> temp_dir_watcher_;
+
base::WeakPtrFactory<PicasaDataProvider> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(PicasaDataProvider);

Powered by Google App Engine
This is Rietveld 408576698