OLD | NEW |
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_DRIVE_FILE_CACHE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // - re-create the |metadata_| instance. | 269 // - re-create the |metadata_| instance. |
270 // |callback| must not be null. | 270 // |callback| must not be null. |
271 // Must be called on the UI thread. | 271 // Must be called on the UI thread. |
272 void ClearAllOnUIThread(const InitializeCacheCallback& callback); | 272 void ClearAllOnUIThread(const InitializeCacheCallback& callback); |
273 | 273 |
274 // Utility method to call Initialize on UI thread. |callback| is called on | 274 // Utility method to call Initialize on UI thread. |callback| is called on |
275 // UI thread when the initialization is complete. | 275 // UI thread when the initialization is complete. |
276 // |callback| must not be null. | 276 // |callback| must not be null. |
277 void RequestInitialize(const InitializeCacheCallback& callback); | 277 void RequestInitialize(const InitializeCacheCallback& callback); |
278 | 278 |
279 // Utility method to call InitializeForTesting on UI thread. | |
280 void RequestInitializeForTesting(); | |
281 | |
282 // Destroys this cache. This function posts a task to the blocking task | 279 // Destroys this cache. This function posts a task to the blocking task |
283 // runner to safely delete the object. | 280 // runner to safely delete the object. |
284 // Must be called on the UI thread. | 281 // Must be called on the UI thread. |
285 void Destroy(); | 282 void Destroy(); |
286 | 283 |
287 // Returns file paths for all the cache sub directories under | 284 // Returns file paths for all the cache sub directories under |
288 // |cache_root_path|. | 285 // |cache_root_path|. |
289 static std::vector<base::FilePath> GetCachePaths( | 286 static std::vector<base::FilePath> GetCachePaths( |
290 const base::FilePath& cache_root_path); | 287 const base::FilePath& cache_root_path); |
291 | 288 |
(...skipping 29 matching lines...) Expand all Loading... |
321 CachedFileOrigin file_origin) const; | 318 CachedFileOrigin file_origin) const; |
322 | 319 |
323 | 320 |
324 // Checks whether the current thread is on the right sequenced worker pool | 321 // Checks whether the current thread is on the right sequenced worker pool |
325 // with the right sequence ID. If not, DCHECK will fail. | 322 // with the right sequence ID. If not, DCHECK will fail. |
326 void AssertOnSequencedWorkerPool(); | 323 void AssertOnSequencedWorkerPool(); |
327 | 324 |
328 // Initializes the cache. Returns true on success. | 325 // Initializes the cache. Returns true on success. |
329 bool InitializeOnBlockingPool(); | 326 bool InitializeOnBlockingPool(); |
330 | 327 |
331 // Initializes the cache with in-memory cache for testing. | |
332 // The in-memory cache is used since it's faster than the db. | |
333 void InitializeOnBlockingPoolForTesting(); | |
334 | |
335 // Destroys the cache on the blocking pool. | 328 // Destroys the cache on the blocking pool. |
336 void DestroyOnBlockingPool(); | 329 void DestroyOnBlockingPool(); |
337 | 330 |
338 // Used to implement Store and StoreLocallyModifiedOnUIThread. | 331 // Used to implement Store and StoreLocallyModifiedOnUIThread. |
339 // TODO(hidehiko): Merge this method with Store(), after | 332 // TODO(hidehiko): Merge this method with Store(), after |
340 // StoreLocallyModifiedOnUIThread is removed. | 333 // StoreLocallyModifiedOnUIThread is removed. |
341 FileError StoreInternal(const std::string& resource_id, | 334 FileError StoreInternal(const std::string& resource_id, |
342 const std::string& md5, | 335 const std::string& md5, |
343 const base::FilePath& source_path, | 336 const base::FilePath& source_path, |
344 FileOperationType file_operation_type, | 337 FileOperationType file_operation_type, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 // this value. | 403 // this value. |
411 // | 404 // |
412 // Copied from cryptohome/homedirs.h. | 405 // Copied from cryptohome/homedirs.h. |
413 // TODO(satorux): Share the constant. | 406 // TODO(satorux): Share the constant. |
414 const int64 kMinFreeSpace = 512 * 1LL << 20; | 407 const int64 kMinFreeSpace = 512 * 1LL << 20; |
415 | 408 |
416 } // namespace internal | 409 } // namespace internal |
417 } // namespace drive | 410 } // namespace drive |
418 | 411 |
419 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ | 412 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ |
OLD | NEW |