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

Unified Diff: chrome/browser/chromeos/gdata/gdata_uploader.h

Issue 10540132: gdata: Convert GDataFileSystem::AddUploadFile() to asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Satoru's comments. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gdata/gdata_uploader.h
diff --git a/chrome/browser/chromeos/gdata/gdata_uploader.h b/chrome/browser/chromeos/gdata/gdata_uploader.h
index b3bb8da3c5b1fa3770e030a813f1ed40febb7444..47b3b68e4d60c71a425edd43a1f97b4982465ecc 100644
--- a/chrome/browser/chromeos/gdata/gdata_uploader.h
+++ b/chrome/browser/chromeos/gdata/gdata_uploader.h
@@ -13,6 +13,7 @@
#include "base/basictypes.h"
#include "base/memory/weak_ptr.h"
#include "base/platform_file.h"
+#include "base/synchronization/lock.h"
#include "chrome/browser/chromeos/gdata/gdata_errorcode.h"
#include "chrome/browser/chromeos/gdata/gdata_params.h"
#include "googleurl/src/gurl.h"
@@ -43,10 +44,6 @@ class GDataUploader {
// Returns the count of bytes confirmed as uploaded so far.
int64 GetUploadedBytes(int upload_id) const;
- // TODO(achuith): Make this private.
- // Destroys |upload_file_info|.
- void DeleteUpload(UploadFileInfo* upload_file_info);
-
private:
// Lookup UploadFileInfo* in pending_uploads_.
UploadFileInfo* GetUploadFileInfo(int upload_id) const;
@@ -83,6 +80,15 @@ class GDataUploader {
void UploadFailed(UploadFileInfo* upload_file_info,
base::PlatformFileError error);
+ // Removes |upload_file_info| from UploadFileInfoMap |pending_uploads_|.
+ // Note that this does not delete the |upload_file_info| object itself,
+ // because it may still be in use by an asynchronous function.
+ void RemoveUpload(UploadFileInfo* upload_file_info);
+
+ // Helper function to delete the UploadFileInfo object after completion
+ // of AddUploadedFile.
+ void OnAddUploadFileComplete(UploadFileInfo* upload_file_info);
+
// Pointers to GDataFileSystem and DocumentsServiceInterface objects owned by
// GDataSystemService. The lifetime of these two objects is guaranteed to
// exceed that of the GDataUploader instance.
@@ -97,6 +103,9 @@ class GDataUploader {
// Factory for various callbacks.
base::WeakPtrFactory<GDataUploader> uploader_factory_;
+ // This ensures serialized access to UploadFileInfoMap |pending_uploads_|.
+ base::Lock lock_;
+
DISALLOW_COPY_AND_ASSIGN(GDataUploader);
};

Powered by Google App Engine
This is Rietveld 408576698