Chromium Code Reviews| 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_GDATA_GDATA_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 virtual void RequestDirectoryRefresh(const FilePath& file_path) = 0; | 370 virtual void RequestDirectoryRefresh(const FilePath& file_path) = 0; |
| 371 | 371 |
| 372 // Does server side content search for |search_query|. Search results will be | 372 // Does server side content search for |search_query|. Search results will be |
| 373 // returned as gdata entries in temp directory proto, and their | 373 // returned as gdata entries in temp directory proto, and their |
| 374 // title/file_name will be formatted as |<resource_id>.<original_file_name>|. | 374 // title/file_name will be formatted as |<resource_id>.<original_file_name>|. |
| 375 // | 375 // |
| 376 // Can be called from UI/IO thread. |callback| is run on the calling thread. | 376 // Can be called from UI/IO thread. |callback| is run on the calling thread. |
| 377 virtual void SearchAsync(const std::string& search_query, | 377 virtual void SearchAsync(const std::string& search_query, |
| 378 const ReadDirectoryCallback& callback) = 0; | 378 const ReadDirectoryCallback& callback) = 0; |
| 379 | 379 |
| 380 // Returns true if the given path is under gdata cache directory, i.e. | |
| 381 // <user_profile_dir>/GCache/v1 | |
| 382 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; | |
| 383 | |
| 384 // Returns the sub-directory under gdata cache directory for the given sub | |
| 385 // directory type. Example: <user_profile_dir>/GCache/v1/tmp | |
| 386 virtual FilePath GetCacheDirectoryPath( | |
| 387 GDataCache::CacheSubDirectoryType sub_dir_type) const = 0; | |
| 388 | |
| 389 // Returns absolute path of the file if it were cached or to be cached. | |
| 390 virtual FilePath GetCacheFilePath( | |
| 391 const std::string& resource_id, | |
| 392 const std::string& md5, | |
| 393 GDataCache::CacheSubDirectoryType sub_dir_type, | |
| 394 GDataCache::CachedFileOrigin file_orign) const = 0; | |
| 395 | |
| 396 // Fetches the user's Account Metadata to find out current quota information | 380 // Fetches the user's Account Metadata to find out current quota information |
| 397 // and returns it to the callback. | 381 // and returns it to the callback. |
| 398 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; | 382 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; |
| 399 | 383 |
| 400 // Pin or unpin file. | 384 // Pin or unpin file. |
| 401 virtual void SetPinState(const FilePath& file_path, bool to_pin, | 385 virtual void SetPinState(const FilePath& file_path, bool to_pin, |
| 402 const FileOperationCallback& callback) = 0; | 386 const FileOperationCallback& callback) = 0; |
| 403 | 387 |
| 404 // Marks or unmarks a file as locally mounted. | 388 // Marks or unmarks a file as locally mounted. |
| 405 // When marked as mounted, the file is prevented from being modified | 389 // When marked as mounted, the file is prevented from being modified |
| 406 // or evicted from cache. | 390 // or evicted from cache. |
| 407 virtual void SetMountedState(const FilePath& file_path, bool to_mount, | 391 virtual void SetMountedState(const FilePath& file_path, bool to_mount, |
| 408 const SetMountedStateCallback& callback) = 0; | 392 const SetMountedStateCallback& callback) = 0; |
| 409 | 393 |
| 410 // Creates a new file from |entry| under |virtual_dir_path|. Stored its | 394 // Creates a new file from |entry| under |virtual_dir_path|. Stored its |
| 411 // content from |file_content_path| into the cache. | 395 // content from |file_content_path| into the cache. |
| 412 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 396 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
| 413 DocumentEntry* entry, | 397 DocumentEntry* entry, |
| 414 const FilePath& file_content_path, | 398 const FilePath& file_content_path, |
| 415 FileOperationType cache_operation) = 0; | 399 FileOperationType cache_operation) = 0; |
| 416 | 400 |
| 417 // Returns true if hosted documents should be hidden. | 401 // Returns true if hosted documents should be hidden. |
| 418 virtual bool hide_hosted_documents() = 0; | 402 virtual bool hide_hosted_documents() = 0; |
| 419 }; | 403 }; |
| 420 | 404 |
| 421 // The production implementation of GDataFileSystemInterface. | 405 // The production implementation of GDataFileSystemInterface. |
| 422 class GDataFileSystem : public GDataFileSystemInterface, | 406 class GDataFileSystem : public GDataFileSystemInterface, |
| 423 public content::NotificationObserver { | 407 public content::NotificationObserver { |
| 424 public: | 408 public: |
| 425 GDataFileSystem(Profile* profile, | 409 GDataFileSystem( |
| 426 DocumentsServiceInterface* documents_service); | 410 Profile* profile, |
| 411 GDataCache* cache, | |
|
achuithb
2012/06/11 21:58:10
Why not pass in GDataSystemService* instead of GDa
hashimoto
2012/06/12 06:20:12
See my comment in gdata_sync_client.h
| |
| 412 DocumentsServiceInterface* documents_service, | |
| 413 const base::SequencedWorkerPool::SequenceToken& sequence_token); | |
| 427 virtual ~GDataFileSystem(); | 414 virtual ~GDataFileSystem(); |
| 428 | 415 |
| 429 // GDataFileSystem overrides. | 416 // GDataFileSystem overrides. |
| 430 virtual void Initialize() OVERRIDE; | 417 virtual void Initialize() OVERRIDE; |
| 431 virtual void AddObserver(Observer* observer) OVERRIDE; | 418 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 432 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 419 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 433 virtual void StartUpdates() OVERRIDE; | 420 virtual void StartUpdates() OVERRIDE; |
| 434 virtual void StopUpdates() OVERRIDE; | 421 virtual void StopUpdates() OVERRIDE; |
| 435 virtual void CheckForUpdates() OVERRIDE; | 422 virtual void CheckForUpdates() OVERRIDE; |
| 436 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; | 423 virtual void Authenticate(const AuthStatusCallback& callback) OVERRIDE; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 const FilePath& file_path, | 466 const FilePath& file_path, |
| 480 const GetEntryInfoCallback& callback) OVERRIDE; | 467 const GetEntryInfoCallback& callback) OVERRIDE; |
| 481 virtual void GetFileInfoByPathAsync( | 468 virtual void GetFileInfoByPathAsync( |
| 482 const FilePath& file_path, | 469 const FilePath& file_path, |
| 483 const GetFileInfoCallback& callback) OVERRIDE; | 470 const GetFileInfoCallback& callback) OVERRIDE; |
| 484 virtual void ReadDirectoryByPathAsync( | 471 virtual void ReadDirectoryByPathAsync( |
| 485 const FilePath& file_path, | 472 const FilePath& file_path, |
| 486 const ReadDirectoryCallback& callback) OVERRIDE; | 473 const ReadDirectoryCallback& callback) OVERRIDE; |
| 487 virtual void RequestDirectoryRefresh( | 474 virtual void RequestDirectoryRefresh( |
| 488 const FilePath& file_path) OVERRIDE; | 475 const FilePath& file_path) OVERRIDE; |
| 489 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; | |
| 490 virtual FilePath GetCacheDirectoryPath( | |
| 491 GDataCache::CacheSubDirectoryType sub_dir_type) const OVERRIDE; | |
| 492 virtual FilePath GetCacheFilePath( | |
| 493 const std::string& resource_id, | |
| 494 const std::string& md5, | |
| 495 GDataCache::CacheSubDirectoryType sub_dir_type, | |
| 496 GDataCache::CachedFileOrigin file_orign) const OVERRIDE; | |
| 497 virtual void GetAvailableSpace( | 476 virtual void GetAvailableSpace( |
| 498 const GetAvailableSpaceCallback& callback) OVERRIDE; | 477 const GetAvailableSpaceCallback& callback) OVERRIDE; |
| 499 // Calls private Pin or Unpin methods with |callback|. | 478 // Calls private Pin or Unpin methods with |callback|. |
| 500 virtual void SetPinState(const FilePath& file_path, bool pin, | 479 virtual void SetPinState(const FilePath& file_path, bool pin, |
| 501 const FileOperationCallback& callback) OVERRIDE; | 480 const FileOperationCallback& callback) OVERRIDE; |
| 502 virtual void SetMountedState( | 481 virtual void SetMountedState( |
| 503 const FilePath& file_path, | 482 const FilePath& file_path, |
| 504 bool to_mount, | 483 bool to_mount, |
| 505 const SetMountedStateCallback& callback) OVERRIDE; | 484 const SetMountedStateCallback& callback) OVERRIDE; |
| 506 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 485 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1471 const GetCacheStateCallback& callback); | 1450 const GetCacheStateCallback& callback); |
| 1472 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); | 1451 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); |
| 1473 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, | 1452 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, |
| 1474 const FileOperationCallback& callback); | 1453 const FileOperationCallback& callback); |
| 1475 void SetMountedStateOnUIThread( | 1454 void SetMountedStateOnUIThread( |
| 1476 const FilePath& file_path, | 1455 const FilePath& file_path, |
| 1477 bool to_mount, | 1456 bool to_mount, |
| 1478 const SetMountedStateCallback& callback); | 1457 const SetMountedStateCallback& callback); |
| 1479 | 1458 |
| 1480 scoped_ptr<GDataRootDirectory> root_; | 1459 scoped_ptr<GDataRootDirectory> root_; |
| 1481 scoped_ptr<GDataCache> cache_; | |
| 1482 | 1460 |
| 1483 // This guards regular states. | 1461 // This guards regular states. |
| 1484 base::Lock lock_; | 1462 base::Lock lock_; |
| 1485 | 1463 |
| 1486 // The profile hosts the GDataFileSystem via GDataSystemService. | 1464 // The profile hosts the GDataFileSystem via GDataSystemService. |
| 1487 Profile* profile_; | 1465 Profile* profile_; |
| 1488 | 1466 |
| 1467 GDataCache* cache_; // Owned by GDataSystemService. | |
| 1468 | |
| 1489 // The document service for the GDataFileSystem. | 1469 // The document service for the GDataFileSystem. |
| 1490 DocumentsServiceInterface* documents_service_; | 1470 DocumentsServiceInterface* documents_service_; |
|
achuithb
2012/06/12 08:17:43
Can we also add a comment here that this is owned
hashimoto
2012/06/12 08:25:22
Done.
| |
| 1491 | 1471 |
| 1492 // Waitable events used to block destructor until all the tasks on blocking | 1472 // Waitable events used to block destructor until all the tasks on blocking |
| 1493 // pool are run. | 1473 // pool are run. |
| 1494 scoped_ptr<base::WaitableEvent> on_io_completed_; | 1474 scoped_ptr<base::WaitableEvent> on_io_completed_; |
| 1495 | 1475 |
| 1496 // True if cache initialization has started, is in progress or has completed, | 1476 // True if cache initialization has started, is in progress or has completed, |
| 1497 // we only want to initialize cache once. | 1477 // we only want to initialize cache once. |
| 1498 bool cache_initialization_started_; | 1478 bool cache_initialization_started_; |
| 1499 | 1479 |
| 1500 // Number of pending tasks on the blocking pool. | 1480 // Number of pending tasks on the blocking pool. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1535 }; | 1515 }; |
| 1536 | 1516 |
| 1537 // Sets the free disk space getter for testing. | 1517 // Sets the free disk space getter for testing. |
| 1538 // The existing getter is deleted. | 1518 // The existing getter is deleted. |
| 1539 void SetFreeDiskSpaceGetterForTesting( | 1519 void SetFreeDiskSpaceGetterForTesting( |
| 1540 FreeDiskSpaceGetterInterface* getter); | 1520 FreeDiskSpaceGetterInterface* getter); |
| 1541 | 1521 |
| 1542 } // namespace gdata | 1522 } // namespace gdata |
| 1543 | 1523 |
| 1544 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1524 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| OLD | NEW |