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 #include "chrome/browser/chromeos/gdata/drive_download_observer.h" | 5 #include "chrome/browser/chromeos/gdata/drive_download_observer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/supports_user_data.h" | 11 #include "base/supports_user_data.h" |
12 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 12 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
13 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" | 13 #include "chrome/browser/chromeos/gdata/drive_file_system_interface.h" |
14 #include "chrome/browser/chromeos/gdata/drive_file_system_util.h" | 14 #include "chrome/browser/chromeos/gdata/drive_file_system_util.h" |
15 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | 15 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
16 #include "chrome/browser/chromeos/gdata/drive_system_service.h" | 16 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
17 #include "chrome/browser/chromeos/gdata/gdata_upload_file_info.h" | 17 #include "chrome/browser/chromeos/gdata/drive_upload_file_info.h" |
18 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" | 18 #include "chrome/browser/chromeos/gdata/drive_uploader.h" |
19 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
20 #include "chrome/browser/download/download_completion_blocker.h" | 20 #include "chrome/browser/download/download_completion_blocker.h" |
21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
23 | 23 |
24 using content::BrowserThread; | 24 using content::BrowserThread; |
25 using content::DownloadManager; | 25 using content::DownloadManager; |
26 using content::DownloadItem; | 26 using content::DownloadItem; |
27 | 27 |
28 namespace gdata { | 28 namespace gdata { |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Threshold file size after which we stream the file. | 31 // Threshold file size after which we stream the file. |
32 const int64 kStreamingFileSize = 1 << 20; // 1MB | 32 const int64 kStreamingFileSize = 1 << 20; // 1MB |
33 | 33 |
34 // Keys for base::SupportsUserData::Data. | 34 // Keys for base::SupportsUserData::Data. |
35 const char kUploadingKey[] = "Uploading"; | 35 const char kUploadingKey[] = "Uploading"; |
36 const char kGDataPathKey[] = "GDataPath"; | 36 const char kGDataPathKey[] = "GDataPath"; |
37 | 37 |
38 // User Data stored in DownloadItem for ongoing uploads. | 38 // User Data stored in DownloadItem for ongoing uploads. |
39 class UploadingUserData : public DownloadCompletionBlocker { | 39 class UploadingUserData : public DownloadCompletionBlocker { |
40 public: | 40 public: |
41 explicit UploadingUserData(GDataUploader* uploader) | 41 explicit UploadingUserData(DriveUploader* uploader) |
42 : uploader_(uploader), | 42 : uploader_(uploader), |
43 upload_id_(-1), | 43 upload_id_(-1), |
44 is_overwrite_(false) { | 44 is_overwrite_(false) { |
45 } | 45 } |
46 virtual ~UploadingUserData() {} | 46 virtual ~UploadingUserData() {} |
47 | 47 |
48 GDataUploader* uploader() { return uploader_; } | 48 DriveUploader* uploader() { return uploader_; } |
49 void set_upload_id(int upload_id) { upload_id_ = upload_id; } | 49 void set_upload_id(int upload_id) { upload_id_ = upload_id; } |
50 int upload_id() const { return upload_id_; } | 50 int upload_id() const { return upload_id_; } |
51 void set_virtual_dir_path(const FilePath& path) { virtual_dir_path_ = path; } | 51 void set_virtual_dir_path(const FilePath& path) { virtual_dir_path_ = path; } |
52 const FilePath& virtual_dir_path() const { return virtual_dir_path_; } | 52 const FilePath& virtual_dir_path() const { return virtual_dir_path_; } |
53 void set_entry(scoped_ptr<DocumentEntry> entry) { entry_ = entry.Pass(); } | 53 void set_entry(scoped_ptr<DocumentEntry> entry) { entry_ = entry.Pass(); } |
54 scoped_ptr<DocumentEntry> entry_passed() { return entry_.Pass(); } | 54 scoped_ptr<DocumentEntry> entry_passed() { return entry_.Pass(); } |
55 void set_overwrite(bool overwrite) { is_overwrite_ = overwrite; } | 55 void set_overwrite(bool overwrite) { is_overwrite_ = overwrite; } |
56 bool is_overwrite() { return is_overwrite_; } | 56 bool is_overwrite() { return is_overwrite_; } |
57 void set_resource_id(const std::string& resource_id) { | 57 void set_resource_id(const std::string& resource_id) { |
58 resource_id_ = resource_id; | 58 resource_id_ = resource_id; |
59 } | 59 } |
60 const std::string& resource_id() const { return resource_id_; } | 60 const std::string& resource_id() const { return resource_id_; } |
61 void set_md5(const std::string& md5) { md5_ = md5; } | 61 void set_md5(const std::string& md5) { md5_ = md5; } |
62 const std::string& md5() const { return md5_; } | 62 const std::string& md5() const { return md5_; } |
63 | 63 |
64 private: | 64 private: |
65 GDataUploader* uploader_; | 65 DriveUploader* uploader_; |
66 int upload_id_; | 66 int upload_id_; |
67 FilePath virtual_dir_path_; | 67 FilePath virtual_dir_path_; |
68 scoped_ptr<DocumentEntry> entry_; | 68 scoped_ptr<DocumentEntry> entry_; |
69 bool is_overwrite_; | 69 bool is_overwrite_; |
70 std::string resource_id_; | 70 std::string resource_id_; |
71 std::string md5_; | 71 std::string md5_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(UploadingUserData); | 73 DISALLOW_COPY_AND_ASSIGN(UploadingUserData); |
74 }; | 74 }; |
75 | 75 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 substitute_callback)); | 184 substitute_callback)); |
185 } else { | 185 } else { |
186 // TODO(achuith): Handle this. | 186 // TODO(achuith): Handle this. |
187 NOTREACHED(); | 187 NOTREACHED(); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 } // namespace | 191 } // namespace |
192 | 192 |
193 DriveDownloadObserver::DriveDownloadObserver( | 193 DriveDownloadObserver::DriveDownloadObserver( |
194 GDataUploader* uploader, | 194 DriveUploader* uploader, |
195 DriveFileSystemInterface* file_system) | 195 DriveFileSystemInterface* file_system) |
196 : gdata_uploader_(uploader), | 196 : drive_uploader_(uploader), |
197 file_system_(file_system), | 197 file_system_(file_system), |
198 download_manager_(NULL), | 198 download_manager_(NULL), |
199 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 199 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
200 } | 200 } |
201 | 201 |
202 DriveDownloadObserver::~DriveDownloadObserver() { | 202 DriveDownloadObserver::~DriveDownloadObserver() { |
203 if (download_manager_) | 203 if (download_manager_) |
204 download_manager_->RemoveObserver(this); | 204 download_manager_->RemoveObserver(this); |
205 | 205 |
206 for (DownloadMap::iterator iter = pending_downloads_.begin(); | 206 for (DownloadMap::iterator iter = pending_downloads_.begin(); |
207 iter != pending_downloads_.end(); ++iter) { | 207 iter != pending_downloads_.end(); ++iter) { |
208 DetachFromDownload(iter->second); | 208 DetachFromDownload(iter->second); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 void DriveDownloadObserver::Initialize( | 212 void DriveDownloadObserver::Initialize( |
213 DownloadManager* download_manager, | 213 DownloadManager* download_manager, |
214 const FilePath& drive_tmp_download_path) { | 214 const FilePath& drive_tmp_download_path) { |
215 DCHECK(!drive_tmp_download_path.empty()); | 215 DCHECK(!drive_tmp_download_path.empty()); |
216 download_manager_ = download_manager; | 216 download_manager_ = download_manager; |
217 if (download_manager_) | 217 if (download_manager_) |
218 download_manager_->AddObserver(this); | 218 download_manager_->AddObserver(this); |
219 drive_tmp_download_path_ = drive_tmp_download_path; | 219 drive_tmp_download_path_ = drive_tmp_download_path; |
220 } | 220 } |
221 | 221 |
222 // static | 222 // static |
223 void DriveDownloadObserver::SubstituteDriveDownloadPath(Profile* profile, | 223 void DriveDownloadObserver::SubstituteDriveDownloadPath(Profile* profile, |
224 const FilePath& gdata_path, content::DownloadItem* download, | 224 const FilePath& drive_path, content::DownloadItem* download, |
225 const SubstituteDriveDownloadPathCallback& callback) { | 225 const SubstituteDriveDownloadPathCallback& callback) { |
226 DVLOG(1) << "SubstituteDriveDownloadPath " << gdata_path.value(); | 226 DVLOG(1) << "SubstituteDriveDownloadPath " << drive_path.value(); |
227 | 227 |
228 SetDownloadParams(gdata_path, download); | 228 SetDownloadParams(drive_path, download); |
229 | 229 |
230 if (util::IsUnderGDataMountPoint(gdata_path)) { | 230 if (util::IsUnderGDataMountPoint(drive_path)) { |
231 // Can't access drive if we're not authenticated. | 231 // Can't access drive if we're not authenticated. |
232 // We set off a chain of callbacks as follows: | 232 // We set off a chain of callbacks as follows: |
233 // DriveServiceInterface::Authenticate | 233 // DriveServiceInterface::Authenticate |
234 // OnAuthenticate calls DriveFileSystem::GetEntryInfoByPath | 234 // OnAuthenticate calls DriveFileSystem::GetEntryInfoByPath |
235 // OnEntryFound calls DriveFileSystem::CreateDirectory (if necessary) | 235 // OnEntryFound calls DriveFileSystem::CreateDirectory (if necessary) |
236 // OnCreateDirectory calls SubstituteDriveDownloadPathInternal | 236 // OnCreateDirectory calls SubstituteDriveDownloadPathInternal |
237 GetSystemService(profile)->drive_service()->Authenticate( | 237 GetSystemService(profile)->drive_service()->Authenticate( |
238 base::Bind(&OnAuthenticate, profile, gdata_path, | 238 base::Bind(&OnAuthenticate, profile, drive_path, |
239 base::Bind(&SubstituteDriveDownloadPathInternal, | 239 base::Bind(&SubstituteDriveDownloadPathInternal, |
240 profile, callback))); | 240 profile, callback))); |
241 } else { | 241 } else { |
242 callback.Run(gdata_path); | 242 callback.Run(drive_path); |
243 } | 243 } |
244 } | 244 } |
245 | 245 |
246 // static | 246 // static |
247 void DriveDownloadObserver::SetDownloadParams(const FilePath& gdata_path, | 247 void DriveDownloadObserver::SetDownloadParams(const FilePath& drive_path, |
248 DownloadItem* download) { | 248 DownloadItem* download) { |
249 if (!download) | 249 if (!download) |
250 return; | 250 return; |
251 | 251 |
252 if (util::IsUnderGDataMountPoint(gdata_path)) { | 252 if (util::IsUnderGDataMountPoint(drive_path)) { |
253 download->SetUserData(&kGDataPathKey, | 253 download->SetUserData(&kGDataPathKey, |
254 new DriveUserData(gdata_path)); | 254 new DriveUserData(drive_path)); |
255 download->SetDisplayName(gdata_path.BaseName()); | 255 download->SetDisplayName(drive_path.BaseName()); |
256 download->SetIsTemporary(true); | 256 download->SetIsTemporary(true); |
257 } else if (IsDriveDownload(download)) { | 257 } else if (IsDriveDownload(download)) { |
258 // This may have been previously set if the default download folder is | 258 // This may have been previously set if the default download folder is |
259 // /drive, and the user has now changed the download target to a local | 259 // /drive, and the user has now changed the download target to a local |
260 // folder. | 260 // folder. |
261 download->SetUserData(&kGDataPathKey, NULL); | 261 download->SetUserData(&kGDataPathKey, NULL); |
262 download->SetDisplayName(gdata_path); | 262 download->SetDisplayName(drive_path); |
263 // TODO(achuith): This is not quite right. | 263 // TODO(achuith): This is not quite right. |
264 download->SetIsTemporary(false); | 264 download->SetIsTemporary(false); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 // static | 268 // static |
269 FilePath DriveDownloadObserver::GetDrivePath(DownloadItem* download) { | 269 FilePath DriveDownloadObserver::GetDrivePath(DownloadItem* download) { |
270 DriveUserData* data = GetDriveUserData(download); | 270 DriveUserData* data = GetDriveUserData(download); |
271 // If data is NULL, we've somehow lost the gdata path selected by the file | 271 // If data is NULL, we've somehow lost the gdata path selected by the file |
272 // picker. | 272 // picker. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 427 |
428 void DriveDownloadObserver::UploadDownloadItem(DownloadItem* download) { | 428 void DriveDownloadObserver::UploadDownloadItem(DownloadItem* download) { |
429 // Update metadata of ongoing upload. | 429 // Update metadata of ongoing upload. |
430 UpdateUpload(download); | 430 UpdateUpload(download); |
431 | 431 |
432 if (!ShouldUpload(download)) | 432 if (!ShouldUpload(download)) |
433 return; | 433 return; |
434 | 434 |
435 // Initialize uploading userdata. | 435 // Initialize uploading userdata. |
436 download->SetUserData(&kUploadingKey, | 436 download->SetUserData(&kUploadingKey, |
437 new UploadingUserData(gdata_uploader_)); | 437 new UploadingUserData(drive_uploader_)); |
438 | 438 |
439 // Create UploadFileInfo structure for the download item. | 439 // Create UploadFileInfo structure for the download item. |
440 CreateUploadFileInfo(download); | 440 CreateUploadFileInfo(download); |
441 } | 441 } |
442 | 442 |
443 void DriveDownloadObserver::UpdateUpload(DownloadItem* download) { | 443 void DriveDownloadObserver::UpdateUpload(DownloadItem* download) { |
444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
445 | 445 |
446 UploadingUserData* upload_data = GetUploadingUserData(download); | 446 UploadingUserData* upload_data = GetUploadingUserData(download); |
447 if (!upload_data) { | 447 if (!upload_data) { |
448 DVLOG(1) << "No UploadingUserData for download " << download->GetId(); | 448 DVLOG(1) << "No UploadingUserData for download " << download->GetId(); |
449 return; | 449 return; |
450 } | 450 } |
451 | 451 |
452 gdata_uploader_->UpdateUpload(upload_data->upload_id(), download); | 452 drive_uploader_->UpdateUpload(upload_data->upload_id(), download); |
453 } | 453 } |
454 | 454 |
455 bool DriveDownloadObserver::ShouldUpload(DownloadItem* download) { | 455 bool DriveDownloadObserver::ShouldUpload(DownloadItem* download) { |
456 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 456 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
457 | 457 |
458 // Upload if the item is in pending_downloads_, | 458 // Upload if the item is in pending_downloads_, |
459 // is complete or large enough to stream, and, | 459 // is complete or large enough to stream, and, |
460 // is not already being uploaded. | 460 // is not already being uploaded. |
461 return (pending_downloads_.count(download->GetId()) != 0) && | 461 return (pending_downloads_.count(download->GetId()) != 0) && |
462 (download->AllDataSaved() || | 462 (download->AllDataSaved() || |
463 download->GetReceivedBytes() > kStreamingFileSize) && | 463 download->GetReceivedBytes() > kStreamingFileSize) && |
464 (GetUploadingUserData(download) == NULL); | 464 (GetUploadingUserData(download) == NULL); |
465 } | 465 } |
466 | 466 |
467 void DriveDownloadObserver::CreateUploadFileInfo(DownloadItem* download) { | 467 void DriveDownloadObserver::CreateUploadFileInfo(DownloadItem* download) { |
468 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 468 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
469 | 469 |
470 scoped_ptr<UploadFileInfo> upload_file_info(new UploadFileInfo()); | 470 scoped_ptr<UploadFileInfo> upload_file_info(new UploadFileInfo()); |
471 | 471 |
472 // GetFullPath will be a temporary location if we're streaming. | 472 // GetFullPath will be a temporary location if we're streaming. |
473 upload_file_info->file_path = download->GetFullPath(); | 473 upload_file_info->file_path = download->GetFullPath(); |
474 upload_file_info->file_size = download->GetReceivedBytes(); | 474 upload_file_info->file_size = download->GetReceivedBytes(); |
475 | 475 |
476 // Extract the final path from DownloadItem. | 476 // Extract the final path from DownloadItem. |
477 upload_file_info->gdata_path = GetDrivePath(download); | 477 upload_file_info->drive_path = GetDrivePath(download); |
478 | 478 |
479 // Use the file name as the title. | 479 // Use the file name as the title. |
480 upload_file_info->title = upload_file_info->gdata_path.BaseName().value(); | 480 upload_file_info->title = upload_file_info->drive_path.BaseName().value(); |
481 upload_file_info->content_type = download->GetMimeType(); | 481 upload_file_info->content_type = download->GetMimeType(); |
482 // GData api handles -1 as unknown file length. | 482 // GData api handles -1 as unknown file length. |
483 upload_file_info->content_length = download->AllDataSaved() ? | 483 upload_file_info->content_length = download->AllDataSaved() ? |
484 download->GetReceivedBytes() : -1; | 484 download->GetReceivedBytes() : -1; |
485 | 485 |
486 upload_file_info->all_bytes_present = download->AllDataSaved(); | 486 upload_file_info->all_bytes_present = download->AllDataSaved(); |
487 | 487 |
488 upload_file_info->completion_callback = | 488 upload_file_info->completion_callback = |
489 base::Bind(&DriveDownloadObserver::OnUploadComplete, | 489 base::Bind(&DriveDownloadObserver::OnUploadComplete, |
490 weak_ptr_factory_.GetWeakPtr(), | 490 weak_ptr_factory_.GetWeakPtr(), |
491 download->GetId()); | 491 download->GetId()); |
492 | 492 |
493 // First check if |path| already exists. If so, we'll be overwriting an | 493 // First check if |path| already exists. If so, we'll be overwriting an |
494 // existing file. | 494 // existing file. |
495 const FilePath path = upload_file_info->gdata_path; | 495 const FilePath path = upload_file_info->drive_path; |
496 file_system_->GetEntryInfoByPath( | 496 file_system_->GetEntryInfoByPath( |
497 path, | 497 path, |
498 base::Bind( | 498 base::Bind( |
499 &DriveDownloadObserver::CreateUploadFileInfoAfterCheckExistence, | 499 &DriveDownloadObserver::CreateUploadFileInfoAfterCheckExistence, |
500 weak_ptr_factory_.GetWeakPtr(), | 500 weak_ptr_factory_.GetWeakPtr(), |
501 download->GetId(), | 501 download->GetId(), |
502 base::Passed(&upload_file_info))); | 502 base::Passed(&upload_file_info))); |
503 } | 503 } |
504 | 504 |
505 void DriveDownloadObserver::CreateUploadFileInfoAfterCheckExistence( | 505 void DriveDownloadObserver::CreateUploadFileInfoAfterCheckExistence( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 upload_data->set_resource_id(entry_proto->resource_id()); | 538 upload_data->set_resource_id(entry_proto->resource_id()); |
539 upload_data->set_md5(entry_proto->file_specific_info().file_md5()); | 539 upload_data->set_md5(entry_proto->file_specific_info().file_md5()); |
540 upload_data->set_overwrite(true); | 540 upload_data->set_overwrite(true); |
541 | 541 |
542 StartUpload(download_id, upload_file_info.Pass()); | 542 StartUpload(download_id, upload_file_info.Pass()); |
543 } else { | 543 } else { |
544 // No file exists at the target path, so upload as a new file. | 544 // No file exists at the target path, so upload as a new file. |
545 | 545 |
546 // Get the DriveDirectory proto for the upload directory, then extract the | 546 // Get the DriveDirectory proto for the upload directory, then extract the |
547 // initial upload URL in OnReadDirectoryByPath(). | 547 // initial upload URL in OnReadDirectoryByPath(). |
548 const FilePath upload_dir = upload_file_info->gdata_path.DirName(); | 548 const FilePath upload_dir = upload_file_info->drive_path.DirName(); |
549 file_system_->GetEntryInfoByPath( | 549 file_system_->GetEntryInfoByPath( |
550 upload_dir, | 550 upload_dir, |
551 base::Bind( | 551 base::Bind( |
552 &DriveDownloadObserver::CreateUploadFileInfoAfterCheckTargetDir, | 552 &DriveDownloadObserver::CreateUploadFileInfoAfterCheckTargetDir, |
553 weak_ptr_factory_.GetWeakPtr(), | 553 weak_ptr_factory_.GetWeakPtr(), |
554 download_id, | 554 download_id, |
555 base::Passed(&upload_file_info))); | 555 base::Passed(&upload_file_info))); |
556 } | 556 } |
557 } | 557 } |
558 | 558 |
(...skipping 27 matching lines...) Expand all Loading... |
586 DownloadMap::iterator iter = pending_downloads_.find(download_id); | 586 DownloadMap::iterator iter = pending_downloads_.find(download_id); |
587 if (iter == pending_downloads_.end()) { | 587 if (iter == pending_downloads_.end()) { |
588 DVLOG(1) << "Pending download not found" << download_id; | 588 DVLOG(1) << "Pending download not found" << download_id; |
589 return; | 589 return; |
590 } | 590 } |
591 DVLOG(1) << "Starting upload for download ID " << download_id; | 591 DVLOG(1) << "Starting upload for download ID " << download_id; |
592 DownloadItem* download_item = iter->second; | 592 DownloadItem* download_item = iter->second; |
593 | 593 |
594 UploadingUserData* upload_data = GetUploadingUserData(download_item); | 594 UploadingUserData* upload_data = GetUploadingUserData(download_item); |
595 DCHECK(upload_data); | 595 DCHECK(upload_data); |
596 upload_data->set_virtual_dir_path(upload_file_info->gdata_path.DirName()); | 596 upload_data->set_virtual_dir_path(upload_file_info->drive_path.DirName()); |
597 | 597 |
598 // Start upload and save the upload id for future reference. | 598 // Start upload and save the upload id for future reference. |
599 if (upload_data->is_overwrite()) { | 599 if (upload_data->is_overwrite()) { |
600 const int upload_id = | 600 const int upload_id = |
601 gdata_uploader_->StreamExistingFile(upload_file_info.Pass()); | 601 drive_uploader_->StreamExistingFile(upload_file_info.Pass()); |
602 upload_data->set_upload_id(upload_id); | 602 upload_data->set_upload_id(upload_id); |
603 } else { | 603 } else { |
604 const int upload_id = | 604 const int upload_id = |
605 gdata_uploader_->UploadNewFile(upload_file_info.Pass()); | 605 drive_uploader_->UploadNewFile(upload_file_info.Pass()); |
606 upload_data->set_upload_id(upload_id); | 606 upload_data->set_upload_id(upload_id); |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
610 void DriveDownloadObserver::OnUploadComplete( | 610 void DriveDownloadObserver::OnUploadComplete( |
611 int32 download_id, | 611 int32 download_id, |
612 DriveFileError error, | 612 DriveFileError error, |
613 scoped_ptr<UploadFileInfo> upload_file_info) { | 613 scoped_ptr<UploadFileInfo> upload_file_info) { |
614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
615 DCHECK(upload_file_info.get()); | 615 DCHECK(upload_file_info.get()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, | 665 file_system_->AddUploadedFile(UPLOAD_NEW_FILE, |
666 upload_data->virtual_dir_path(), | 666 upload_data->virtual_dir_path(), |
667 entry.Pass(), | 667 entry.Pass(), |
668 download->GetTargetFilePath(), | 668 download->GetTargetFilePath(), |
669 DriveCache::FILE_OPERATION_MOVE, | 669 DriveCache::FILE_OPERATION_MOVE, |
670 base::Bind(&base::DoNothing)); | 670 base::Bind(&base::DoNothing)); |
671 } | 671 } |
672 } | 672 } |
673 | 673 |
674 } // namespace gdata | 674 } // namespace gdata |
OLD | NEW |