summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/gdata/gdata_download_observer.cc77
-rw-r--r--chrome/browser/download/chrome_download_manager_delegate.cc10
-rw-r--r--chrome/browser/download/download_completion_blocker.h3
-rw-r--r--chrome/browser/extensions/webstore_installer.cc4
-rw-r--r--chrome/browser/extensions/webstore_installer.h5
-rw-r--r--content/browser/download/download_item_impl.cc30
-rw-r--r--content/browser/download/download_item_impl.h7
-rw-r--r--content/browser/download/download_item_impl_unittest.cc67
-rw-r--r--content/browser/download/download_manager_impl.cc23
-rw-r--r--content/browser/download/download_manager_impl_unittest.cc5
-rw-r--r--content/public/browser/download_item.h26
-rw-r--r--content/public/test/mock_download_item.h3
12 files changed, 65 insertions, 195 deletions
diff --git a/chrome/browser/chromeos/gdata/gdata_download_observer.cc b/chrome/browser/chromeos/gdata/gdata_download_observer.cc
index c6299d0..173209c 100644
--- a/chrome/browser/chromeos/gdata/gdata_download_observer.cc
+++ b/chrome/browser/chromeos/gdata/gdata_download_observer.cc
@@ -6,6 +6,7 @@
#include "base/callback.h"
#include "base/file_util.h"
+#include "base/supports_user_data.h"
#include "chrome/browser/chromeos/gdata/gdata.pb.h"
#include "chrome/browser/chromeos/gdata/gdata_documents_service.h"
#include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h"
@@ -27,18 +28,18 @@ namespace {
// Threshold file size after which we stream the file.
const int64 kStreamingFileSize = 1 << 20; // 1MB
-// Keys for DownloadItem::ExternalData.
+// Keys for base::SupportsUserData::Data.
const char kUploadingKey[] = "Uploading";
const char kGDataPathKey[] = "GDataPath";
-// External Data stored in DownloadItem for ongoing uploads.
-class UploadingExternalData : public DownloadCompletionBlocker {
+// User Data stored in DownloadItem for ongoing uploads.
+class UploadingUserData : public DownloadCompletionBlocker {
public:
- explicit UploadingExternalData(GDataUploader* uploader)
+ explicit UploadingUserData(GDataUploader* uploader)
: uploader_(uploader),
upload_id_(-1) {
}
- virtual ~UploadingExternalData() {}
+ virtual ~UploadingUserData() {}
GDataUploader* uploader() { return uploader_; }
void set_upload_id(int upload_id) { upload_id_ = upload_id; }
@@ -54,14 +55,14 @@ class UploadingExternalData : public DownloadCompletionBlocker {
FilePath virtual_dir_path_;
scoped_ptr<DocumentEntry> entry_;
- DISALLOW_COPY_AND_ASSIGN(UploadingExternalData);
+ DISALLOW_COPY_AND_ASSIGN(UploadingUserData);
};
-// External Data stored in DownloadItem for gdata path.
-class GDataExternalData : public DownloadItem::ExternalData {
+// User Data stored in DownloadItem for gdata path.
+class GDataUserData : public base::SupportsUserData::Data {
public:
- explicit GDataExternalData(const FilePath& path) : file_path_(path) {}
- virtual ~GDataExternalData() {}
+ explicit GDataUserData(const FilePath& path) : file_path_(path) {}
+ virtual ~GDataUserData() {}
const FilePath& file_path() const { return file_path_; }
@@ -69,16 +70,16 @@ class GDataExternalData : public DownloadItem::ExternalData {
FilePath file_path_;
};
-// Extracts UploadingExternalData* from |download|.
-UploadingExternalData* GetUploadingExternalData(DownloadItem* download) {
- return static_cast<UploadingExternalData*>(
- download->GetExternalData(&kUploadingKey));
+// Extracts UploadingUserData* from |download|.
+UploadingUserData* GetUploadingUserData(DownloadItem* download) {
+ return static_cast<UploadingUserData*>(
+ download->GetUserData(&kUploadingKey));
}
-// Extracts GDataExternalData* from |download|.
-GDataExternalData* GetGDataExternalData(DownloadItem* download) {
- return static_cast<GDataExternalData*>(
- download->GetExternalData(&kGDataPathKey));
+// Extracts GDataUserData* from |download|.
+GDataUserData* GetGDataUserData(DownloadItem* download) {
+ return static_cast<GDataUserData*>(
+ download->GetUserData(&kGDataPathKey));
}
void RunSubstituteGDataDownloadCallback(
@@ -233,15 +234,15 @@ void GDataDownloadObserver::SetDownloadParams(const FilePath& gdata_path,
return;
if (gdata::util::IsUnderGDataMountPoint(gdata_path)) {
- download->SetExternalData(&kGDataPathKey,
- new GDataExternalData(gdata_path));
+ download->SetUserData(&kGDataPathKey,
+ new GDataUserData(gdata_path));
download->SetDisplayName(gdata_path.BaseName());
download->SetIsTemporary(true);
} else if (IsGDataDownload(download)) {
// This may have been previously set if the default download folder is
// /drive, and the user has now changed the download target to a local
// folder.
- download->SetExternalData(&kGDataPathKey, NULL);
+ download->SetUserData(&kGDataPathKey, NULL);
download->SetDisplayName(gdata_path);
// TODO(achuith): This is not quite right.
download->SetIsTemporary(false);
@@ -250,7 +251,7 @@ void GDataDownloadObserver::SetDownloadParams(const FilePath& gdata_path,
// static
FilePath GDataDownloadObserver::GetGDataPath(DownloadItem* download) {
- GDataExternalData* data = GetGDataExternalData(download);
+ GDataUserData* data = GetGDataUserData(download);
// If data is NULL, we've somehow lost the gdata path selected by the file
// picker.
DCHECK(data);
@@ -259,9 +260,9 @@ FilePath GDataDownloadObserver::GetGDataPath(DownloadItem* download) {
// static
bool GDataDownloadObserver::IsGDataDownload(DownloadItem* download) {
- // We use the existence of the GDataExternalData object in download as a
+ // We use the existence of the GDataUserData object in download as a
// signal that this is a GDataDownload.
- return !!GetGDataExternalData(download);
+ return !!GetGDataUserData(download);
}
// static
@@ -275,7 +276,7 @@ bool GDataDownloadObserver::IsReadyToComplete(
// 2. The upload has completed.
if (!IsGDataDownload(download))
return true;
- UploadingExternalData* upload_data = GetUploadingExternalData(download);
+ UploadingUserData* upload_data = GetUploadingUserData(download);
DCHECK(upload_data);
if (upload_data->is_complete())
return true;
@@ -285,7 +286,7 @@ bool GDataDownloadObserver::IsReadyToComplete(
// static
int64 GDataDownloadObserver::GetUploadedBytes(DownloadItem* download) {
- UploadingExternalData* upload_data = GetUploadingExternalData(download);
+ UploadingUserData* upload_data = GetUploadingUserData(download);
if (!upload_data || !upload_data->uploader())
return 0;
return upload_data->uploader()->GetUploadedBytes(upload_data->upload_id());
@@ -294,7 +295,7 @@ int64 GDataDownloadObserver::GetUploadedBytes(DownloadItem* download) {
// static
int GDataDownloadObserver::PercentComplete(DownloadItem* download) {
// Progress is unknown until the upload starts.
- if (!GetUploadingExternalData(download))
+ if (!GetUploadingUserData(download))
return -1;
int64 complete = GetUploadedBytes(download);
// Once AllDataSaved() is true, we can use the GetReceivedBytes() as the total
@@ -400,8 +401,8 @@ void GDataDownloadObserver::RemovePendingDownload(DownloadItem* download) {
}
void GDataDownloadObserver::DetachFromDownload(DownloadItem* download) {
- download->SetExternalData(&kUploadingKey, NULL);
- download->SetExternalData(&kGDataPathKey, NULL);
+ download->SetUserData(&kUploadingKey, NULL);
+ download->SetUserData(&kGDataPathKey, NULL);
download->RemoveObserver(this);
}
@@ -412,9 +413,9 @@ void GDataDownloadObserver::UploadDownloadItem(DownloadItem* download) {
if (!ShouldUpload(download))
return;
- // Initialize uploading external data.
- download->SetExternalData(&kUploadingKey,
- new UploadingExternalData(gdata_uploader_));
+ // Initialize uploading userdata.
+ download->SetUserData(&kUploadingKey,
+ new UploadingUserData(gdata_uploader_));
// Create UploadFileInfo structure for the download item.
CreateUploadFileInfo(download);
@@ -423,9 +424,9 @@ void GDataDownloadObserver::UploadDownloadItem(DownloadItem* download) {
void GDataDownloadObserver::UpdateUpload(DownloadItem* download) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- UploadingExternalData* upload_data = GetUploadingExternalData(download);
+ UploadingUserData* upload_data = GetUploadingUserData(download);
if (!upload_data) {
- DVLOG(1) << "No UploadingExternalData for download " << download->GetId();
+ DVLOG(1) << "No UploadingUserData for download " << download->GetId();
return;
}
@@ -441,7 +442,7 @@ bool GDataDownloadObserver::ShouldUpload(DownloadItem* download) {
return (pending_downloads_.count(download->GetId()) != 0) &&
(download->AllDataSaved() ||
download->GetReceivedBytes() > kStreamingFileSize) &&
- (GetUploadingExternalData(download) == NULL);
+ (GetUploadingUserData(download) == NULL);
}
void GDataDownloadObserver::CreateUploadFileInfo(DownloadItem* download) {
@@ -512,7 +513,7 @@ void GDataDownloadObserver::StartUpload(
DVLOG(1) << "Starting upload for download ID " << download_id;
DownloadItem* download_item = iter->second;
- UploadingExternalData* upload_data = GetUploadingExternalData(download_item);
+ UploadingUserData* upload_data = GetUploadingUserData(download_item);
DCHECK(upload_data);
upload_data->set_virtual_dir_path(upload_file_info->gdata_path.DirName());
@@ -538,7 +539,7 @@ void GDataDownloadObserver::OnUploadComplete(
DVLOG(1) << "Completing upload for download ID " << download_id;
DownloadItem* download_item = iter->second;
- UploadingExternalData* upload_data = GetUploadingExternalData(download_item);
+ UploadingUserData* upload_data = GetUploadingUserData(download_item);
DCHECK(upload_data);
// Take ownership of the DocumentEntry from UploadFileInfo. This is used by
@@ -553,7 +554,7 @@ void GDataDownloadObserver::OnUploadComplete(
void GDataDownloadObserver::MoveFileToGDataCache(DownloadItem* download) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- UploadingExternalData* upload_data = GetUploadingExternalData(download);
+ UploadingUserData* upload_data = GetUploadingUserData(download);
if (!upload_data) {
NOTREACHED();
return;
diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc
index fc95cbf..3a909c7 100644
--- a/chrome/browser/download/chrome_download_manager_delegate.cc
+++ b/chrome/browser/download/chrome_download_manager_delegate.cc
@@ -252,12 +252,12 @@ bool ChromeDownloadManagerDelegate::ShouldOpenFileBasedOnExtension(
void ChromeDownloadManagerDelegate::DisableSafeBrowsing(DownloadItem* item) {
#if defined(ENABLE_SAFE_BROWSING)
SafeBrowsingState* state = static_cast<SafeBrowsingState*>(
- item->GetExternalData(&safe_browsing_id));
+ item->GetUserData(&safe_browsing_id));
DCHECK(!state);
if (!state)
state = new SafeBrowsingState();
state->SetVerdict(DownloadProtectionService::SAFE);
- item->SetExternalData(&safe_browsing_id, state);
+ item->SetUserData(&safe_browsing_id, state);
#endif
}
@@ -266,7 +266,7 @@ bool ChromeDownloadManagerDelegate::IsDownloadReadyForCompletion(
const base::Closure& internal_complete_callback) {
#if defined(ENABLE_SAFE_BROWSING)
SafeBrowsingState* state = static_cast<SafeBrowsingState*>(
- item->GetExternalData(&safe_browsing_id));
+ item->GetUserData(&safe_browsing_id));
if (!state) {
// Begin the safe browsing download protection check.
DownloadProtectionService* service = GetDownloadProtectionService();
@@ -275,7 +275,7 @@ bool ChromeDownloadManagerDelegate::IsDownloadReadyForCompletion(
<< item->DebugString(false);
state = new SafeBrowsingState();
state->set_callback(internal_complete_callback);
- item->SetExternalData(&safe_browsing_id, state);
+ item->SetUserData(&safe_browsing_id, state);
service->CheckClientDownload(
DownloadProtectionService::DownloadInfo::FromDownloadItem(*item),
base::Bind(
@@ -609,7 +609,7 @@ void ChromeDownloadManagerDelegate::CheckClientDownloadDone(
}
SafeBrowsingState* state = static_cast<SafeBrowsingState*>(
- item->GetExternalData(&safe_browsing_id));
+ item->GetUserData(&safe_browsing_id));
state->SetVerdict(result);
}
diff --git a/chrome/browser/download/download_completion_blocker.h b/chrome/browser/download/download_completion_blocker.h
index 8f369b5..6cce983 100644
--- a/chrome/browser/download/download_completion_blocker.h
+++ b/chrome/browser/download/download_completion_blocker.h
@@ -6,13 +6,14 @@
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_COMPLETION_BLOCKER_H_
#include "base/callback.h"
+#include "base/supports_user_data.h"
#include "content/public/browser/download_item.h"
// A subsystem may use a DownloadCompletionBlocker in conjunction with
// DownloadManagerDelegate::ShouldCompleteDownload() in order to block the
// completion of a DownloadItem. CompleteDownload() will run the most recent
// callback set.
-class DownloadCompletionBlocker : public content::DownloadItem::ExternalData {
+class DownloadCompletionBlocker : public base::SupportsUserData::Data {
public:
DownloadCompletionBlocker();
virtual ~DownloadCompletionBlocker();
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index 1dfb39f..644b99c 100644
--- a/chrome/browser/extensions/webstore_installer.cc
+++ b/chrome/browser/extensions/webstore_installer.cc
@@ -167,7 +167,7 @@ WebstoreInstaller::Approval::~Approval() {}
const WebstoreInstaller::Approval* WebstoreInstaller::GetAssociatedApproval(
const DownloadItem& download) {
- return static_cast<const Approval*>(download.GetExternalData(kApprovalKey));
+ return static_cast<const Approval*>(download.GetUserData(kApprovalKey));
}
WebstoreInstaller::WebstoreInstaller(Profile* profile,
@@ -283,7 +283,7 @@ void WebstoreInstaller::OnDownloadStarted(DownloadId id, net::Error error) {
download_item_ = download_manager->GetActiveDownloadItem(id.local());
download_item_->AddObserver(this);
if (approval_.get())
- download_item_->SetExternalData(kApprovalKey, approval_.release());
+ download_item_->SetUserData(kApprovalKey, approval_.release());
}
void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) {
diff --git a/chrome/browser/extensions/webstore_installer.h b/chrome/browser/extensions/webstore_installer.h
index aaf95fb..10b1f5d 100644
--- a/chrome/browser/extensions/webstore_installer.h
+++ b/chrome/browser/extensions/webstore_installer.h
@@ -11,14 +11,15 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/supports_user_data.h"
#include "base/values.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_id.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
-#include "net/base/net_errors.h"
#include "googleurl/src/gurl.h"
+#include "net/base/net_errors.h"
class FilePath;
class Profile;
@@ -57,7 +58,7 @@ class WebstoreInstaller :public content::NotificationObserver,
// be skipped or modified. If one of these is present, it means that a CRX
// download was initiated by WebstoreInstaller. The Approval instance should
// be checked further for additional details.
- struct Approval : public content::DownloadItem::ExternalData {
+ struct Approval : public base::SupportsUserData::Data {
static scoped_ptr<Approval> CreateWithInstallPrompt(Profile* profile);
static scoped_ptr<Approval> CreateWithNoInstallPrompt(
Profile* profile,
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index ad4618b1..b7b7ee41 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -301,8 +301,6 @@ DownloadItemImpl::~DownloadItemImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
TransitionTo(REMOVING);
- STLDeleteContainerPairSecondPointers(
- external_data_map_.begin(), external_data_map_.end());
delegate_->AssertStateConsistent(this);
delegate_->Detach();
}
@@ -1170,31 +1168,3 @@ content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
return last_reason_;
}
void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; }
-
-DownloadItem::ExternalData*
-DownloadItemImpl::GetExternalData(const void* 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(
- 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;
- }
-}
diff --git a/content/browser/download/download_item_impl.h b/content/browser/download/download_item_impl.h
index 1b4a334..593fc46 100644
--- a/content/browser/download/download_item_impl.h
+++ b/content/browser/download/download_item_impl.h
@@ -195,9 +195,6 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
virtual FilePath GetUserVerifiedFilePath() const OVERRIDE;
virtual std::string DebugString(bool verbose) const OVERRIDE;
virtual void MockDownloadOpenForTesting() OVERRIDE;
- virtual ExternalData* GetExternalData(const void* key) OVERRIDE;
- virtual const ExternalData* GetExternalData(const void* key) const OVERRIDE;
- virtual void SetExternalData(const void* key, ExternalData* data) OVERRIDE;
private:
// Construction common to all constructors. |active| should be true for new
@@ -404,10 +401,6 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem {
// Did the delegate delay calling Complete on this download?
bool delegate_delayed_complete_;
- // External Data storage. All objects in the store
- // are owned by the DownloadItemImpl.
- std::map<const void*, ExternalData*> external_data_map_;
-
// Net log to use for this download.
const net::BoundNetLog bound_net_log_;
diff --git a/content/browser/download/download_item_impl_unittest.cc b/content/browser/download/download_item_impl_unittest.cc
index 502e426..f2070b3 100644
--- a/content/browser/download/download_item_impl_unittest.cc
+++ b/content/browser/download/download_item_impl_unittest.cc
@@ -408,73 +408,6 @@ TEST_F(DownloadItemTest, DisplayName) {
item->GetFileNameToReportUser().value());
}
-static char external_data_test_string[] = "External data test";
-static int destructor_called = 0;
-
-class TestExternalData : public DownloadItem::ExternalData {
- public:
- int value;
- virtual ~TestExternalData() {
- destructor_called++;
- }
-};
-
-TEST_F(DownloadItemTest, ExternalData) {
- DownloadItemImpl* item = CreateDownloadItem(DownloadItem::IN_PROGRESS);
- const DownloadItemImpl* const_item = item;
-
- // Shouldn't be anything there before set.
- EXPECT_EQ(NULL, item->GetExternalData(&external_data_test_string));
- EXPECT_EQ(NULL, const_item->GetExternalData(&external_data_test_string));
-
- TestExternalData* test1(new TestExternalData());
- test1->value = 2;
-
- // Should be able to get back what you set.
- item->SetExternalData(&external_data_test_string, test1);
- TestExternalData* test_result =
- static_cast<TestExternalData*>(
- item->GetExternalData(&external_data_test_string));
- EXPECT_EQ(test1, test_result);
-
- // Ditto for const lookup.
- const TestExternalData* test_const_result =
- static_cast<const TestExternalData*>(
- const_item->GetExternalData(&external_data_test_string));
- EXPECT_EQ(static_cast<const TestExternalData*>(test1),
- test_const_result);
-
- // Destructor should be called if value overwritten. New value
- // should then be retrievable.
- TestExternalData* test2(new TestExternalData());
- test2->value = 3;
- EXPECT_EQ(0, destructor_called);
- item->SetExternalData(&external_data_test_string, test2);
- EXPECT_EQ(1, destructor_called);
- EXPECT_EQ(static_cast<DownloadItem::ExternalData*>(test2),
- item->GetExternalData(&external_data_test_string));
-
- // Overwriting with the same value shouldn't do anything.
- EXPECT_EQ(1, destructor_called);
- item->SetExternalData(&external_data_test_string, test2);
- EXPECT_EQ(1, destructor_called);
- EXPECT_EQ(static_cast<DownloadItem::ExternalData*>(test2),
- item->GetExternalData(&external_data_test_string));
-
- // Overwriting with NULL should result in destruction.
- item->SetExternalData(&external_data_test_string, NULL);
- EXPECT_EQ(2, destructor_called);
-
- // Destroying the download item should destroy the external data.
-
- TestExternalData* test3(new TestExternalData());
- item->SetExternalData(&external_data_test_string, test3);
- EXPECT_EQ(static_cast<DownloadItem::ExternalData*>(test3),
- item->GetExternalData(&external_data_test_string));
- DestroyDownloadItem(item);
- EXPECT_EQ(3, destructor_called);
-}
-
// Test that the delegate is invoked after the download file is renamed.
// Delegate::DownloadRenamedToIntermediateName() should be invoked when the
// download is renamed to the intermediate name.
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index c1e983e..ce33228 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -15,6 +15,7 @@
#include "base/message_loop.h"
#include "base/stl_util.h"
#include "base/stringprintf.h"
+#include "base/supports_user_data.h"
#include "base/synchronization/lock.h"
#include "base/sys_string_conversions.h"
#include "build/build_config.h"
@@ -52,26 +53,26 @@ using content::WebContents;
namespace {
// This is just used to remember which DownloadItems come from SavePage.
-class SavePageExternalData : public DownloadItem::ExternalData {
+class SavePageData : public base::SupportsUserData::Data {
public:
// A spoonful of syntactic sugar.
static bool Get(DownloadItem* item) {
- return item->GetExternalData(kKey) != NULL;
+ return item->GetUserData(kKey) != NULL;
}
- explicit SavePageExternalData(DownloadItem* item) {
- item->SetExternalData(kKey, this);
+ explicit SavePageData(DownloadItem* item) {
+ item->SetUserData(kKey, this);
}
- virtual ~SavePageExternalData() {}
+ virtual ~SavePageData() {}
private:
static const char kKey[];
- DISALLOW_COPY_AND_ASSIGN(SavePageExternalData);
+ DISALLOW_COPY_AND_ASSIGN(SavePageData);
};
-const char SavePageExternalData::kKey[] = "DownloadItem SavePageExternalData";
+const char SavePageData::kKey[] = "DownloadItem SavePageData";
void BeginDownload(content::DownloadUrlParameters* params) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
@@ -566,9 +567,9 @@ DownloadItemImpl* DownloadManagerImpl::CreateSavePackageDownloadItem(
DCHECK(!ContainsKey(downloads_, download->GetId()));
downloads_[download->GetId()] = download;
- DCHECK(!SavePageExternalData::Get(download));
- new SavePageExternalData(download);
- DCHECK(SavePageExternalData::Get(download));
+ DCHECK(!SavePageData::Get(download));
+ new SavePageData(download);
+ DCHECK(SavePageData::Get(download));
// TODO(benjhayden): Fire OnDownloadCreated for SavePackage downloads when
// we're comfortable with the user interacting with them.
@@ -928,7 +929,7 @@ void DownloadManagerImpl::OnItemAddedToPersistentStore(int32 download_id,
DownloadItemImpl* item = downloads_[download_id];
AddDownloadItemToHistory(item, db_handle);
- if (SavePageExternalData::Get(item)) {
+ if (SavePageData::Get(item)) {
OnSavePageItemAddedToPersistentStore(item);
} else {
OnDownloadItemAddedToPersistentStore(item);
diff --git a/content/browser/download/download_manager_impl_unittest.cc b/content/browser/download/download_manager_impl_unittest.cc
index 545c414..d3c7931 100644
--- a/content/browser/download/download_manager_impl_unittest.cc
+++ b/content/browser/download/download_manager_impl_unittest.cc
@@ -157,9 +157,6 @@ class MockDownloadItemImpl : public DownloadItemImpl {
MOCK_METHOD0(OffThreadCancel, void());
MOCK_CONST_METHOD1(DebugString, std::string(bool));
MOCK_METHOD0(MockDownloadOpenForTesting, void());
- MOCK_METHOD1(GetExternalData, ExternalData*(const void*));
- MOCK_CONST_METHOD1(GetExternalData, const ExternalData*(const void*));
- MOCK_METHOD2(SetExternalData, void(const void*, ExternalData*));
};
class MockDownloadManagerDelegate : public content::DownloadManagerDelegate {
@@ -641,8 +638,6 @@ TEST_F(DownloadManagerTest, OnDownloadStopped_Persisted) {
MockDownloadItemImpl& item(AddItemToManager());
int download_id = item.GetId();
int64 db_handle = 0x7;
- EXPECT_CALL(item, GetExternalData(_))
- .WillOnce(Return(static_cast<DownloadItem::ExternalData*>(NULL)));
EXPECT_CALL(GetMockObserver(), ModelChanged(download_manager_.get()))
.WillOnce(Return());
AddItemToHistory(item, db_handle);
diff --git a/content/public/browser/download_item.h b/content/public/browser/download_item.h
index 20dc06b..c440bce 100644
--- a/content/public/browser/download_item.h
+++ b/content/public/browser/download_item.h
@@ -23,6 +23,7 @@
#include "base/file_path.h"
#include "base/string16.h"
+#include "base/supports_user_data.h"
#include "content/public/browser/download_danger_type.h"
#include "content/public/browser/download_interrupt_reasons.h"
#include "content/public/common/page_transition_types.h"
@@ -49,7 +50,7 @@ struct DownloadPersistentStoreInfo;
// Destination tab's download view, may refer to a given DownloadItem.
//
// This is intended to be used only on the UI thread.
-class CONTENT_EXPORT DownloadItem {
+class CONTENT_EXPORT DownloadItem : public base::SupportsUserData {
public:
enum DownloadState {
// Download is actively progressing.
@@ -111,13 +112,6 @@ class CONTENT_EXPORT DownloadItem {
virtual ~Observer() {}
};
- // Interface for data that can be stored associated with (and owned
- // by) an object of this class via GetExternalData/SetExternalData.
- class ExternalData {
- public:
- virtual ~ExternalData() {};
- };
-
virtual ~DownloadItem() {}
virtual void AddObserver(DownloadItem::Observer* observer) = 0;
@@ -291,22 +285,6 @@ class CONTENT_EXPORT DownloadItem {
// but does not for dangerous downloads until the name is verified.
virtual FilePath GetUserVerifiedFilePath() const = 0;
- // Manage data owned by other subsystems associated with the
- // DownloadItem. By custom, key is the address of a
- // static char subsystem_specific_string[] = ".."; defined
- // in the subsystem, but the only requirement of this interface
- // is that the key be unique over all data stored with this
- // DownloadItem.
- //
- // Note that SetExternalData takes ownership of the
- // passed object; it will be destroyed when the DownloadItem is.
- // If an object is already held by the DownloadItem associated with
- // the passed key, it will be destroyed if overwriten by a new pointer
- // (overwrites by the same pointer are ignored).
- virtual ExternalData* GetExternalData(const void* key) = 0;
- virtual const ExternalData* GetExternalData(const void* key) const = 0;
- virtual void SetExternalData(const void* key, ExternalData* data) = 0;
-
virtual std::string DebugString(bool verbose) const = 0;
virtual void MockDownloadOpenForTesting() = 0;
diff --git a/content/public/test/mock_download_item.h b/content/public/test/mock_download_item.h
index ca66bf2..9f327e9 100644
--- a/content/public/test/mock_download_item.h
+++ b/content/public/test/mock_download_item.h
@@ -97,9 +97,6 @@ class MockDownloadItem : public DownloadItem {
MOCK_CONST_METHOD0(GetUserVerifiedFilePath, FilePath());
MOCK_CONST_METHOD1(DebugString, std::string(bool));
MOCK_METHOD0(MockDownloadOpenForTesting, void());
- MOCK_METHOD1(GetExternalData, ExternalData*(const void*));
- MOCK_CONST_METHOD1(GetExternalData, const ExternalData*(const void*));
- MOCK_METHOD2(SetExternalData, void(const void*, ExternalData*));
};
} // namespace content