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_DOWNLOAD_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 // Creates UploadFileInfo and initializes it using DownloadItem*. | 113 // Creates UploadFileInfo and initializes it using DownloadItem*. |
114 void CreateUploadFileInfo(content::DownloadItem* download); | 114 void CreateUploadFileInfo(content::DownloadItem* download); |
115 | 115 |
116 // Callback for checking if the file already exists. If so, the file is | 116 // Callback for checking if the file already exists. If so, the file is |
117 // overwritten, and StartUpload() to actually start the upload. If not, the | 117 // overwritten, and StartUpload() to actually start the upload. If not, the |
118 // directory is queried to determine where to store the file. | 118 // directory is queried to determine where to store the file. |
119 void CreateUploadFileInfoAfterCheckExistence( | 119 void CreateUploadFileInfoAfterCheckExistence( |
120 int32 download_id, | 120 int32 download_id, |
121 scoped_ptr<UploadFileInfo> upload_file_info, | 121 scoped_ptr<UploadFileInfo> upload_file_info, |
122 GDataFileError error, | 122 DriveFileError error, |
123 scoped_ptr<DriveEntryProto> entry_proto); | 123 scoped_ptr<DriveEntryProto> entry_proto); |
124 | 124 |
125 // Callback for handling results of GDataFileSystem::GetEntryInfoByPath() | 125 // Callback for handling results of GDataFileSystem::GetEntryInfoByPath() |
126 // initiated by CreateUploadFileInfoAfterCheckExistence(). This callback | 126 // initiated by CreateUploadFileInfoAfterCheckExistence(). This callback |
127 // reads the directory entry to determine the upload path, then calls | 127 // reads the directory entry to determine the upload path, then calls |
128 // StartUpload() to actually start the upload. | 128 // StartUpload() to actually start the upload. |
129 void CreateUploadFileInfoAfterCheckTargetDir( | 129 void CreateUploadFileInfoAfterCheckTargetDir( |
130 int32 download_id, | 130 int32 download_id, |
131 scoped_ptr<UploadFileInfo> upload_file_info, | 131 scoped_ptr<UploadFileInfo> upload_file_info, |
132 GDataFileError error, | 132 DriveFileError error, |
133 scoped_ptr<DriveEntryProto> entry_proto); | 133 scoped_ptr<DriveEntryProto> entry_proto); |
134 | 134 |
135 // Starts the upload. | 135 // Starts the upload. |
136 void StartUpload(int32 download_id, | 136 void StartUpload(int32 download_id, |
137 scoped_ptr<UploadFileInfo> upload_file_info); | 137 scoped_ptr<UploadFileInfo> upload_file_info); |
138 | 138 |
139 // Callback invoked by GDataUploader when the upload associated with | 139 // Callback invoked by GDataUploader when the upload associated with |
140 // |download_id| has completed. |error| indicated whether the | 140 // |download_id| has completed. |error| indicated whether the |
141 // call was successful. This function takes ownership of DocumentEntry from | 141 // call was successful. This function takes ownership of DocumentEntry from |
142 // |upload_file_info| for use by MoveFileToDriveCache(). It also invokes the | 142 // |upload_file_info| for use by MoveFileToDriveCache(). It also invokes the |
143 // MaybeCompleteDownload() method on the DownloadItem to allow it to complete. | 143 // MaybeCompleteDownload() method on the DownloadItem to allow it to complete. |
144 void OnUploadComplete(int32 download_id, | 144 void OnUploadComplete(int32 download_id, |
145 GDataFileError error, | 145 DriveFileError error, |
146 scoped_ptr<UploadFileInfo> upload_file_info); | 146 scoped_ptr<UploadFileInfo> upload_file_info); |
147 | 147 |
148 // Moves the downloaded file to gdata cache. | 148 // Moves the downloaded file to gdata cache. |
149 // Must be called after GDataDownloadObserver receives COMPLETE notification. | 149 // Must be called after GDataDownloadObserver receives COMPLETE notification. |
150 void MoveFileToDriveCache(content::DownloadItem* download); | 150 void MoveFileToDriveCache(content::DownloadItem* download); |
151 | 151 |
152 // Private data. | 152 // Private data. |
153 // The uploader owned by GDataSystemService. Used to trigger file uploads. | 153 // The uploader owned by GDataSystemService. Used to trigger file uploads. |
154 GDataUploader* gdata_uploader_; | 154 GDataUploader* gdata_uploader_; |
155 // The file system owned by GDataSystemService. | 155 // The file system owned by GDataSystemService. |
(...skipping 11 matching lines...) Expand all Loading... |
167 // Note: This should remain the last member so it'll be destroyed and | 167 // Note: This should remain the last member so it'll be destroyed and |
168 // invalidate its weak pointers before any other members are destroyed. | 168 // invalidate its weak pointers before any other members are destroyed. |
169 base::WeakPtrFactory<GDataDownloadObserver> weak_ptr_factory_; | 169 base::WeakPtrFactory<GDataDownloadObserver> weak_ptr_factory_; |
170 | 170 |
171 DISALLOW_COPY_AND_ASSIGN(GDataDownloadObserver); | 171 DISALLOW_COPY_AND_ASSIGN(GDataDownloadObserver); |
172 }; | 172 }; |
173 | 173 |
174 } // namespace gdata | 174 } // namespace gdata |
175 | 175 |
176 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H_ | 176 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_DOWNLOAD_OBSERVER_H_ |
OLD | NEW |