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/extensions/api/downloads/downloads_api.h" | 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 } | 1031 } |
1032 | 1032 |
1033 void DownloadsDownloadFunction::OnStarted( | 1033 void DownloadsDownloadFunction::OnStarted( |
1034 const base::FilePath& creator_suggested_filename, | 1034 const base::FilePath& creator_suggested_filename, |
1035 downloads::FilenameConflictAction creator_conflict_action, | 1035 downloads::FilenameConflictAction creator_conflict_action, |
1036 DownloadItem* item, | 1036 DownloadItem* item, |
1037 content::DownloadInterruptReason interrupt_reason) { | 1037 content::DownloadInterruptReason interrupt_reason) { |
1038 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1038 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1039 VLOG(1) << __FUNCTION__ << " " << item << " " << interrupt_reason; | 1039 VLOG(1) << __FUNCTION__ << " " << item << " " << interrupt_reason; |
1040 if (item) { | 1040 if (item) { |
1041 DCHECK_EQ(content::DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason); | |
1042 SetResult(new base::FundamentalValue(static_cast<int>(item->GetId()))); | 1041 SetResult(new base::FundamentalValue(static_cast<int>(item->GetId()))); |
1043 if (!creator_suggested_filename.empty() || | 1042 if (!creator_suggested_filename.empty() || |
1044 (creator_conflict_action != | 1043 (creator_conflict_action != |
1045 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY)) { | 1044 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY)) { |
1046 ExtensionDownloadsEventRouterData* data = | 1045 ExtensionDownloadsEventRouterData* data = |
1047 ExtensionDownloadsEventRouterData::Get(item); | 1046 ExtensionDownloadsEventRouterData::Get(item); |
1048 if (!data) { | 1047 if (!data) { |
1049 data = new ExtensionDownloadsEventRouterData( | 1048 data = new ExtensionDownloadsEventRouterData( |
1050 item, | 1049 item, |
1051 scoped_ptr<base::DictionaryValue>(new base::DictionaryValue())); | 1050 scoped_ptr<base::DictionaryValue>(new base::DictionaryValue())); |
1052 } | 1051 } |
1053 data->CreatorSuggestedFilename( | 1052 data->CreatorSuggestedFilename( |
1054 creator_suggested_filename, creator_conflict_action); | 1053 creator_suggested_filename, creator_conflict_action); |
1055 } | 1054 } |
1056 new DownloadedByExtension(item, extension()->id(), extension()->name()); | 1055 new DownloadedByExtension(item, extension()->id(), extension()->name()); |
1057 item->UpdateObservers(); | 1056 item->UpdateObservers(); |
1058 } else { | 1057 } else { |
1059 DCHECK_NE(content::DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason); | |
1060 error_ = content::DownloadInterruptReasonToString(interrupt_reason); | 1058 error_ = content::DownloadInterruptReasonToString(interrupt_reason); |
1061 } | 1059 } |
1062 SendResponse(error_.empty()); | 1060 SendResponse(error_.empty()); |
1063 } | 1061 } |
1064 | 1062 |
1065 DownloadsSearchFunction::DownloadsSearchFunction() {} | 1063 DownloadsSearchFunction::DownloadsSearchFunction() {} |
1066 | 1064 |
1067 DownloadsSearchFunction::~DownloadsSearchFunction() {} | 1065 DownloadsSearchFunction::~DownloadsSearchFunction() {} |
1068 | 1066 |
1069 bool DownloadsSearchFunction::RunSync() { | 1067 bool DownloadsSearchFunction::RunSync() { |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 return; | 1901 return; |
1904 base::Time now(base::Time::Now()); | 1902 base::Time now(base::Time::Now()); |
1905 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); | 1903 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); |
1906 if (delta <= kFileExistenceRateLimitSeconds) | 1904 if (delta <= kFileExistenceRateLimitSeconds) |
1907 return; | 1905 return; |
1908 last_checked_removal_ = now; | 1906 last_checked_removal_ = now; |
1909 manager->CheckForHistoryFilesRemoval(); | 1907 manager->CheckForHistoryFilesRemoval(); |
1910 } | 1908 } |
1911 | 1909 |
1912 } // namespace extensions | 1910 } // namespace extensions |
OLD | NEW |