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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/download/download_item_impl.h" 5 #include "content/browser/download/download_item_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/i18n/case_conversion.h" 13 #include "base/i18n/case_conversion.h"
14 #include "base/i18n/string_search.h" 14 #include "base/i18n/string_search.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/stl_util.h"
17 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
18 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
19 #include "content/browser/download/download_create_info.h" 20 #include "content/browser/download/download_create_info.h"
20 #include "content/browser/download/download_file.h" 21 #include "content/browser/download/download_file.h"
21 #include "content/browser/download/download_file_manager.h" 22 #include "content/browser/download/download_file_manager.h"
22 #include "content/browser/download/download_id.h" 23 #include "content/browser/download/download_id.h"
23 #include "content/browser/download/download_persistent_store_info.h" 24 #include "content/browser/download/download_persistent_store_info.h"
24 #include "content/browser/download/download_request_handle.h" 25 #include "content/browser/download/download_request_handle.h"
25 #include "content/browser/download/download_stats.h" 26 #include "content/browser/download/download_stats.h"
26 #include "content/browser/download/interrupt_reasons.h" 27 #include "content/browser/download/interrupt_reasons.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 delegate_delayed_complete_(false) { 254 delegate_delayed_complete_(false) {
254 delegate_->Attach(); 255 delegate_->Attach();
255 Init(true /* actively downloading */); 256 Init(true /* actively downloading */);
256 } 257 }
257 258
258 DownloadItemImpl::~DownloadItemImpl() { 259 DownloadItemImpl::~DownloadItemImpl() {
259 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 260 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
260 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 261 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
261 262
262 TransitionTo(REMOVING); 263 TransitionTo(REMOVING);
264 STLDeleteContainerPairSecondPointers(
265 external_data_map_.begin(), external_data_map_.end());
263 delegate_->AssertStateConsistent(this); 266 delegate_->AssertStateConsistent(this);
264 delegate_->Detach(); 267 delegate_->Detach();
265 } 268 }
266 269
267 void DownloadItemImpl::AddObserver(Observer* observer) { 270 void DownloadItemImpl::AddObserver(Observer* observer) {
268 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 271 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
269 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 272 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
270 273
271 observers_.AddObserver(observer); 274 observers_.AddObserver(observer);
272 } 275 }
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; } 924 void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; }
922 bool DownloadItemImpl::GetOpened() const { return opened_; } 925 bool DownloadItemImpl::GetOpened() const { return opened_; }
923 InterruptReason DownloadItemImpl::GetLastReason() const { 926 InterruptReason DownloadItemImpl::GetLastReason() const {
924 return last_reason_; 927 return last_reason_;
925 } 928 }
926 DownloadStateInfo DownloadItemImpl::GetStateInfo() const { return state_info_; } 929 DownloadStateInfo DownloadItemImpl::GetStateInfo() const { return state_info_; }
927 bool DownloadItemImpl::NeedsRename() const { 930 bool DownloadItemImpl::NeedsRename() const {
928 return state_info_.target_name != full_path_.BaseName(); 931 return state_info_.target_name != full_path_.BaseName();
929 } 932 }
930 void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; } 933 void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; }
934
935 DownloadItem::ExternalData*
936 DownloadItemImpl::GetExternalData(const void* key) {
937 if (!ContainsKey(external_data_map_, key))
938 return NULL;
939 return external_data_map_[key];
940 }
941
942 void DownloadItemImpl::SetExternalData(
943 const void* key, DownloadItem::ExternalData* data) {
944 std::map<const void*, ExternalData*>::iterator it =
945 external_data_map_.find(key);
946
947 if (it == external_data_map_.end()) {
948 external_data_map_[key] = data;
949 } else if (it->second != data) {
950 delete it->second;
951 it->second = data;
952 }
953 }
OLDNEW
« 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