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

Unified Diff: chrome/browser/chromeos/gdata/stale_cache_files_remover.h

Issue 10832241: Drive: Removes unused cache files after the initial feed fetch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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/chromeos/gdata/stale_cache_files_remover.h
diff --git a/chrome/browser/chromeos/gdata/stale_cache_files_remover.h b/chrome/browser/chromeos/gdata/stale_cache_files_remover.h
new file mode 100644
index 0000000000000000000000000000000000000000..ea31af78c02c05df79d315c7223598a6b728e8e0
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/stale_cache_files_remover.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_GDATA_STALE_CACHE_FILE_REMOVER_H_
+#define CHROME_BROWSER_CHROMEOS_GDATA_STALE_CACHE_FILE_REMOVER_H_
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "chrome/browser/chromeos/gdata/drive_file_system_interface.h"
+
+namespace gdata{
+
+class DriveCache;
+class DriveFileSystem;
+
+// This class removes stale cache files, which are present locally, but no
+// longer present on the server. This can happen if files are removed from the
+// server from other devices, or from the web interface.
+class StaleCacheFilesRemover : public DriveFileSystemInterface::Observer {
+ public:
+ StaleCacheFilesRemover(DriveFileSystemInterface* file_system,
+ DriveCache* cache);
+ virtual ~StaleCacheFilesRemover();
+
+ private:
+ // Removes stale cache files.
+ // Gets the list of all the resource id and calls OnGetResourceIdsOfAllFiles()
+ // with the list.
+ virtual void OnInitialLoadFinished() OVERRIDE;
+
+ // Gets the cache entry of each resource id. And passes the cache entry to
+ // GetEntryInfoAndRemoveCacheIfNecessary().
+ void OnGetResourceIdsOfAllFiles(const std::vector<std::string>& resource_ids);
+
+ // Gets the file entry and calls RemoveCacheIfNecessary() with the file entry.
+ // This is called from StaleCacheFilesRemover::OnGetResourceIdsOfAllFiles().
+ void GetEntryInfoAndRemoveCacheIfNecessary(
+ const std::string& resource_id,
+ bool success,
+ const gdata::DriveCacheEntry& cache_entry);
+
+ // Check the cache file and removes if it is unavailable or invalid (eg. md5
+ // mismatch). This is called from GetCacheEntryAndRemoveCacheIfNecessary();
+ void RemoveCacheIfNecessary(
+ const std::string& resource_id,
+ const std::string& cache_md5,
+ DriveFileError error,
+ const FilePath& gdata_file_path,
+ scoped_ptr<gdata::DriveEntryProto> entry_proto);
+
+ DriveCache* cache_; // Not owned.
+ DriveFileSystemInterface* file_system_; // Not owned.
+
+ // Note: This should remain the last member so it'll be destroyed and
+ // invalidate its weak pointers before any other members are destroyed.
+ base::WeakPtrFactory<StaleCacheFilesRemover> weak_ptr_factory_;
+ DISALLOW_COPY_AND_ASSIGN(StaleCacheFilesRemover);
+};
+
+} // namespace gdata
+
+#endif // CHROME_BROWSER_CHROMEOS_GDATA_STALE_CACHE_FILE_REMOVER_H_

Powered by Google App Engine
This is Rietveld 408576698