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

Side by Side 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: 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_UPLOADER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 25 matching lines...) Expand all
36 // Uploads a file specified by |upload_file_info|. Transfers ownership. 36 // Uploads a file specified by |upload_file_info|. Transfers ownership.
37 // Returns the upload_id. 37 // Returns the upload_id.
38 int UploadFile(scoped_ptr<UploadFileInfo> upload_file_info); 38 int UploadFile(scoped_ptr<UploadFileInfo> upload_file_info);
39 39
40 // Updates attributes of streaming upload. 40 // Updates attributes of streaming upload.
41 void UpdateUpload(int upload_id, content::DownloadItem* download); 41 void UpdateUpload(int upload_id, content::DownloadItem* download);
42 42
43 // Returns the count of bytes confirmed as uploaded so far. 43 // Returns the count of bytes confirmed as uploaded so far.
44 int64 GetUploadedBytes(int upload_id) const; 44 int64 GetUploadedBytes(int upload_id) const;
45 45
46 // TODO(achuith): Make this private.
47 // Destroys |upload_file_info|.
48 void DeleteUpload(UploadFileInfo* upload_file_info);
49
50 private: 46 private:
51 // Lookup UploadFileInfo* in pending_uploads_. 47 // Lookup UploadFileInfo* in pending_uploads_.
52 UploadFileInfo* GetUploadFileInfo(int upload_id) const; 48 UploadFileInfo* GetUploadFileInfo(int upload_id) const;
53 49
54 // Open the file. 50 // Open the file.
55 void OpenFile(UploadFileInfo* upload_file_info); 51 void OpenFile(UploadFileInfo* upload_file_info);
56 52
57 // net::FileStream::Open completion callback. The result of the file 53 // net::FileStream::Open completion callback. The result of the file
58 // open operation is passed as |result|. 54 // open operation is passed as |result|.
59 void OpenCompletionCallback(int upload_id, int result); 55 void OpenCompletionCallback(int upload_id, int result);
(...skipping 13 matching lines...) Expand all
73 69
74 // DocumentsService callback for ResumeUpload. 70 // DocumentsService callback for ResumeUpload.
75 void OnResumeUploadResponseReceived(int upload_id, 71 void OnResumeUploadResponseReceived(int upload_id,
76 const ResumeUploadResponse& response, 72 const ResumeUploadResponse& response,
77 scoped_ptr<DocumentEntry> entry); 73 scoped_ptr<DocumentEntry> entry);
78 74
79 // When upload completes, move the file into the gdata cache. 75 // When upload completes, move the file into the gdata cache.
80 void MoveFileToCache(UploadFileInfo* upload_file_info); 76 void MoveFileToCache(UploadFileInfo* upload_file_info);
81 77
82 // Handle failed uploads. 78 // Handle failed uploads.
83 void UploadFailed(UploadFileInfo* upload_file_info, 79 void UploadFailed(scoped_ptr<UploadFileInfo> upload_file_info,
84 base::PlatformFileError error); 80 base::PlatformFileError error);
85 81
82 // Removes |upload_id| from UploadFileInfoMap |pending_uploads_|.
83 // Note that this does not delete the UploadFileInfo object itself,
84 // because it may still be in use by an asynchronous function.
85 void RemoveUpload(int upload_id);
86
86 // Pointers to GDataFileSystem and DocumentsServiceInterface objects owned by 87 // Pointers to GDataFileSystem and DocumentsServiceInterface objects owned by
87 // GDataSystemService. The lifetime of these two objects is guaranteed to 88 // GDataSystemService. The lifetime of these two objects is guaranteed to
88 // exceed that of the GDataUploader instance. 89 // exceed that of the GDataUploader instance.
89 GDataFileSystem* file_system_; 90 GDataFileSystem* file_system_;
90 DocumentsServiceInterface* documents_service_; 91 DocumentsServiceInterface* documents_service_;
91 92
92 int next_upload_id_; // id counter. 93 int next_upload_id_; // id counter.
93 94
94 typedef std::map<int, UploadFileInfo*> UploadFileInfoMap; 95 typedef std::map<int, UploadFileInfo*> UploadFileInfoMap;
95 UploadFileInfoMap pending_uploads_; 96 UploadFileInfoMap pending_uploads_;
96 97
97 // Factory for various callbacks. 98 // Factory for various callbacks.
98 base::WeakPtrFactory<GDataUploader> uploader_factory_; 99 base::WeakPtrFactory<GDataUploader> uploader_factory_;
99 100
100 DISALLOW_COPY_AND_ASSIGN(GDataUploader); 101 DISALLOW_COPY_AND_ASSIGN(GDataUploader);
101 }; 102 };
102 103
103 } // namespace gdata 104 } // namespace gdata
104 105
105 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_ 106 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_upload_file_info.cc ('k') | chrome/browser/chromeos/gdata/gdata_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698