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

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

Issue 10116044: gdata: Support mounting archive files in GData cache. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: gdata: Support mounting archive files in GData cache. Created 8 years, 8 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_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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 GDataEntry* entry)> 69 GDataEntry* entry)>
70 FindEntryCallback; 70 FindEntryCallback;
71 71
72 // Used to get files from the file system. 72 // Used to get files from the file system.
73 typedef base::Callback<void(base::PlatformFileError error, 73 typedef base::Callback<void(base::PlatformFileError error,
74 const FilePath& file_path, 74 const FilePath& file_path,
75 const std::string& mime_type, 75 const std::string& mime_type,
76 GDataFileType file_type)> 76 GDataFileType file_type)>
77 GetFileCallback; 77 GetFileCallback;
78 78
79 // Callback for SetMountedState.
80 typedef base::Callback<void(base::PlatformFileError error,
81 const FilePath& file_path)>
82 SetMountedStateCallback;
83
79 // Used for file operations like removing files. 84 // Used for file operations like removing files.
80 typedef base::Callback<void(base::PlatformFileError error, 85 typedef base::Callback<void(base::PlatformFileError error,
81 base::ListValue* feed_list)> 86 base::ListValue* feed_list)>
82 GetJsonDocumentCallback; 87 GetJsonDocumentCallback;
83 88
84 // Used to get available space for the account from GData. 89 // Used to get available space for the account from GData.
85 typedef base::Callback<void(base::PlatformFileError error, 90 typedef base::Callback<void(base::PlatformFileError error,
86 int bytes_total, 91 int bytes_total,
87 int bytes_used)> 92 int bytes_used)>
88 GetAvailableSpaceCallback; 93 GetAvailableSpaceCallback;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 virtual void Initialize() = 0; 190 virtual void Initialize() = 0;
186 191
187 // Adds and removes the observer. 192 // Adds and removes the observer.
188 virtual void AddObserver(Observer* observer) = 0; 193 virtual void AddObserver(Observer* observer) = 0;
189 virtual void RemoveObserver(Observer* observer) = 0; 194 virtual void RemoveObserver(Observer* observer) = 0;
190 195
191 // Enum defining origin of a cached file. 196 // Enum defining origin of a cached file.
192 enum CachedFileOrigin { 197 enum CachedFileOrigin {
193 CACHED_FILE_FROM_SERVER = 0, 198 CACHED_FILE_FROM_SERVER = 0,
194 CACHED_FILE_LOCALLY_MODIFIED, 199 CACHED_FILE_LOCALLY_MODIFIED,
200 CACHED_FILE_MOUNTED,
195 }; 201 };
196 202
197 // Enum defining type of file operation e.g. copy or move, etc. 203 // Enum defining type of file operation e.g. copy or move, etc.
198 // For now, it's used for StoreToCache. 204 // For now, it's used for StoreToCache.
199 enum FileOperationType { 205 enum FileOperationType {
200 FILE_OPERATION_MOVE = 0, 206 FILE_OPERATION_MOVE = 0,
201 FILE_OPERATION_COPY, 207 FILE_OPERATION_COPY,
202 }; 208 };
203 209
204 // Authenticates the user by fetching the auth token as 210 // Authenticates the user by fetching the auth token as
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 // otherwise. 364 // otherwise.
359 virtual void GetCacheState(const std::string& resource_id, 365 virtual void GetCacheState(const std::string& resource_id,
360 const std::string& md5, 366 const std::string& md5,
361 const GetCacheStateCallback& callback) = 0; 367 const GetCacheStateCallback& callback) = 0;
362 368
363 // Finds file object by |file_path| and returns its key |properties|. 369 // Finds file object by |file_path| and returns its key |properties|.
364 // Returns true if file was found. 370 // Returns true if file was found.
365 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, 371 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path,
366 GDataFileProperties* properties) = 0; 372 GDataFileProperties* properties) = 0;
367 373
374 // Returns true if the given path is under gdata cache directory, i.e.
375 // <user_profile_dir>/GCache/v1
376 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const = 0;
377
368 // Returns the tmp sub-directory under gdata cache directory, i.e. 378 // Returns the tmp sub-directory under gdata cache directory, i.e.
369 // <user_profile_dir>/GCache/v1/tmp 379 // <user_profile_dir>/GCache/v1/tmp
370 virtual FilePath GetGDataCacheTmpDirectory() const = 0; 380 virtual FilePath GetGDataCacheTmpDirectory() const = 0;
371 381
372 // Returns the tmp downloads sub-directory under gdata cache directory, i.e. 382 // Returns the tmp downloads sub-directory under gdata cache directory, i.e.
373 // <user_profile_dir>/GCache/v1/tmp/downloads/ 383 // <user_profile_dir>/GCache/v1/tmp/downloads/
374 virtual FilePath GetGDataTempDownloadFolderPath() const = 0; 384 virtual FilePath GetGDataTempDownloadFolderPath() const = 0;
375 385
376 // Returns the tmp documents sub-directory under gdata cache directory, i.e. 386 // Returns the tmp documents sub-directory under gdata cache directory, i.e.
377 // <user_profile_dir>/GCache/v1/tmp/documents/ 387 // <user_profile_dir>/GCache/v1/tmp/documents/
(...skipping 15 matching lines...) Expand all
393 CachedFileOrigin file_orign) const = 0; 403 CachedFileOrigin file_orign) const = 0;
394 404
395 // Fetches the user's Account Metadata to find out current quota information 405 // Fetches the user's Account Metadata to find out current quota information
396 // and returns it to the callback. 406 // and returns it to the callback.
397 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; 407 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0;
398 408
399 // Pin or unpin file. 409 // Pin or unpin file.
400 virtual void SetPinState(const FilePath& file_path, bool to_pin, 410 virtual void SetPinState(const FilePath& file_path, bool to_pin,
401 const FileOperationCallback& callback) = 0; 411 const FileOperationCallback& callback) = 0;
402 412
413 // Marks or unmarks a file as locally mounted.
414 // When marked as mounted, the file is prevented from being modified
415 // or evicted from cache.
416 virtual void SetMountedState(const FilePath& file_path, bool to_mount,
417 const SetMountedStateCallback& callback) = 0;
418
403 // Creates a new file from |entry| under |virtual_dir_path|. Stored its 419 // Creates a new file from |entry| under |virtual_dir_path|. Stored its
404 // content from |file_content_path| into the cache. 420 // content from |file_content_path| into the cache.
405 virtual void AddUploadedFile(const FilePath& virtual_dir_path, 421 virtual void AddUploadedFile(const FilePath& virtual_dir_path,
406 DocumentEntry* entry, 422 DocumentEntry* entry,
407 const FilePath& file_content_path, 423 const FilePath& file_content_path,
408 FileOperationType cache_operation) = 0; 424 FileOperationType cache_operation) = 0;
409 425
410 // Returns true if hosted documents should be hidden. 426 // Returns true if hosted documents should be hidden.
411 virtual bool hide_hosted_documents() = 0; 427 virtual bool hide_hosted_documents() = 0;
412 }; 428 };
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 virtual bool CancelOperation(const FilePath& file_path) OVERRIDE; 475 virtual bool CancelOperation(const FilePath& file_path) OVERRIDE;
460 virtual void AddOperationObserver( 476 virtual void AddOperationObserver(
461 GDataOperationRegistry::Observer* observer) OVERRIDE; 477 GDataOperationRegistry::Observer* observer) OVERRIDE;
462 virtual void RemoveOperationObserver( 478 virtual void RemoveOperationObserver(
463 GDataOperationRegistry::Observer* observer) OVERRIDE; 479 GDataOperationRegistry::Observer* observer) OVERRIDE;
464 virtual void GetCacheState(const std::string& resource_id, 480 virtual void GetCacheState(const std::string& resource_id,
465 const std::string& md5, 481 const std::string& md5,
466 const GetCacheStateCallback& callback) OVERRIDE; 482 const GetCacheStateCallback& callback) OVERRIDE;
467 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path, 483 virtual bool GetFileInfoFromPath(const FilePath& gdata_file_path,
468 GDataFileProperties* properties) OVERRIDE; 484 GDataFileProperties* properties) OVERRIDE;
485 virtual bool IsUnderGDataCacheDirectory(const FilePath& path) const OVERRIDE;
469 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE; 486 virtual FilePath GetGDataCacheTmpDirectory() const OVERRIDE;
470 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE; 487 virtual FilePath GetGDataTempDownloadFolderPath() const OVERRIDE;
471 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE; 488 virtual FilePath GetGDataTempDocumentFolderPath() const OVERRIDE;
472 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE; 489 virtual FilePath GetGDataCachePinnedDirectory() const OVERRIDE;
473 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE; 490 virtual FilePath GetGDataCachePersistentDirectory() const OVERRIDE;
474 virtual FilePath GetCacheFilePath( 491 virtual FilePath GetCacheFilePath(
475 const std::string& resource_id, 492 const std::string& resource_id,
476 const std::string& md5, 493 const std::string& md5,
477 GDataRootDirectory::CacheSubDirectoryType sub_dir_type, 494 GDataRootDirectory::CacheSubDirectoryType sub_dir_type,
478 CachedFileOrigin file_orign) const OVERRIDE; 495 CachedFileOrigin file_orign) const OVERRIDE;
479 virtual void GetAvailableSpace( 496 virtual void GetAvailableSpace(
480 const GetAvailableSpaceCallback& callback) OVERRIDE; 497 const GetAvailableSpaceCallback& callback) OVERRIDE;
481 // Calls private Pin or Unpin methods with |callback|. 498 // Calls private Pin or Unpin methods with |callback|.
482 virtual void SetPinState(const FilePath& file_path, bool pin, 499 virtual void SetPinState(const FilePath& file_path, bool pin,
483 const FileOperationCallback& callback) OVERRIDE; 500 const FileOperationCallback& callback) OVERRIDE;
501 virtual void SetMountedState(
502 const FilePath& file_path,
503 bool to_mount,
504 const SetMountedStateCallback& callback) OVERRIDE;
484 virtual void AddUploadedFile(const FilePath& virtual_dir_path, 505 virtual void AddUploadedFile(const FilePath& virtual_dir_path,
485 DocumentEntry* entry, 506 DocumentEntry* entry,
486 const FilePath& file_content_path, 507 const FilePath& file_content_path,
487 FileOperationType cache_operation) OVERRIDE; 508 FileOperationType cache_operation) OVERRIDE;
488 virtual bool hide_hosted_documents() OVERRIDE; 509 virtual bool hide_hosted_documents() OVERRIDE;
489 510
490 // content::NotificationObserver implementation. 511 // content::NotificationObserver implementation.
491 virtual void Observe(int type, 512 virtual void Observe(int type,
492 const content::NotificationSource& source, 513 const content::NotificationSource& source,
493 const content::NotificationDetails& details) OVERRIDE; 514 const content::NotificationDetails& details) OVERRIDE;
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 // Task posted from Unpin to modify cache state on the IO thread pool, which 1202 // Task posted from Unpin to modify cache state on the IO thread pool, which
1182 // involves the following: 1203 // involves the following:
1183 // - moves |source_path| to |dest_path| in tmp dir if file is 1204 // - moves |source_path| to |dest_path| in tmp dir if file is
1184 // not dirty 1205 // not dirty
1185 // - deletes symlink from pinned dir 1206 // - deletes symlink from pinned dir
1186 void UnpinOnIOThreadPool(const std::string& resource_id, 1207 void UnpinOnIOThreadPool(const std::string& resource_id,
1187 const std::string& md5, 1208 const std::string& md5,
1188 FileOperationType file_operation_type, 1209 FileOperationType file_operation_type,
1189 base::PlatformFileError* error); 1210 base::PlatformFileError* error);
1190 1211
1212 // Task posted from SetMountedState to modify cache state on the IO thread
1213 // pool, which involves the following:
1214 // - moves |source_path| to |dest_path|
tbarzic 2012/04/23 18:03:22 what are |source_path| and |dest_path|?
hshi 2012/04/23 19:01:09 In the case we're mounting, the |source_path| is t
hshi 2012/04/23 20:45:47 Done.
1215 void SetMountedStateOnIOThreadPool(const FilePath& file_path,
1216 bool to_mount,
1217 base::PlatformFileError* error,
1218 FilePath* cache_file_path);
1219
1191 // Task posted from MarkDirtyInCache to modify cache state on the IO thread 1220 // Task posted from MarkDirtyInCache to modify cache state on the IO thread
1192 // pool, which involves the following: 1221 // pool, which involves the following:
1193 // - moves |source_path| to |dest_path| in persistent dir, where 1222 // - moves |source_path| to |dest_path| in persistent dir, where
1194 // |source_path| has .<md5> extension and |dest_path| has .local extension 1223 // |source_path| has .<md5> extension and |dest_path| has .local extension
1195 // - if file is pinned, updates symlink in pinned dir to reference dirty file 1224 // - if file is pinned, updates symlink in pinned dir to reference dirty file
1196 void MarkDirtyInCacheOnIOThreadPool(const std::string& resource_id, 1225 void MarkDirtyInCacheOnIOThreadPool(const std::string& resource_id,
1197 const std::string& md5, 1226 const std::string& md5,
1198 FileOperationType file_operation_type, 1227 FileOperationType file_operation_type,
1199 base::PlatformFileError* error, 1228 base::PlatformFileError* error,
1200 FilePath* cache_file_path); 1229 FilePath* cache_file_path);
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 }; 1412 };
1384 1413
1385 // Sets the free disk space getter for testing. 1414 // Sets the free disk space getter for testing.
1386 // The existing getter is deleted. 1415 // The existing getter is deleted.
1387 void SetFreeDiskSpaceGetterForTesting( 1416 void SetFreeDiskSpaceGetterForTesting(
1388 FreeDiskSpaceGetterInterface* getter); 1417 FreeDiskSpaceGetterInterface* getter);
1389 1418
1390 } // namespace gdata 1419 } // namespace gdata
1391 1420
1392 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 1421 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_file_system.cc » ('j') | chrome/browser/chromeos/gdata/gdata_file_system.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698