| Index: chrome/browser/extensions/api/downloads/downloads_api.cc
|
| diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
|
| index ea28deb0d027ea02f13bf8ead0db165a13c52ad8..859f240d3b0883663a0b903dadc0a82cb04266cd 100644
|
| --- a/chrome/browser/extensions/api/downloads/downloads_api.cc
|
| +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
|
| @@ -135,7 +135,6 @@ const char* kStateStrings[] = {
|
| kStateInProgress,
|
| kStateComplete,
|
| kStateInterrupted,
|
| - NULL,
|
| kStateInterrupted,
|
| };
|
| COMPILE_ASSERT(arraysize(kStateStrings) == DownloadItem::MAX_DOWNLOAD_STATE,
|
| @@ -160,7 +159,6 @@ const char* StateString(DownloadItem::DownloadState state) {
|
| DCHECK(state >= 0);
|
| DCHECK(state < static_cast<DownloadItem::DownloadState>(
|
| arraysize(kStateStrings)));
|
| - DCHECK(state != DownloadItem::REMOVING);
|
| return kStateStrings[state];
|
| }
|
|
|
| @@ -957,25 +955,30 @@ ExtensionDownloadsEventRouter::OnChangedStat::~OnChangedStat() {
|
| UMA_HISTOGRAM_PERCENTAGE("Download.OnChanged", (fires * 100 / total));
|
| }
|
|
|
| -void ExtensionDownloadsEventRouter::OnDownloadUpdated(DownloadItem* item) {
|
| +void ExtensionDownloadsEventRouter::OnDownloadDestructed(DownloadItem* item) {
|
| if (!profile_)
|
| return;
|
| int download_id = item->GetId();
|
| - if (item->GetState() == DownloadItem::REMOVING) {
|
| - // The REMOVING state indicates that this item is being erased.
|
| - // Let's unregister as an observer so that we don't see any more updates
|
| - // from it, dispatch the onErased event, and remove its json and is
|
| - // OnChangedStat from our maps.
|
| - downloads_.erase(download_id);
|
| - item->RemoveObserver(this);
|
| - DispatchEvent(extension_event_names::kOnDownloadErased,
|
| - base::Value::CreateIntegerValue(download_id));
|
| - delete item_jsons_[download_id];
|
| - item_jsons_.erase(download_id);
|
| - delete on_changed_stats_[download_id];
|
| - on_changed_stats_.erase(download_id);
|
| + downloads_.erase(download_id);
|
| + item->RemoveObserver(this);
|
| + delete item_jsons_[download_id];
|
| + item_jsons_.erase(download_id);
|
| + delete on_changed_stats_[download_id];
|
| + on_changed_stats_.erase(download_id);
|
| +}
|
| +
|
| +void ExtensionDownloadsEventRouter::OnDownloadRemoved(DownloadItem* item) {
|
| + if (!profile_)
|
| return;
|
| - }
|
| + int download_id = item->GetId();
|
| + DispatchEvent(extension_event_names::kOnDownloadErased,
|
| + base::Value::CreateIntegerValue(download_id));
|
| +}
|
| +
|
| +void ExtensionDownloadsEventRouter::OnDownloadUpdated(DownloadItem* item) {
|
| + if (!profile_)
|
| + return;
|
| + int download_id = item->GetId();
|
|
|
| base::DictionaryValue* old_json = item_jsons_[download_id];
|
| scoped_ptr<base::DictionaryValue> new_json(DownloadItemToJSON(item));
|
| @@ -1024,9 +1027,6 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(DownloadItem* item) {
|
| item_jsons_[download_id]->Swap(new_json.get());
|
| }
|
|
|
| -void ExtensionDownloadsEventRouter::OnDownloadOpened(DownloadItem* item) {
|
| -}
|
| -
|
| void ExtensionDownloadsEventRouter::ModelChanged(DownloadManager* manager) {
|
| if (!profile_)
|
| return;
|
| @@ -1077,9 +1077,6 @@ void ExtensionDownloadsEventRouter::ModelChanged(DownloadManager* manager) {
|
| item_jsons_[*iter] = item.release();
|
| }
|
| downloads_.swap(current_map);
|
| -
|
| - // Dispatching onErased is handled in OnDownloadUpdated when an item
|
| - // transitions to the REMOVING state.
|
| }
|
|
|
| void ExtensionDownloadsEventRouter::ManagerGoingDown(
|
|
|