Chromium Code Reviews| Index: content/browser/download/download_item.cc |
| diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc |
| index e3eff9943cf34b37c35f0b76a1f26125076bdb2f..bc2a278da8c54b7812c139320307cc77149c7d08 100644 |
| --- a/content/browser/download/download_item.cc |
| +++ b/content/browser/download/download_item.cc |
| @@ -14,6 +14,7 @@ |
| #include "base/i18n/string_search.h" |
| #include "base/logging.h" |
| #include "base/metrics/histogram.h" |
| +#include "base/stl_util.h" |
| #include "base/stringprintf.h" |
| #include "base/utf_string_conversions.h" |
| #include "content/browser/download/download_create_info.h" |
| @@ -233,6 +234,8 @@ DownloadItem::~DownloadItem() { |
| TransitionTo(REMOVING); |
| download_manager_->AssertQueueStateConsistent(this); |
| + STLDeleteContainerPairSecondPointers( |
| + external_data_map_.begin(), external_data_map_.end()); |
| } |
| void DownloadItem::AddObserver(Observer* observer) { |
| @@ -716,6 +719,23 @@ void DownloadItem::OffThreadCancel(DownloadFileManager* file_manager) { |
| file_manager, global_id())); |
| } |
| +DownloadItem::ExternalData* |
| +DownloadItem::GetExternalData(void* key) { |
| + if (external_data_map_.count(key) == 0) |
| + return NULL; |
| + return external_data_map_[key]; |
| +} |
| + |
| +void DownloadItem::SetExternalData( |
| + void* key, DownloadItem::ExternalData* data) { |
| + if (external_data_map_.count(key) != 0) { |
|
noelutz
2011/11/16 02:59:38
How about this to avoid all these lookups?
std::m
Randy Smith (Not in Mondays)
2011/11/18 02:02:57
Yes, noticeably better. Thanks for the nudge. Do
|
| + if (external_data_map_[key] == data) |
| + return; // Nothing to do. |
| + delete external_data_map_[key]; |
| + } |
| + external_data_map_[key] = data; |
| +} |
| + |
| void DownloadItem::Init(bool active) { |
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |