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 <sys/stat.h> | 9 #include <sys/stat.h> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 GDataFileBase* file)> | 64 GDataFileBase* file)> |
65 FindFileCallback; | 65 FindFileCallback; |
66 | 66 |
67 // Used to get files from the file system. | 67 // Used to get files from the file system. |
68 typedef base::Callback<void(base::PlatformFileError error, | 68 typedef base::Callback<void(base::PlatformFileError error, |
69 const FilePath& file_path, | 69 const FilePath& file_path, |
70 const std::string& mime_type, | 70 const std::string& mime_type, |
71 GDataFileType file_type)> | 71 GDataFileType file_type)> |
72 GetFileCallback; | 72 GetFileCallback; |
73 | 73 |
74 // Callback for SetMountedState. | |
75 typedef base::Callback<void(base::PlatformFileError error, | |
76 const FilePath& file_path)> | |
77 SetMountedStateCallback; | |
78 | |
74 // Used for file operations like removing files. | 79 // Used for file operations like removing files. |
75 typedef base::Callback<void(base::PlatformFileError error, | 80 typedef base::Callback<void(base::PlatformFileError error, |
76 base::ListValue* feed_list)> | 81 base::ListValue* feed_list)> |
77 GetJsonDocumentCallback; | 82 GetJsonDocumentCallback; |
78 | 83 |
79 // Used to get available space for the account from GData. | 84 // Used to get available space for the account from GData. |
80 typedef base::Callback<void(base::PlatformFileError error, | 85 typedef base::Callback<void(base::PlatformFileError error, |
81 int bytes_total, | 86 int bytes_total, |
82 int bytes_used)> | 87 int bytes_used)> |
83 GetAvailableSpaceCallback; | 88 GetAvailableSpaceCallback; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 virtual void Initialize() = 0; | 181 virtual void Initialize() = 0; |
177 | 182 |
178 // Adds and removes the observer. | 183 // Adds and removes the observer. |
179 virtual void AddObserver(Observer* observer) = 0; | 184 virtual void AddObserver(Observer* observer) = 0; |
180 virtual void RemoveObserver(Observer* observer) = 0; | 185 virtual void RemoveObserver(Observer* observer) = 0; |
181 | 186 |
182 // Enum defining origin of a cached file. | 187 // Enum defining origin of a cached file. |
183 enum CachedFileOrigin { | 188 enum CachedFileOrigin { |
184 CACHED_FILE_FROM_SERVER = 0, | 189 CACHED_FILE_FROM_SERVER = 0, |
185 CACHED_FILE_LOCALLY_MODIFIED, | 190 CACHED_FILE_LOCALLY_MODIFIED, |
191 CACHED_FILE_MOUNTED, | |
186 }; | 192 }; |
187 | 193 |
188 // Enum defining type of file operation e.g. copy or move, etc. | 194 // Enum defining type of file operation e.g. copy or move, etc. |
189 // For now, it's used for StoreToCache. | 195 // For now, it's used for StoreToCache. |
190 enum FileOperationType { | 196 enum FileOperationType { |
191 FILE_OPERATION_MOVE = 0, | 197 FILE_OPERATION_MOVE = 0, |
192 FILE_OPERATION_COPY, | 198 FILE_OPERATION_COPY, |
193 }; | 199 }; |
194 | 200 |
195 // Authenticates the user by fetching the auth token as | 201 // Authenticates the user by fetching the auth token as |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 // otherwise. | 355 // otherwise. |
350 virtual void GetCacheState(const std::string& resource_id, | 356 virtual void GetCacheState(const std::string& resource_id, |
351 const std::string& md5, | 357 const std::string& md5, |
352 const GetCacheStateCallback& callback) = 0; | 358 const GetCacheStateCallback& callback) = 0; |
353 | 359 |
354 // Finds file object by |file_path| and returns its key |properties|. | 360 // Finds file object by |file_path| and returns its key |properties|. |
355 // Returns true if file was found. | 361 // Returns true if file was found. |
356 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, | 362 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, |
357 GDataFileProperties* properties) = 0; | 363 GDataFileProperties* properties) = 0; |
358 | 364 |
365 // Returns true if the given path is under gdata cache directory, i.e. | |
366 // <user_profile_dir>/GCache/v1 | |
367 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0; | |
368 | |
359 // Returns the tmp sub-directory under gdata cache directory, i.e. | 369 // Returns the tmp sub-directory under gdata cache directory, i.e. |
360 // <user_profile_dir>/GCache/v1/tmp | 370 // <user_profile_dir>/GCache/v1/tmp |
361 virtual FilePath GetGDataCacheTmpDirectory() const = 0; | 371 virtual FilePath GetGDataCacheTmpDirectory() const = 0; |
362 | 372 |
363 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. | 373 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. |
364 // <user_profile_dir>/GCache/v1/tmp/downloads/ | 374 // <user_profile_dir>/GCache/v1/tmp/downloads/ |
365 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; | 375 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; |
366 | 376 |
367 // Returns the tmp documents sub-directory under gdata cache directory, i.e. | 377 // Returns the tmp documents sub-directory under gdata cache directory, i.e. |
368 // <user_profile_dir>/GCache/v1/tmp/documents/ | 378 // <user_profile_dir>/GCache/v1/tmp/documents/ |
(...skipping 15 matching lines...) Expand all Loading... | |
384 CachedFileOrigin file_orign) const = 0; | 394 CachedFileOrigin file_orign) const = 0; |
385 | 395 |
386 // Fetches the user's Account Metadata to find out current quota information | 396 // Fetches the user's Account Metadata to find out current quota information |
387 // and returns it to the callback. | 397 // and returns it to the callback. |
388 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; | 398 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; |
389 | 399 |
390 // Pin or unpin file. | 400 // Pin or unpin file. |
391 virtual void SetPinState(const FilePath& file_path, bool to_pin, | 401 virtual void SetPinState(const FilePath& file_path, bool to_pin, |
392 const FileOperationCallback& callback) = 0; | 402 const FileOperationCallback& callback) = 0; |
393 | 403 |
404 // Mark or unmark a file as locally mounted. | |
405 // When marked as mounted, the file is prevented from being modified | |
406 // or evicted from cache. | |
kuan
2012/04/18 00:43:50
marking it as mounted doesn't automatically preven
| |
407 virtual void SetMountedState(const FilePath& file_path, bool to_mount, | |
408 const SetMountedStateCallback& callback) = 0; | |
409 | |
394 // Creates a new file from |entry| under |virtual_dir_path|. Stored its | 410 // Creates a new file from |entry| under |virtual_dir_path|. Stored its |
395 // content from |file_content_path| into the cache. | 411 // content from |file_content_path| into the cache. |
396 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 412 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
397 DocumentEntry* entry, | 413 DocumentEntry* entry, |
398 const FilePath& file_content_path, | 414 const FilePath& file_content_path, |
399 FileOperationType cache_operation) = 0; | 415 FileOperationType cache_operation) = 0; |
400 | 416 |
401 // Returns true if hosted documents should be hidden. | 417 // Returns true if hosted documents should be hidden. |
402 virtual bool hide_hosted_documents() = 0; | 418 virtual bool hide_hosted_documents() = 0; |
403 }; | 419 }; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 virtual bool CancelOperation(const FilePath& file_path) OVERRIDE; | 466 virtual bool CancelOperation(const FilePath& file_path) OVERRIDE; |
451 virtual void AddOperationObserver( | 467 virtual void AddOperationObserver( |
452 GDataOperationRegistry::Observer* observer) OVERRIDE; | 468 GDataOperationRegistry::Observer* observer) OVERRIDE; |
453 virtual void RemoveOperationObserver( | 469 virtual void RemoveOperationObserver( |
454 GDataOperationRegistry::Observer* observer) OVERRIDE; | 470 GDataOperationRegistry::Observer* observer) OVERRIDE; |
455 virtual void GetCacheState(const std::string& resource_id, | 471 virtual void GetCacheState(const std::string& resource_id, |
456 const std::string& md5, | 472 const std::string& md5, |
457 const GetCacheStateCallback& callback) OVERRIDE; | 473 const GetCacheStateCallback& callback) OVERRIDE; |
458 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, | 474 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, |
459 GDataFileProperties* properties) OVERRIDE; | 475 GDataFileProperties* properties) OVERRIDE; |
476 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE; | |
460 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; | 477 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; |
461 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; | 478 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; |
462 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; | 479 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; |
463 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; | 480 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; |
464 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; | 481 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; |
465 virtual FilePath GetCacheFilePath( | 482 virtual FilePath GetCacheFilePath( |
466 const std::string& resource_id, | 483 const std::string& resource_id, |
467 const std::string& md5, | 484 const std::string& md5, |
468 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, | 485 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, |
469 CachedFileOrigin file_orign) const OVERRIDE; | 486 CachedFileOrigin file_orign) const OVERRIDE; |
470 virtual void GetAvailableSpace( | 487 virtual void GetAvailableSpace( |
471 const GetAvailableSpaceCallback& callback) OVERRIDE; | 488 const GetAvailableSpaceCallback& callback) OVERRIDE; |
472 // Calls private Pin or Unpin methods with |callback|. | 489 // Calls private Pin or Unpin methods with |callback|. |
473 virtual void SetPinState(const FilePath& file_path, bool pin, | 490 virtual void SetPinState(const FilePath& file_path, bool pin, |
474 const FileOperationCallback& callback) OVERRIDE; | 491 const FileOperationCallback& callback) OVERRIDE; |
492 virtual void SetMountedState( | |
493 const FilePath& file_path, bool to_mount, | |
494 const SetMountedStateCallback& callback) OVERRIDE; | |
kuan
2012/04/18 00:36:36
nit: either align all parameters after (, or 4-spa
| |
475 virtual void AddUploadedFile(const FilePath& virtual_dir_path, | 495 virtual void AddUploadedFile(const FilePath& virtual_dir_path, |
476 DocumentEntry* entry, | 496 DocumentEntry* entry, |
477 const FilePath& file_content_path, | 497 const FilePath& file_content_path, |
478 FileOperationType cache_operation) OVERRIDE; | 498 FileOperationType cache_operation) OVERRIDE; |
479 virtual bool hide_hosted_documents() OVERRIDE; | 499 virtual bool hide_hosted_documents() OVERRIDE; |
480 | 500 |
481 // content::NotificationObserver implementation. | 501 // content::NotificationObserver implementation. |
482 virtual void Observe(int type, | 502 virtual void Observe(int type, |
483 const content::NotificationSource& source, | 503 const content::NotificationSource& source, |
484 const content::NotificationDetails& details) OVERRIDE; | 504 const content::NotificationDetails& details) OVERRIDE; |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1374 }; | 1394 }; |
1375 | 1395 |
1376 // Sets the free disk space getter for testing. | 1396 // Sets the free disk space getter for testing. |
1377 // The existing getter is deleted. | 1397 // The existing getter is deleted. |
1378 void SetFreeDiskSpaceGetterForTesting( | 1398 void SetFreeDiskSpaceGetterForTesting( |
1379 FreeDiskSpaceGetterInterface* getter); | 1399 FreeDiskSpaceGetterInterface* getter); |
1380 | 1400 |
1381 } // namespace gdata | 1401 } // namespace gdata |
1382 | 1402 |
1383 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 1403 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |