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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_cache.h

Issue 10823125: Drive: add a method to clear all local cache. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: review fix (comment #12) 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CHROMEOS_GDATA_GDATA_CACHE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 12 matching lines...) Expand all
23 23
24 class SequencedTaskRunner; 24 class SequencedTaskRunner;
25 25
26 } // namespace base 26 } // namespace base
27 27
28 namespace gdata { 28 namespace gdata {
29 29
30 class GDataCacheEntry; 30 class GDataCacheEntry;
31 class GDataCacheMetadata; 31 class GDataCacheMetadata;
32 32
33 // Callback for SetMountedStateOnUIThread. 33 // Callback for SetMountedStateOnUIThread and ClearAllOnUIThread.
34 typedef base::Callback<void(GDataFileError error, 34 typedef base::Callback<void(GDataFileError error,
35 const FilePath& file_path)> SetMountedStateCallback; 35 const FilePath& file_path)>
36 ChangeCacheStateCallback;
36 37
37 // Callback for completion of cache operation. 38 // Callback for completion of cache operation.
38 typedef base::Callback<void(GDataFileError error, 39 typedef base::Callback<void(GDataFileError error,
39 const std::string& resource_id, 40 const std::string& resource_id,
40 const std::string& md5)> CacheOperationCallback; 41 const std::string& md5)> CacheOperationCallback;
41 42
42 // Callback for GetFileFromCache. 43 // Callback for GetFileFromCache.
43 typedef base::Callback<void(GDataFileError error, 44 typedef base::Callback<void(GDataFileError error,
44 const std::string& resource_id, 45 const std::string& resource_id,
45 const std::string& md5, 46 const std::string& md5,
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 223
223 // Modifies cache state, which involves the following: 224 // Modifies cache state, which involves the following:
224 // - moves |source_path| to |dest_path|, where 225 // - moves |source_path| to |dest_path|, where
225 // if we're mounting: |source_path| is the unmounted path and has .<md5> 226 // if we're mounting: |source_path| is the unmounted path and has .<md5>
226 // extension, and |dest_path| is the mounted path in persistent dir 227 // extension, and |dest_path| is the mounted path in persistent dir
227 // and has .<md5>.mounted extension; 228 // and has .<md5>.mounted extension;
228 // if we're unmounting: the opposite is true for the two paths, i.e. 229 // if we're unmounting: the opposite is true for the two paths, i.e.
229 // |dest_path| is the mounted path and |source_path| the unmounted path. 230 // |dest_path| is the mounted path and |source_path| the unmounted path.
230 void SetMountedStateOnUIThread(const FilePath& file_path, 231 void SetMountedStateOnUIThread(const FilePath& file_path,
231 bool to_mount, 232 bool to_mount,
232 const SetMountedStateCallback& callback); 233 const ChangeCacheStateCallback& callback);
233 234
234 // Modifies cache state, which involves the following: 235 // Modifies cache state, which involves the following:
235 // - moves |source_path| to |dest_path| in persistent dir, where 236 // - moves |source_path| to |dest_path| in persistent dir, where
236 // |source_path| has .<md5> extension and |dest_path| has .local extension 237 // |source_path| has .<md5> extension and |dest_path| has .local extension
237 // - if file is pinned, updates symlink in pinned dir to reference dirty file 238 // - if file is pinned, updates symlink in pinned dir to reference dirty file
238 void MarkDirtyOnUIThread(const std::string& resource_id, 239 void MarkDirtyOnUIThread(const std::string& resource_id,
239 const std::string& md5, 240 const std::string& md5,
240 const GetFileFromCacheCallback& callback); 241 const GetFileFromCacheCallback& callback);
241 242
242 // Modifies cache state, i.e. creates symlink in outgoing 243 // Modifies cache state, i.e. creates symlink in outgoing
(...skipping 13 matching lines...) Expand all
256 const std::string& md5, 257 const std::string& md5,
257 const CacheOperationCallback& callback); 258 const CacheOperationCallback& callback);
258 259
259 // Does the following: 260 // Does the following:
260 // - remove all delete stale cache versions corresponding to |resource_id| in 261 // - remove all delete stale cache versions corresponding to |resource_id| in
261 // persistent, tmp and pinned directories 262 // persistent, tmp and pinned directories
262 // - remove entry corresponding to |resource_id| from cache map. 263 // - remove entry corresponding to |resource_id| from cache map.
263 void RemoveOnUIThread(const std::string& resource_id, 264 void RemoveOnUIThread(const std::string& resource_id,
264 const CacheOperationCallback& callback); 265 const CacheOperationCallback& callback);
265 266
267 // Does the following:
268 // - remove all the files in the cache directory.
269 // - re-create the |metadata_| instance.
270 void ClearAllOnUIThread(const ChangeCacheStateCallback& callback);
271
266 // Utility method to call Initialize on UI thread. 272 // Utility method to call Initialize on UI thread.
267 void RequestInitializeOnUIThread(); 273 void RequestInitializeOnUIThread();
268 274
269 // Force a rescan of cache files, for testing. 275 // Force a rescan of cache files, for testing.
270 void ForceRescanOnUIThreadForTesting(); 276 void ForceRescanOnUIThreadForTesting();
271 277
272 // Gets the cache entry for file corresponding to |resource_id| and |md5| 278 // Gets the cache entry for file corresponding to |resource_id| and |md5|
273 // and returns true if entry exists in cache map. Otherwise, returns false. 279 // and returns true if entry exists in cache map. Otherwise, returns false.
274 // |md5| can be empty if only matching |resource_id| is desired, which may 280 // |md5| can be empty if only matching |resource_id| is desired, which may
275 // happen when looking for pinned entries where symlinks' filenames have no 281 // happen when looking for pinned entries where symlinks' filenames have no
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // Used to implement ClearDirtyOnUIThread. 395 // Used to implement ClearDirtyOnUIThread.
390 void ClearDirty(const std::string& resource_id, 396 void ClearDirty(const std::string& resource_id,
391 const std::string& md5, 397 const std::string& md5,
392 FileOperationType file_operation_type, 398 FileOperationType file_operation_type,
393 GDataFileError* error); 399 GDataFileError* error);
394 400
395 // Used to implement RemoveOnUIThread. 401 // Used to implement RemoveOnUIThread.
396 void Remove(const std::string& resource_id, 402 void Remove(const std::string& resource_id,
397 GDataFileError* error); 403 GDataFileError* error);
398 404
405 // Used to implement ClearAllUIThread.
406 void ClearAll(GDataFileError* error);
407
399 // Runs callback and notifies the observers when file is pinned. 408 // Runs callback and notifies the observers when file is pinned.
400 void OnPinned(GDataFileError* error, 409 void OnPinned(GDataFileError* error,
401 const std::string& resource_id, 410 const std::string& resource_id,
402 const std::string& md5, 411 const std::string& md5,
403 const CacheOperationCallback& callback); 412 const CacheOperationCallback& callback);
404 413
405 // Runs callback and notifies the observers when file is unpinned. 414 // Runs callback and notifies the observers when file is unpinned.
406 void OnUnpinned(GDataFileError* error, 415 void OnUnpinned(GDataFileError* error,
407 const std::string& resource_id, 416 const std::string& resource_id,
408 const std::string& md5, 417 const std::string& md5,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 }; 465 };
457 466
458 // Sets the free disk space getter for testing. 467 // Sets the free disk space getter for testing.
459 // The existing getter is deleted. 468 // The existing getter is deleted.
460 void SetFreeDiskSpaceGetterForTesting( 469 void SetFreeDiskSpaceGetterForTesting(
461 FreeDiskSpaceGetterInterface* getter); 470 FreeDiskSpaceGetterInterface* getter);
462 471
463 } // namespace gdata 472 } // namespace gdata
464 473
465 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_ 474 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_event_router.cc ('k') | chrome/browser/chromeos/gdata/gdata_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698