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

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: Incorporated comments, fixed bugs. Created 9 years, 11 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 // A DownloadItem normally goes through the following states:
31 // * Created (when download starts)
32 // * Made visible to consumers (e.g. Javascript) after the
33 // destination file has been determined.
34 // * Entered into the history database.
35 // * Made visible in the download shelf.
36 // * All data is received. Note that the actual data download occurs
37 // in parallel with the above steps, but until those steps are
38 // complete, completion of the data download will be ignored.
39 // * Download file is renamed to its final name, and possibly
40 // auto-opened.
41 // TODO(rdsmith): This progress should be reflected in
42 // DownloadItem::DownloadState and a state transition table/state diagram.
43 //
44 // TODO(rdsmith): This description should be updated to reflect the cancel
45 // pathways.
46
30 namespace { 47 namespace {
31 48
32 // Update frequency (milliseconds). 49 // Update frequency (milliseconds).
33 const int kUpdateTimeMs = 1000; 50 const int kUpdateTimeMs = 1000;
34 51
35 void DeleteDownloadedFile(const FilePath& path) { 52 void DeleteDownloadedFile(const FilePath& path) {
36 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
37 54
38 // Make sure we only delete files. 55 // Make sure we only delete files.
39 if (!file_util::DirectoryExists(path)) 56 if (!file_util::DirectoryExists(path))
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 target_name_.value().c_str(), 564 target_name_.value().c_str(),
548 full_path().value().c_str()); 565 full_path().value().c_str());
549 } else { 566 } else {
550 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str()); 567 description += base::StringPrintf(" url = \"%s\"", url().spec().c_str());
551 } 568 }
552 569
553 description += " }"; 570 description += " }";
554 571
555 return description; 572 return description;
556 } 573 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_manager.h » ('j') | chrome/browser/download/download_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698