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

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

Issue 9518008: Add a const overload to DownloadItem::GetExternalData() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Add a comment explaining the const cast" Created 8 years, 10 months 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 dd08306e35e0f91cb76e444afd46fb453847da30..a8341b1daafb70b47fec34344ce203209beac0d3 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -1131,9 +1131,17 @@ 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];
+ // The behavior of the const overload is identical with the exception of the
+ // constness of |this| and the return value.
+ return const_cast<DownloadItem::ExternalData*>(
+ static_cast<const DownloadItemImpl&>(*this).GetExternalData(key));
+}
+
+const DownloadItem::ExternalData*
+DownloadItemImpl::GetExternalData(const void* key) const {
+ std::map<const void*, ExternalData*>::const_iterator it =
+ external_data_map_.find(key);
+ return (it == external_data_map_.end()) ? NULL : it->second;
}
void DownloadItemImpl::SetExternalData(
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698