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

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: Synced up to near TOT. 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
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..3109e93e1ed6e2f9c525c1703772b66061df1254 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();
}
@@ -761,6 +764,26 @@ void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) {
file_manager, download_id_));
}
+DownloadItem::ExternalData*
asanka 2011/12/07 04:10:57 Style nit: The method implementation order isn't t
Randy Smith (Not in Mondays) 2011/12/07 18:36:12 Done.
+DownloadItemImpl::GetExternalData(const void* key) {
+ if (external_data_map_.count(key) == 0)
asanka 2011/12/07 04:10:57 Just curious; why not ContainsKey()?
Randy Smith (Not in Mondays) 2011/12/07 18:36:12 Prejudice on my part, which it's probably time for
+ 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;
+ }
+}
+
void DownloadItemImpl::Init(bool active) {
// TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

Powered by Google App Engine
This is Rietveld 408576698