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_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 Loading... | |
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 Loading... | |
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(UploadFileInfo* upload_file_info, |
achuithb
2012/06/14 22:27:18
Can we use a scoped_ptr here too?
hshi1
2012/06/15 00:16:28
Done.
| |
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 | |
87 // Helper function to delete the UploadFileInfo object after completion | |
88 // of AddUploadedFile. | |
89 void OnAddUploadFileComplete(UploadFileInfo* upload_file_info); | |
achuithb
2012/06/14 22:27:18
Why does this need to be a member function? I thin
hshi1
2012/06/15 00:16:28
Done.
| |
90 | |
86 // Pointers to GDataFileSystem and DocumentsServiceInterface objects owned by | 91 // Pointers to GDataFileSystem and DocumentsServiceInterface objects owned by |
87 // GDataSystemService. The lifetime of these two objects is guaranteed to | 92 // GDataSystemService. The lifetime of these two objects is guaranteed to |
88 // exceed that of the GDataUploader instance. | 93 // exceed that of the GDataUploader instance. |
89 GDataFileSystem* file_system_; | 94 GDataFileSystem* file_system_; |
90 DocumentsServiceInterface* documents_service_; | 95 DocumentsServiceInterface* documents_service_; |
91 | 96 |
92 int next_upload_id_; // id counter. | 97 int next_upload_id_; // id counter. |
93 | 98 |
94 typedef std::map<int, UploadFileInfo*> UploadFileInfoMap; | 99 typedef std::map<int, UploadFileInfo*> UploadFileInfoMap; |
95 UploadFileInfoMap pending_uploads_; | 100 UploadFileInfoMap pending_uploads_; |
96 | 101 |
97 // Factory for various callbacks. | 102 // Factory for various callbacks. |
98 base::WeakPtrFactory<GDataUploader> uploader_factory_; | 103 base::WeakPtrFactory<GDataUploader> uploader_factory_; |
99 | 104 |
100 DISALLOW_COPY_AND_ASSIGN(GDataUploader); | 105 DISALLOW_COPY_AND_ASSIGN(GDataUploader); |
101 }; | 106 }; |
102 | 107 |
103 } // namespace gdata | 108 } // namespace gdata |
104 | 109 |
105 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_ | 110 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_UPLOADER_H_ |
OLD | NEW |