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

Side by Side Diff: chrome/browser/download/download_file.cc

Issue 55046: Installing extensions (drag/drop, download crx file) will now be... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | « chrome/browser/download/download_file.h ('k') | chrome/browser/download/download_manager.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/download/download_file.h" 5 #include "chrome/browser/download/download_file.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/task.h" 10 #include "base/task.h"
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 #else 543 #else
544 // TODO(port) implement me. 544 // TODO(port) implement me.
545 NOTREACHED(); 545 NOTREACHED();
546 #endif 546 #endif
547 } 547 }
548 548
549 // The DownloadManager in the UI thread has provided a final name for the 549 // The DownloadManager in the UI thread has provided a final name for the
550 // download specified by 'id'. Rename the in progress download, and remove it 550 // download specified by 'id'. Rename the in progress download, and remove it
551 // from our table if it has been completed or cancelled already. 551 // from our table if it has been completed or cancelled already.
552 void DownloadFileManager::OnFinalDownloadName(int id, 552 void DownloadFileManager::OnFinalDownloadName(int id,
553 const FilePath& full_path) { 553 const FilePath& full_path,
554 DownloadManager* manager) {
554 DCHECK(MessageLoop::current() == file_loop_); 555 DCHECK(MessageLoop::current() == file_loop_);
555 DownloadFileMap::iterator it = downloads_.find(id); 556 DownloadFileMap::iterator it = downloads_.find(id);
556 if (it == downloads_.end()) 557 if (it == downloads_.end())
557 return; 558 return;
558 559
559 file_util::CreateDirectory(full_path.DirName()); 560 file_util::CreateDirectory(full_path.DirName());
560 561
561 DownloadFile* download = it->second; 562 DownloadFile* download = it->second;
562 if (!download->Rename(full_path)) { 563 if (download->Rename(full_path)) {
564 ui_loop_->PostTask(FROM_HERE,
565 NewRunnableMethod(manager,
566 &DownloadManager::DownloadRenamedToFinalName,
567 id,
568 full_path));
569 } else {
563 // Error. Between the time the UI thread generated 'full_path' to the time 570 // Error. Between the time the UI thread generated 'full_path' to the time
564 // this code runs, something happened that prevents us from renaming. 571 // this code runs, something happened that prevents us from renaming.
565 DownloadManagerMap::iterator dmit = managers_.find(download->id()); 572 DownloadManagerMap::iterator dmit = managers_.find(download->id());
566 if (dmit != managers_.end()) { 573 if (dmit != managers_.end()) {
567 DownloadManager* dlm = dmit->second; 574 DownloadManager* dlm = dmit->second;
568 ui_loop_->PostTask(FROM_HERE, 575 ui_loop_->PostTask(FROM_HERE,
569 NewRunnableMethod(dlm, 576 NewRunnableMethod(dlm,
570 &DownloadManager::DownloadCancelled, 577 &DownloadManager::DownloadCancelled,
571 id)); 578 id));
572 } else { 579 } else {
(...skipping 15 matching lines...) Expand all
588 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( 595 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
589 this, &DownloadFileManager::StopUpdateTimer)); 596 this, &DownloadFileManager::StopUpdateTimer));
590 } 597 }
591 598
592 // static 599 // static
593 void DownloadFileManager::DeleteFile(const FilePath& path) { 600 void DownloadFileManager::DeleteFile(const FilePath& path) {
594 // Make sure we only delete files. 601 // Make sure we only delete files.
595 if (!file_util::DirectoryExists(path)) 602 if (!file_util::DirectoryExists(path))
596 file_util::Delete(path, false); 603 file_util::Delete(path, false);
597 } 604 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_file.h ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698