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

Side by Side Diff: chrome/browser/download/download_history.cc

Issue 16703018: Rewrite scoped_ptr<T>(NULL) to use the default ctor in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // DownloadHistory manages persisting DownloadItems to the history service by 5 // DownloadHistory manages persisting DownloadItems to the history service by
6 // observing a single DownloadManager and all its DownloadItems using an 6 // observing a single DownloadManager and all its DownloadItems using an
7 // AllDownloadItemNotifier. 7 // AllDownloadItemNotifier.
8 // 8 //
9 // DownloadHistory decides whether and when to add items to, remove items from, 9 // DownloadHistory decides whether and when to add items to, remove items from,
10 // and update items in the database. DownloadHistory uses DownloadHistoryData to 10 // and update items in the database. DownloadHistory uses DownloadHistoryData to
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // have no control over when DownloadItems are destroyed. 48 // have no control over when DownloadItems are destroyed.
49 class DownloadHistoryData : public base::SupportsUserData::Data { 49 class DownloadHistoryData : public base::SupportsUserData::Data {
50 public: 50 public:
51 static DownloadHistoryData* Get(content::DownloadItem* item) { 51 static DownloadHistoryData* Get(content::DownloadItem* item) {
52 base::SupportsUserData::Data* data = item->GetUserData(kKey); 52 base::SupportsUserData::Data* data = item->GetUserData(kKey);
53 return (data == NULL) ? NULL : 53 return (data == NULL) ? NULL :
54 static_cast<DownloadHistoryData*>(data); 54 static_cast<DownloadHistoryData*>(data);
55 } 55 }
56 56
57 DownloadHistoryData(content::DownloadItem* item, int64 handle) 57 DownloadHistoryData(content::DownloadItem* item, int64 handle)
58 : is_adding_(false), 58 : is_adding_(false), db_handle_(handle) {
59 db_handle_(handle),
60 info_(NULL) {
61 item->SetUserData(kKey, this); 59 item->SetUserData(kKey, this);
62 } 60 }
63 61
64 virtual ~DownloadHistoryData() { 62 virtual ~DownloadHistoryData() {
65 } 63 }
66 64
67 // Whether this item is currently being added to the database. 65 // Whether this item is currently being added to the database.
68 bool is_adding() const { return is_adding_; } 66 bool is_adding() const { return is_adding_; }
69 void set_is_adding(bool a) { is_adding_ = a; } 67 void set_is_adding(bool a) { is_adding_ = a; }
70 68
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 420
423 void DownloadHistory::RemoveDownloadsBatch() { 421 void DownloadHistory::RemoveDownloadsBatch() {
424 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 422 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
425 HandleSet remove_handles; 423 HandleSet remove_handles;
426 IdSet remove_ids; 424 IdSet remove_ids;
427 removing_handles_.swap(remove_handles); 425 removing_handles_.swap(remove_handles);
428 removing_ids_.swap(remove_ids); 426 removing_ids_.swap(remove_ids);
429 history_->RemoveDownloads(remove_handles); 427 history_->RemoveDownloads(remove_handles);
430 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); 428 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids));
431 } 429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698