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

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

Issue 6096003: Put history insertion for downloads processing inline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 12 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_item.h" 5 #include "chrome/browser/download/download_item.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
16 #include "chrome/browser/browser_thread.h" 16 #include "chrome/browser/browser_thread.h"
17 #include "chrome/browser/download/download_extensions.h" 17 #include "chrome/browser/download/download_extensions.h"
18 #include "chrome/browser/download/download_file_manager.h" 18 #include "chrome/browser/download/download_file_manager.h"
19 #include "chrome/browser/download/download_history.h" 19 #include "chrome/browser/download/download_history.h"
20 #include "chrome/browser/download/download_manager.h" 20 #include "chrome/browser/download/download_manager.h"
21 #include "chrome/browser/download/download_prefs.h" 21 #include "chrome/browser/download/download_prefs.h"
22 #include "chrome/browser/download/download_util.h" 22 #include "chrome/browser/download/download_util.h"
23 #include "chrome/browser/history/download_create_info.h" 23 #include "chrome/browser/history/download_create_info.h"
24 #include "chrome/browser/platform_util.h" 24 #include "chrome/browser/platform_util.h"
25 #include "chrome/browser/prefs/pref_service.h" 25 #include "chrome/browser/prefs/pref_service.h"
26 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/common/extensions/extension.h" 27 #include "chrome/common/extensions/extension.h"
28 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
29 29
30 // The lifecycle of a DownloadItem under normal conditions:
Paweł Hajdan Jr. 2011/01/03 09:43:03 I'm not sure if it's a good idea to put all that i
Randy Smith (Not in Mondays) 2011/01/04 19:29:21 Fair enough. Long term I really feel like there n
31 // * Created. Downloading of data starts here.
32 // (DownloadFileManager::StartDownload ->
33 // DownloadManager::CreateDownloadItem).
34 // * Made visible to consumers by entry into
35 // DownloadManager::in_progress_ map after file information is
36 // nailed down. The file into which data
37 // is being downloaded is renamed to the intermedate file name here (*)
38 // (DownloadManager::OnPathExistenceAvailable (or select file callback)
39 // -> DownloadManager::AttachDownloadItem).
40 // * Entered into the downloads history
41 // (HistoryBackEnd::CreateDownload)
42 // * Made visible in the download shelf
43 // (DownloadManager::OnCreateDownloadEntryComplete after entry into
44 // history).
45 // * Completed--after above sequence and all data has been received.
46 // (DownloadManager::MaybeCompleteDownload).
47 // * Renamed to final name (*) and possibly auto-opened
48 // (DownloadManager::DownloadFinished -> platform_util::OpenItem)
49 //
50 // (*) Both the nature of the intermediate file name and the routines used
51 // for immedate and final file rename are different for dangerous and
52 // non-dangerous downloads:
53 // * Non-dangerous: Intermediate file format "<actual name>.crdownload"
54 // (with a possible path uniquifier). Intermediate file rename done
55 // by DownloadFileManager::OnIntermediateDownloadName, Final file
56 // rename done by DownloadFileManager::OnFinalDownloadName.
57 // * Dangerous: Intermediate file format "unconfirmed %d.crdownload".
58 // Intermediate file rename done by
59 // DownloadFileManager::OnFinalDownloadName (sic). Final file
60 // rename done by DownloadManager::ProceedWithDangerousDownload.
61
62 // TODO(rdsmith): This progress should be reflected in
63 // DownloadItem::DownloadState and a state transition table/state diagram.
64 //
65 // TODO(rdsmith): This description should be updated to reflect the cancel
66 // pathways.
67
30 namespace { 68 namespace {
31 69
32 // Update frequency (milliseconds). 70 // Update frequency (milliseconds).
33 const int kUpdateTimeMs = 1000; 71 const int kUpdateTimeMs = 1000;
34 72
35 void DeleteDownloadedFile(const FilePath& path) { 73 void DeleteDownloadedFile(const FilePath& path) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
37 75
38 // Make sure we only delete files. 76 // Make sure we only delete files.
39 if (!file_util::DirectoryExists(path)) 77 if (!file_util::DirectoryExists(path))
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 target_name_.value().c_str(), 582 target_name_.value().c_str(),
545 full_path().value().c_str()); 583 full_path().value().c_str());
546 } else { 584 } else {
547 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); 585 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str());
548 } 586 }
549 587
550 description += " }"; 588 description += " }";
551 589
552 return description; 590 return description;
553 } 591 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_manager.h » ('j') | chrome/browser/download/download_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698