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

Unified Diff: content/browser/download/download_item.cc

Issue 8571023: Implemented ExternalData interface on DownloadItem and used it for SafeBrowsing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up a bit. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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));
« content/browser/download/download_item.h ('K') | « content/browser/download/download_item.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698