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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 FileOperationType file_operation_type, | 191 FileOperationType file_operation_type, |
192 const FileOperationCallback& callback); | 192 const FileOperationCallback& callback); |
193 | 193 |
194 // Stores |source_path| as a cache of the remote content of the file | 194 // Stores |source_path| as a cache of the remote content of the file |
195 // with |resource_id| and |md5|. | 195 // with |resource_id| and |md5|. |
196 FileError Store(const std::string& resource_Id, | 196 FileError Store(const std::string& resource_Id, |
197 const std::string& md5, | 197 const std::string& md5, |
198 const base::FilePath& source_path, | 198 const base::FilePath& source_path, |
199 FileOperationType file_operation_type); | 199 FileOperationType file_operation_type); |
200 | 200 |
201 // Stores |source_path| to the cache and mark it as dirty, i.e., needs to be | |
202 // uploaded to the remove server for syncing. | |
203 // |callback| must not be null. | |
204 // Must be called on the UI thread. | |
205 void StoreLocallyModifiedOnUIThread(const std::string& resource_id, | |
206 const std::string& md5, | |
207 const base::FilePath& source_path, | |
208 FileOperationType file_operation_type, | |
209 const FileOperationCallback& callback); | |
210 | |
211 // Runs Pin() on |blocking_task_runner_|, and calls |callback| with the result | 201 // Runs Pin() on |blocking_task_runner_|, and calls |callback| with the result |
212 // asynchronously. | 202 // asynchronously. |
213 // |callback| must not be null. | 203 // |callback| must not be null. |
214 // Must be called on the UI thread. | 204 // Must be called on the UI thread. |
215 void PinOnUIThread(const std::string& resource_id, | 205 void PinOnUIThread(const std::string& resource_id, |
216 const std::string& md5, | 206 const std::string& md5, |
217 const FileOperationCallback& callback); | 207 const FileOperationCallback& callback); |
218 | 208 |
219 // Pins the specified entry. | 209 // Pins the specified entry. |
220 FileError Pin(const std::string& resource_id, | 210 FileError Pin(const std::string& resource_id, |
(...skipping 28 matching lines...) Expand all Loading... |
249 // |callback| must not be null. | 239 // |callback| must not be null. |
250 // Must be called on the UI thread. | 240 // Must be called on the UI thread. |
251 void MarkDirtyOnUIThread(const std::string& resource_id, | 241 void MarkDirtyOnUIThread(const std::string& resource_id, |
252 const std::string& md5, | 242 const std::string& md5, |
253 const FileOperationCallback& callback); | 243 const FileOperationCallback& callback); |
254 | 244 |
255 // Marks the specified entry dirty. | 245 // Marks the specified entry dirty. |
256 FileError MarkDirty(const std::string& resource_id, | 246 FileError MarkDirty(const std::string& resource_id, |
257 const std::string& md5); | 247 const std::string& md5); |
258 | 248 |
259 // Commits changes for the specified dirty entry. | |
260 // |callback| must not be null. | |
261 // Must be called on the UI thread. | |
262 void CommitDirtyOnUIThread(const std::string& resource_id, | |
263 const std::string& md5, | |
264 const FileOperationCallback& callback); | |
265 | |
266 // Clears dirty state of the specified entry. | 249 // Clears dirty state of the specified entry. |
267 FileError ClearDirty(const std::string& resource_id, | 250 FileError ClearDirty(const std::string& resource_id, |
268 const std::string& md5); | 251 const std::string& md5); |
269 | 252 |
270 // Runs Remove() on |blocking_task_runner_| and runs |callback| with the | 253 // Runs Remove() on |blocking_task_runner_| and runs |callback| with the |
271 // result. | 254 // result. |
272 // Must be called on the UI thread. | 255 // Must be called on the UI thread. |
273 void RemoveOnUIThread(const std::string& resource_id, | 256 void RemoveOnUIThread(const std::string& resource_id, |
274 const FileOperationCallback& callback); | 257 const FileOperationCallback& callback); |
275 | 258 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 324 |
342 // Destroys the cache on the blocking pool. | 325 // Destroys the cache on the blocking pool. |
343 void DestroyOnBlockingPool(); | 326 void DestroyOnBlockingPool(); |
344 | 327 |
345 // Used to implement Store and StoreLocallyModifiedOnUIThread. | 328 // Used to implement Store and StoreLocallyModifiedOnUIThread. |
346 // TODO(hidehiko): Merge this method with Store(), after | 329 // TODO(hidehiko): Merge this method with Store(), after |
347 // StoreLocallyModifiedOnUIThread is removed. | 330 // StoreLocallyModifiedOnUIThread is removed. |
348 FileError StoreInternal(const std::string& resource_id, | 331 FileError StoreInternal(const std::string& resource_id, |
349 const std::string& md5, | 332 const std::string& md5, |
350 const base::FilePath& source_path, | 333 const base::FilePath& source_path, |
351 FileOperationType file_operation_type, | 334 FileOperationType file_operation_type); |
352 CachedFileOrigin origin); | |
353 | 335 |
354 // Used to implement MarkAsMountedOnUIThread. | 336 // Used to implement MarkAsMountedOnUIThread. |
355 FileError MarkAsMounted(const std::string& resource_id, | 337 FileError MarkAsMounted(const std::string& resource_id, |
356 base::FilePath* cache_file_path); | 338 base::FilePath* cache_file_path); |
357 | 339 |
358 // Used to implement MarkAsUnmountedOnUIThread. | 340 // Used to implement MarkAsUnmountedOnUIThread. |
359 FileError MarkAsUnmounted(const base::FilePath& file_path); | 341 FileError MarkAsUnmounted(const base::FilePath& file_path); |
360 | 342 |
361 // Used to implement ClearAllOnUIThread. | 343 // Used to implement ClearAllOnUIThread. |
362 bool ClearAll(); | 344 bool ClearAll(); |
363 | 345 |
364 // Runs callback and notifies the observers when file is pinned. | 346 // Runs callback and notifies the observers when file is pinned. |
365 void OnPinned(const std::string& resource_id, | 347 void OnPinned(const std::string& resource_id, |
366 const std::string& md5, | 348 const std::string& md5, |
367 const FileOperationCallback& callback, | 349 const FileOperationCallback& callback, |
368 FileError error); | 350 FileError error); |
369 | 351 |
370 // Runs callback and notifies the observers when file is unpinned. | 352 // Runs callback and notifies the observers when file is unpinned. |
371 void OnUnpinned(const std::string& resource_id, | 353 void OnUnpinned(const std::string& resource_id, |
372 const std::string& md5, | 354 const std::string& md5, |
373 const FileOperationCallback& callback, | 355 const FileOperationCallback& callback, |
374 FileError error); | 356 FileError error); |
375 | 357 |
376 // Runs callback and notifies the observers when file is committed. | |
377 void OnCommitDirty(const std::string& resource_id, | |
378 const FileOperationCallback& callback, | |
379 FileError error); | |
380 | |
381 // Returns true if we have sufficient space to store the given number of | 358 // Returns true if we have sufficient space to store the given number of |
382 // bytes, while keeping kMinFreeSpace bytes on the disk. | 359 // bytes, while keeping kMinFreeSpace bytes on the disk. |
383 bool HasEnoughSpaceFor(int64 num_bytes, const base::FilePath& path); | 360 bool HasEnoughSpaceFor(int64 num_bytes, const base::FilePath& path); |
384 | 361 |
385 // The root directory of the cache (i.e. <user_profile_dir>/GCache/v1). | 362 // The root directory of the cache (i.e. <user_profile_dir>/GCache/v1). |
386 const base::FilePath cache_root_path_; | 363 const base::FilePath cache_root_path_; |
387 // Paths for all subdirectories of GCache, one for each | 364 // Paths for all subdirectories of GCache, one for each |
388 // FileCache::CacheSubDirectoryType enum. | 365 // FileCache::CacheSubDirectoryType enum. |
389 const std::vector<base::FilePath> cache_paths_; | 366 const std::vector<base::FilePath> cache_paths_; |
390 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 367 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
(...skipping 17 matching lines...) Expand all Loading... |
408 // this value. | 385 // this value. |
409 // | 386 // |
410 // Copied from cryptohome/homedirs.h. | 387 // Copied from cryptohome/homedirs.h. |
411 // TODO(satorux): Share the constant. | 388 // TODO(satorux): Share the constant. |
412 const int64 kMinFreeSpace = 512 * 1LL << 20; | 389 const int64 kMinFreeSpace = 512 * 1LL << 20; |
413 | 390 |
414 } // namespace internal | 391 } // namespace internal |
415 } // namespace drive | 392 } // namespace drive |
416 | 393 |
417 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ | 394 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_CACHE_H_ |
OLD | NEW |