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

Unified Diff: content/browser/download/download_item_impl.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: Merged to LKGR. Created 9 years 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
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/mock_download_item.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_item_impl.cc
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index 73c3cc9435fd6f40dbc4e7f224812936908a697d..23d20928cc7a94ab9f5c882a875de921470865dd 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.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"
@@ -260,6 +261,8 @@ DownloadItemImpl::~DownloadItemImpl() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
TransitionTo(REMOVING);
+ STLDeleteContainerPairSecondPointers(
+ external_data_map_.begin(), external_data_map_.end());
delegate_->AssertStateConsistent(this);
delegate_->Detach();
}
@@ -928,3 +931,23 @@ bool DownloadItemImpl::NeedsRename() const {
return state_info_.target_name != full_path_.BaseName();
}
void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; }
+
+DownloadItem::ExternalData*
+DownloadItemImpl::GetExternalData(const void* key) {
+ if (!ContainsKey(external_data_map_, key))
+ return NULL;
+ return external_data_map_[key];
+}
+
+void DownloadItemImpl::SetExternalData(
+ const void* key, DownloadItem::ExternalData* data) {
+ std::map<const void*, ExternalData*>::iterator it =
+ external_data_map_.find(key);
+
+ if (it == external_data_map_.end()) {
+ external_data_map_[key] = data;
+ } else if (it->second != data) {
+ delete it->second;
+ it->second = data;
+ }
+}
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/mock_download_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698