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

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

Issue 665253002: Standardize usage of virtual/override/final in chrome/browser/download/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 #include <vector> 5 #include <vector>
6 6
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/download/download_history.h" 10 #include "chrome/browser/download/download_history.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 typedef testing::StrictMock<content::MockDownloadItem> StrictMockDownloadItem; 63 typedef testing::StrictMock<content::MockDownloadItem> StrictMockDownloadItem;
64 64
65 class FakeHistoryAdapter : public DownloadHistory::HistoryAdapter { 65 class FakeHistoryAdapter : public DownloadHistory::HistoryAdapter {
66 public: 66 public:
67 FakeHistoryAdapter() 67 FakeHistoryAdapter()
68 : DownloadHistory::HistoryAdapter(NULL), 68 : DownloadHistory::HistoryAdapter(NULL),
69 slow_create_download_(false), 69 slow_create_download_(false),
70 fail_create_download_(false) { 70 fail_create_download_(false) {
71 } 71 }
72 72
73 virtual ~FakeHistoryAdapter() {} 73 ~FakeHistoryAdapter() override {}
74 74
75 virtual void QueryDownloads( 75 void QueryDownloads(
76 const HistoryService::DownloadQueryCallback& callback) override { 76 const HistoryService::DownloadQueryCallback& callback) override {
77 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 77 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
78 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 78 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
79 base::Bind(&FakeHistoryAdapter::QueryDownloadsDone, 79 base::Bind(&FakeHistoryAdapter::QueryDownloadsDone,
80 base::Unretained(this), callback)); 80 base::Unretained(this), callback));
81 } 81 }
82 82
83 void QueryDownloadsDone( 83 void QueryDownloadsDone(
84 const HistoryService::DownloadQueryCallback& callback) { 84 const HistoryService::DownloadQueryCallback& callback) {
85 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 85 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
86 CHECK(expect_query_downloads_.get()); 86 CHECK(expect_query_downloads_.get());
87 callback.Run(expect_query_downloads_.Pass()); 87 callback.Run(expect_query_downloads_.Pass());
88 } 88 }
89 89
90 void set_slow_create_download(bool slow) { slow_create_download_ = slow; } 90 void set_slow_create_download(bool slow) { slow_create_download_ = slow; }
91 91
92 virtual void CreateDownload( 92 void CreateDownload(
93 const history::DownloadRow& info, 93 const history::DownloadRow& info,
94 const HistoryService::DownloadCreateCallback& callback) override { 94 const HistoryService::DownloadCreateCallback& callback) override {
95 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 95 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
96 create_download_info_ = info; 96 create_download_info_ = info;
97 // Must not call CreateDownload() again before FinishCreateDownload()! 97 // Must not call CreateDownload() again before FinishCreateDownload()!
98 DCHECK(create_download_callback_.is_null()); 98 DCHECK(create_download_callback_.is_null());
99 create_download_callback_ = base::Bind(callback, !fail_create_download_); 99 create_download_callback_ = base::Bind(callback, !fail_create_download_);
100 fail_create_download_ = false; 100 fail_create_download_ = false;
101 if (!slow_create_download_) 101 if (!slow_create_download_)
102 FinishCreateDownload(); 102 FinishCreateDownload();
103 } 103 }
104 104
105 void FinishCreateDownload() { 105 void FinishCreateDownload() {
106 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 106 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
107 create_download_callback_.Run(); 107 create_download_callback_.Run();
108 create_download_callback_.Reset(); 108 create_download_callback_.Reset();
109 } 109 }
110 110
111 virtual void UpdateDownload( 111 void UpdateDownload(const history::DownloadRow& info) override {
112 const history::DownloadRow& info) override {
113 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 112 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
114 update_download_ = info; 113 update_download_ = info;
115 } 114 }
116 115
117 virtual void RemoveDownloads(const IdSet& ids) override { 116 void RemoveDownloads(const IdSet& ids) override {
118 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 117 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
119 for (IdSet::const_iterator it = ids.begin(); 118 for (IdSet::const_iterator it = ids.begin();
120 it != ids.end(); ++it) { 119 it != ids.end(); ++it) {
121 remove_downloads_.insert(*it); 120 remove_downloads_.insert(*it);
122 } 121 }
123 } 122 }
124 123
125 void ExpectWillQueryDownloads(scoped_ptr<InfoVector> infos) { 124 void ExpectWillQueryDownloads(scoped_ptr<InfoVector> infos) {
126 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 125 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
127 expect_query_downloads_ = infos.Pass(); 126 expect_query_downloads_ = infos.Pass();
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 FinishCreateDownload(); 861 FinishCreateDownload();
863 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); 862 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0)));
864 863
865 // ItemAdded should call OnDownloadUpdated, which should detect that the item 864 // ItemAdded should call OnDownloadUpdated, which should detect that the item
866 // changed while it was being added and call UpdateDownload immediately. 865 // changed while it was being added and call UpdateDownload immediately.
867 info.opened = true; 866 info.opened = true;
868 ExpectDownloadUpdated(info); 867 ExpectDownloadUpdated(info);
869 } 868 }
870 869
871 } // anonymous namespace 870 } // anonymous namespace
OLDNEW
« no previous file with comments | « chrome/browser/download/download_history.cc ('k') | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698