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

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

Issue 10919093: Rename GDataUplaoder to DriveUploader (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix after rebase Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/drive_download_observer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_DRIVE_DOWNLOAD_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_DOWNLOAD_OBSERVER_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_DOWNLOAD_OBSERVER_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_DOWNLOAD_OBSERVER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "content/public/browser/download_item.h" 13 #include "content/public/browser/download_item.h"
14 #include "content/public/browser/download_manager.h" 14 #include "content/public/browser/download_manager.h"
15 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" 15 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h"
16 16
17 class Profile; 17 class Profile;
18 18
19 namespace gdata { 19 namespace gdata {
20 20
21 class DocumentEntry; 21 class DocumentEntry;
22 class DriveEntryProto; 22 class DriveEntryProto;
23 class DriveFileSystemInterface; 23 class DriveFileSystemInterface;
24 class GDataUploader; 24 class DriveUploader;
25 struct UploadFileInfo; 25 struct UploadFileInfo;
26 26
27 // Observes downloads to temporary local drive folder. Schedules these 27 // Observes downloads to temporary local drive folder. Schedules these
28 // downloads for upload to drive service. 28 // downloads for upload to drive service.
29 class DriveDownloadObserver : public content::DownloadManager::Observer, 29 class DriveDownloadObserver : public content::DownloadManager::Observer,
30 public content::DownloadItem::Observer { 30 public content::DownloadItem::Observer {
31 public: 31 public:
32 DriveDownloadObserver(GDataUploader* uploader, 32 DriveDownloadObserver(DriveUploader* uploader,
33 DriveFileSystemInterface* file_system); 33 DriveFileSystemInterface* file_system);
34 virtual ~DriveDownloadObserver(); 34 virtual ~DriveDownloadObserver();
35 35
36 // Become an observer of DownloadManager. 36 // Become an observer of DownloadManager.
37 void Initialize(content::DownloadManager* download_manager, 37 void Initialize(content::DownloadManager* download_manager,
38 const FilePath& drive_tmp_download_path); 38 const FilePath& drive_tmp_download_path);
39 39
40 typedef base::Callback<void(const FilePath&)> 40 typedef base::Callback<void(const FilePath&)>
41 SubstituteDriveDownloadPathCallback; 41 SubstituteDriveDownloadPathCallback;
42 static void SubstituteDriveDownloadPath(Profile* profile, 42 static void SubstituteDriveDownloadPath(Profile* profile,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 DriveFileError 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 DriveUploader 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 DriveFileError 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 drive cache. 148 // Moves the downloaded file to drive cache.
149 // Must be called after DriveDownloadObserver receives COMPLETE notification. 149 // Must be called after DriveDownloadObserver 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 DriveSystemService. Used to trigger file uploads. 153 // The uploader owned by DriveSystemService. Used to trigger file uploads.
154 GDataUploader* gdata_uploader_; 154 DriveUploader* drive_uploader_;
155 // The file system owned by DriveSystemService. 155 // The file system owned by DriveSystemService.
156 DriveFileSystemInterface* file_system_; 156 DriveFileSystemInterface* file_system_;
157 // Observe the DownloadManager for new downloads. 157 // Observe the DownloadManager for new downloads.
158 content::DownloadManager* download_manager_; 158 content::DownloadManager* download_manager_;
159 159
160 // Temporary download location directory. 160 // Temporary download location directory.
161 FilePath drive_tmp_download_path_; 161 FilePath drive_tmp_download_path_;
162 162
163 // Map of pending downloads. 163 // Map of pending downloads.
164 typedef std::map<int32, content::DownloadItem*> DownloadMap; 164 typedef std::map<int32, content::DownloadItem*> DownloadMap;
165 DownloadMap pending_downloads_; 165 DownloadMap pending_downloads_;
166 166
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<DriveDownloadObserver> weak_ptr_factory_; 169 base::WeakPtrFactory<DriveDownloadObserver> weak_ptr_factory_;
170 170
171 DISALLOW_COPY_AND_ASSIGN(DriveDownloadObserver); 171 DISALLOW_COPY_AND_ASSIGN(DriveDownloadObserver);
172 }; 172 };
173 173
174 } // namespace gdata 174 } // namespace gdata
175 175
176 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_DOWNLOAD_OBSERVER_H_ 176 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_DOWNLOAD_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/drive_download_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698