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

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

Issue 10540132: gdata: Convert GDataFileSystem::AddUploadFile() to asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comments to explain why Patch Set #11 is necesary. Created 8 years, 6 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 | Annotate | Revision Log
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 <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Fetches the user's Account Metadata to find out current quota information 366 // Fetches the user's Account Metadata to find out current quota information
367 // and returns it to the callback. 367 // and returns it to the callback.
368 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0; 368 virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0;
369 369
370 // Pin or unpin file. 370 // Pin or unpin file.
371 virtual void SetPinState(const FilePath& file_path, bool to_pin, 371 virtual void SetPinState(const FilePath& file_path, bool to_pin,
372 const FileOperationCallback& callback) = 0; 372 const FileOperationCallback& callback) = 0;
373 373
374 // Creates a new file from |entry| under |virtual_dir_path|. Stored its 374 // Creates a new file from |entry| under |virtual_dir_path|. Stored its
375 // content from |file_content_path| into the cache. 375 // content from |file_content_path| into the cache.
376 virtual void AddUploadedFile( 376 //
377 const FilePath& virtual_dir_path, 377 // |callback| will be called on the UI thread upon completion of operation.
378 DocumentEntry* entry, 378 virtual void AddUploadedFile(const FilePath& virtual_dir_path,
379 const FilePath& file_content_path, 379 DocumentEntry* entry,
380 GDataCache::FileOperationType cache_operation) = 0; 380 const FilePath& file_content_path,
381 GDataCache::FileOperationType cache_operation,
382 const base::Closure& callback) = 0;
381 }; 383 };
382 384
383 // The production implementation of GDataFileSystemInterface. 385 // The production implementation of GDataFileSystemInterface.
384 class GDataFileSystem : public GDataFileSystemInterface, 386 class GDataFileSystem : public GDataFileSystemInterface,
385 public content::NotificationObserver { 387 public content::NotificationObserver {
386 public: 388 public:
387 GDataFileSystem( 389 GDataFileSystem(
388 Profile* profile, 390 Profile* profile,
389 GDataCache* cache, 391 GDataCache* cache,
390 DocumentsServiceInterface* documents_service, 392 DocumentsServiceInterface* documents_service,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 virtual void ReadDirectoryByPathAsync( 452 virtual void ReadDirectoryByPathAsync(
451 const FilePath& file_path, 453 const FilePath& file_path,
452 const ReadDirectoryCallback& callback) OVERRIDE; 454 const ReadDirectoryCallback& callback) OVERRIDE;
453 virtual void RequestDirectoryRefresh( 455 virtual void RequestDirectoryRefresh(
454 const FilePath& file_path) OVERRIDE; 456 const FilePath& file_path) OVERRIDE;
455 virtual void GetAvailableSpace( 457 virtual void GetAvailableSpace(
456 const GetAvailableSpaceCallback& callback) OVERRIDE; 458 const GetAvailableSpaceCallback& callback) OVERRIDE;
457 // Calls private Pin or Unpin methods with |callback|. 459 // Calls private Pin or Unpin methods with |callback|.
458 virtual void SetPinState(const FilePath& file_path, bool pin, 460 virtual void SetPinState(const FilePath& file_path, bool pin,
459 const FileOperationCallback& callback) OVERRIDE; 461 const FileOperationCallback& callback) OVERRIDE;
460 virtual void AddUploadedFile( 462 virtual void AddUploadedFile(const FilePath& virtual_dir_path,
461 const FilePath& virtual_dir_path, 463 DocumentEntry* entry,
462 DocumentEntry* entry, 464 const FilePath& file_content_path,
463 const FilePath& file_content_path, 465 GDataCache::FileOperationType cache_operation,
464 GDataCache::FileOperationType cache_operation) OVERRIDE; 466 const base::Closure& callback) OVERRIDE;
465 467
466 // content::NotificationObserver implementation. 468 // content::NotificationObserver implementation.
467 virtual void Observe(int type, 469 virtual void Observe(int type,
468 const content::NotificationSource& source, 470 const content::NotificationSource& source,
469 const content::NotificationDetails& details) OVERRIDE; 471 const content::NotificationDetails& details) OVERRIDE;
470 472
471 // Used in tests to inject mock document service. 473 // Used in tests to inject mock document service.
472 void SetDocumentsServiceForTesting(DocumentsServiceInterface* 474 void SetDocumentsServiceForTesting(DocumentsServiceInterface*
473 new_document_service) { 475 new_document_service) {
474 documents_service_ = new_document_service; 476 documents_service_ = new_document_service;
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 // Notifies events to observers on UI thread. 1000 // Notifies events to observers on UI thread.
999 void NotifyDirectoryChanged(const FilePath& directory_path); 1001 void NotifyDirectoryChanged(const FilePath& directory_path);
1000 void NotifyInitialLoadFinished(); 1002 void NotifyInitialLoadFinished();
1001 void NotifyDocumentFeedFetched(int num_accumulated_entries); 1003 void NotifyDocumentFeedFetched(int num_accumulated_entries);
1002 1004
1003 // Helper function that completes bookkeeping tasks related to 1005 // Helper function that completes bookkeeping tasks related to
1004 // completed file transfer. 1006 // completed file transfer.
1005 void OnTransferCompleted( 1007 void OnTransferCompleted(
1006 const FileOperationCallback& callback, 1008 const FileOperationCallback& callback,
1007 base::PlatformFileError error, 1009 base::PlatformFileError error,
1008 UploadFileInfo* upload_file_info); 1010 scoped_ptr<UploadFileInfo> upload_file_info);
1009 1011
1010 // Kicks off file upload once it receives |upload_file_info|. 1012 // Kicks off file upload once it receives |upload_file_info|.
1011 void StartFileUploadOnUIThread( 1013 void StartFileUploadOnUIThread(
1012 const FileOperationCallback& callback, 1014 const FileOperationCallback& callback,
1013 base::PlatformFileError* error, 1015 base::PlatformFileError* error,
1014 UploadFileInfo* upload_file_info); 1016 UploadFileInfo* upload_file_info);
1015 1017
1016 // Cache intermediate callbacks, that run on calling thread, for above cache 1018 // Cache intermediate callbacks, that run on calling thread, for above cache
1017 // tasks that were run on blocking pool. 1019 // tasks that were run on blocking pool.
1018 1020
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 void RequestDirectoryRefreshOnUIThread( 1134 void RequestDirectoryRefreshOnUIThread(
1133 const FilePath& file_path); 1135 const FilePath& file_path);
1134 void OnRequestDirectoryRefresh(GetDocumentsParams* params, 1136 void OnRequestDirectoryRefresh(GetDocumentsParams* params,
1135 base::PlatformFileError error); 1137 base::PlatformFileError error);
1136 void GetCacheStateOnUIThread(const std::string& resource_id, 1138 void GetCacheStateOnUIThread(const std::string& resource_id,
1137 const std::string& md5, 1139 const std::string& md5,
1138 const GetCacheStateCallback& callback); 1140 const GetCacheStateCallback& callback);
1139 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); 1141 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback);
1140 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin, 1142 void SetPinStateOnUIThread(const FilePath& file_path, bool to_pin,
1141 const FileOperationCallback& callback); 1143 const FileOperationCallback& callback);
1144 void AddUploadedFileOnUIThread(const FilePath& virtual_dir_path,
1145 DocumentEntry* entry,
1146 const FilePath& file_content_path,
1147 GDataCache::FileOperationType cache_operation,
1148 const base::Closure& callback);
1142 1149
1143 // All members should be accessed only on UI thread. Do not post tasks to 1150 // All members should be accessed only on UI thread. Do not post tasks to
1144 // other threads with base::Unretained(this). 1151 // other threads with base::Unretained(this).
1145 1152
1146 scoped_ptr<GDataRootDirectory> root_; 1153 scoped_ptr<GDataRootDirectory> root_;
1147 1154
1148 // The profile hosts the GDataFileSystem via GDataSystemService. 1155 // The profile hosts the GDataFileSystem via GDataSystemService.
1149 Profile* profile_; 1156 Profile* profile_;
1150 1157
1151 // The cache owned by GDataSystemService. 1158 // The cache owned by GDataSystemService.
(...skipping 16 matching lines...) Expand all
1168 1175
1169 ObserverList<Observer> observers_; 1176 ObserverList<Observer> observers_;
1170 1177
1171 // The token is used to post tasks to the blocking pool in sequence. 1178 // The token is used to post tasks to the blocking pool in sequence.
1172 const base::SequencedWorkerPool::SequenceToken sequence_token_; 1179 const base::SequencedWorkerPool::SequenceToken sequence_token_;
1173 }; 1180 };
1174 1181
1175 } // namespace gdata 1182 } // namespace gdata
1176 1183
1177 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 1184 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_download_observer.cc ('k') | chrome/browser/chromeos/gdata/gdata_file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698