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

Side by Side Diff: content/browser/appcache/appcache_storage_impl_unittest.cc

Issue 631773003: Replacing the OVERRIDE with override and FINAL with final in content/browser/appcache (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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stack> 5 #include <stack>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 (*body) = ""; 121 (*body) = "";
122 } 122 }
123 } 123 }
124 }; 124 };
125 125
126 class MockHttpServerJobFactory 126 class MockHttpServerJobFactory
127 : public net::URLRequestJobFactory::ProtocolHandler { 127 : public net::URLRequestJobFactory::ProtocolHandler {
128 public: 128 public:
129 virtual net::URLRequestJob* MaybeCreateJob( 129 virtual net::URLRequestJob* MaybeCreateJob(
130 net::URLRequest* request, 130 net::URLRequest* request,
131 net::NetworkDelegate* network_delegate) const OVERRIDE { 131 net::NetworkDelegate* network_delegate) const override {
132 return MockHttpServer::CreateJob(request, network_delegate); 132 return MockHttpServer::CreateJob(request, network_delegate);
133 } 133 }
134 }; 134 };
135 135
136 class IOThread : public base::Thread { 136 class IOThread : public base::Thread {
137 public: 137 public:
138 explicit IOThread(const char* name) 138 explicit IOThread(const char* name)
139 : base::Thread(name) { 139 : base::Thread(name) {
140 } 140 }
141 141
142 virtual ~IOThread() { 142 virtual ~IOThread() {
143 Stop(); 143 Stop();
144 } 144 }
145 145
146 net::URLRequestContext* request_context() { 146 net::URLRequestContext* request_context() {
147 return request_context_.get(); 147 return request_context_.get();
148 } 148 }
149 149
150 virtual void Init() OVERRIDE { 150 virtual void Init() override {
151 scoped_ptr<net::URLRequestJobFactoryImpl> factory( 151 scoped_ptr<net::URLRequestJobFactoryImpl> factory(
152 new net::URLRequestJobFactoryImpl()); 152 new net::URLRequestJobFactoryImpl());
153 factory->SetProtocolHandler("http", new MockHttpServerJobFactory); 153 factory->SetProtocolHandler("http", new MockHttpServerJobFactory);
154 job_factory_ = factory.Pass(); 154 job_factory_ = factory.Pass();
155 request_context_.reset(new net::TestURLRequestContext()); 155 request_context_.reset(new net::TestURLRequestContext());
156 request_context_->set_job_factory(job_factory_.get()); 156 request_context_->set_job_factory(job_factory_.get());
157 AppCacheInterceptor::EnsureRegistered(); 157 AppCacheInterceptor::EnsureRegistered();
158 } 158 }
159 159
160 virtual void CleanUp() OVERRIDE { 160 virtual void CleanUp() override {
161 request_context_.reset(); 161 request_context_.reset();
162 job_factory_.reset(); 162 job_factory_.reset();
163 } 163 }
164 164
165 private: 165 private:
166 scoped_ptr<net::URLRequestJobFactory> job_factory_; 166 scoped_ptr<net::URLRequestJobFactory> job_factory_;
167 scoped_ptr<net::URLRequestContext> request_context_; 167 scoped_ptr<net::URLRequestContext> request_context_;
168 }; 168 };
169 169
170 scoped_ptr<IOThread> io_thread; 170 scoped_ptr<IOThread> io_thread;
171 scoped_ptr<base::Thread> db_thread; 171 scoped_ptr<base::Thread> db_thread;
172 172
173 } // namespace 173 } // namespace
174 174
175 class AppCacheStorageImplTest : public testing::Test { 175 class AppCacheStorageImplTest : public testing::Test {
176 public: 176 public:
177 class MockStorageDelegate : public AppCacheStorage::Delegate { 177 class MockStorageDelegate : public AppCacheStorage::Delegate {
178 public: 178 public:
179 explicit MockStorageDelegate(AppCacheStorageImplTest* test) 179 explicit MockStorageDelegate(AppCacheStorageImplTest* test)
180 : loaded_cache_id_(0), stored_group_success_(false), 180 : loaded_cache_id_(0), stored_group_success_(false),
181 would_exceed_quota_(false), obsoleted_success_(false), 181 would_exceed_quota_(false), obsoleted_success_(false),
182 found_cache_id_(kAppCacheNoCacheId), test_(test) { 182 found_cache_id_(kAppCacheNoCacheId), test_(test) {
183 } 183 }
184 184
185 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) OVERRIDE { 185 virtual void OnCacheLoaded(AppCache* cache, int64 cache_id) override {
186 loaded_cache_ = cache; 186 loaded_cache_ = cache;
187 loaded_cache_id_ = cache_id; 187 loaded_cache_id_ = cache_id;
188 test_->ScheduleNextTask(); 188 test_->ScheduleNextTask();
189 } 189 }
190 190
191 virtual void OnGroupLoaded(AppCacheGroup* group, 191 virtual void OnGroupLoaded(AppCacheGroup* group,
192 const GURL& manifest_url) OVERRIDE { 192 const GURL& manifest_url) override {
193 loaded_group_ = group; 193 loaded_group_ = group;
194 loaded_manifest_url_ = manifest_url; 194 loaded_manifest_url_ = manifest_url;
195 loaded_groups_newest_cache_ = group ? group->newest_complete_cache() 195 loaded_groups_newest_cache_ = group ? group->newest_complete_cache()
196 : NULL; 196 : NULL;
197 test_->ScheduleNextTask(); 197 test_->ScheduleNextTask();
198 } 198 }
199 199
200 virtual void OnGroupAndNewestCacheStored( 200 virtual void OnGroupAndNewestCacheStored(
201 AppCacheGroup* group, AppCache* newest_cache, bool success, 201 AppCacheGroup* group, AppCache* newest_cache, bool success,
202 bool would_exceed_quota) OVERRIDE { 202 bool would_exceed_quota) override {
203 stored_group_ = group; 203 stored_group_ = group;
204 stored_group_success_ = success; 204 stored_group_success_ = success;
205 would_exceed_quota_ = would_exceed_quota; 205 would_exceed_quota_ = would_exceed_quota;
206 test_->ScheduleNextTask(); 206 test_->ScheduleNextTask();
207 } 207 }
208 208
209 virtual void OnGroupMadeObsolete(AppCacheGroup* group, 209 virtual void OnGroupMadeObsolete(AppCacheGroup* group,
210 bool success, 210 bool success,
211 int response_code) OVERRIDE { 211 int response_code) override {
212 obsoleted_group_ = group; 212 obsoleted_group_ = group;
213 obsoleted_success_ = success; 213 obsoleted_success_ = success;
214 test_->ScheduleNextTask(); 214 test_->ScheduleNextTask();
215 } 215 }
216 216
217 virtual void OnMainResponseFound(const GURL& url, 217 virtual void OnMainResponseFound(const GURL& url,
218 const AppCacheEntry& entry, 218 const AppCacheEntry& entry,
219 const GURL& namespace_entry_url, 219 const GURL& namespace_entry_url,
220 const AppCacheEntry& fallback_entry, 220 const AppCacheEntry& fallback_entry,
221 int64 cache_id, 221 int64 cache_id,
222 int64 group_id, 222 int64 group_id,
223 const GURL& manifest_url) OVERRIDE { 223 const GURL& manifest_url) override {
224 found_url_ = url; 224 found_url_ = url;
225 found_entry_ = entry; 225 found_entry_ = entry;
226 found_namespace_entry_url_ = namespace_entry_url; 226 found_namespace_entry_url_ = namespace_entry_url;
227 found_fallback_entry_ = fallback_entry; 227 found_fallback_entry_ = fallback_entry;
228 found_cache_id_ = cache_id; 228 found_cache_id_ = cache_id;
229 found_group_id_ = group_id; 229 found_group_id_ = group_id;
230 found_manifest_url_ = manifest_url; 230 found_manifest_url_ = manifest_url;
231 test_->ScheduleNextTask(); 231 test_->ScheduleNextTask();
232 } 232 }
233 233
(...skipping 23 matching lines...) Expand all
257 : QuotaManager(true /* is_incognito */, 257 : QuotaManager(true /* is_incognito */,
258 base::FilePath(), 258 base::FilePath(),
259 io_thread->message_loop_proxy().get(), 259 io_thread->message_loop_proxy().get(),
260 db_thread->message_loop_proxy().get(), 260 db_thread->message_loop_proxy().get(),
261 NULL), 261 NULL),
262 async_(false) {} 262 async_(false) {}
263 263
264 virtual void GetUsageAndQuota( 264 virtual void GetUsageAndQuota(
265 const GURL& origin, 265 const GURL& origin,
266 storage::StorageType type, 266 storage::StorageType type,
267 const GetUsageAndQuotaCallback& callback) OVERRIDE { 267 const GetUsageAndQuotaCallback& callback) override {
268 EXPECT_EQ(storage::kStorageTypeTemporary, type); 268 EXPECT_EQ(storage::kStorageTypeTemporary, type);
269 if (async_) { 269 if (async_) {
270 base::MessageLoop::current()->PostTask( 270 base::MessageLoop::current()->PostTask(
271 FROM_HERE, 271 FROM_HERE,
272 base::Bind(&MockQuotaManager::CallCallback, 272 base::Bind(&MockQuotaManager::CallCallback,
273 base::Unretained(this), 273 base::Unretained(this),
274 callback)); 274 callback));
275 return; 275 return;
276 } 276 }
277 CallCallback(callback); 277 CallCallback(callback);
(...skipping 15 matching lines...) Expand all
293 : QuotaManagerProxy(NULL, NULL), 293 : QuotaManagerProxy(NULL, NULL),
294 notify_storage_accessed_count_(0), 294 notify_storage_accessed_count_(0),
295 notify_storage_modified_count_(0), 295 notify_storage_modified_count_(0),
296 last_delta_(0), 296 last_delta_(0),
297 mock_manager_(new MockQuotaManager) { 297 mock_manager_(new MockQuotaManager) {
298 manager_ = mock_manager_.get(); 298 manager_ = mock_manager_.get();
299 } 299 }
300 300
301 virtual void NotifyStorageAccessed(storage::QuotaClient::ID client_id, 301 virtual void NotifyStorageAccessed(storage::QuotaClient::ID client_id,
302 const GURL& origin, 302 const GURL& origin,
303 storage::StorageType type) OVERRIDE { 303 storage::StorageType type) override {
304 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id); 304 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id);
305 EXPECT_EQ(storage::kStorageTypeTemporary, type); 305 EXPECT_EQ(storage::kStorageTypeTemporary, type);
306 ++notify_storage_accessed_count_; 306 ++notify_storage_accessed_count_;
307 last_origin_ = origin; 307 last_origin_ = origin;
308 } 308 }
309 309
310 virtual void NotifyStorageModified(storage::QuotaClient::ID client_id, 310 virtual void NotifyStorageModified(storage::QuotaClient::ID client_id,
311 const GURL& origin, 311 const GURL& origin,
312 storage::StorageType type, 312 storage::StorageType type,
313 int64 delta) OVERRIDE { 313 int64 delta) override {
314 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id); 314 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id);
315 EXPECT_EQ(storage::kStorageTypeTemporary, type); 315 EXPECT_EQ(storage::kStorageTypeTemporary, type);
316 ++notify_storage_modified_count_; 316 ++notify_storage_modified_count_;
317 last_origin_ = origin; 317 last_origin_ = origin;
318 last_delta_ = delta; 318 last_delta_ = delta;
319 } 319 }
320 320
321 // Not needed for our tests. 321 // Not needed for our tests.
322 virtual void RegisterClient(storage::QuotaClient* client) OVERRIDE {} 322 virtual void RegisterClient(storage::QuotaClient* client) override {}
323 virtual void NotifyOriginInUse(const GURL& origin) OVERRIDE {} 323 virtual void NotifyOriginInUse(const GURL& origin) override {}
324 virtual void NotifyOriginNoLongerInUse(const GURL& origin) OVERRIDE {} 324 virtual void NotifyOriginNoLongerInUse(const GURL& origin) override {}
325 virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, 325 virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id,
326 const GURL& origin, 326 const GURL& origin,
327 storage::StorageType type, 327 storage::StorageType type,
328 bool enabled) OVERRIDE {} 328 bool enabled) override {}
329 virtual void GetUsageAndQuota( 329 virtual void GetUsageAndQuota(
330 base::SequencedTaskRunner* original_task_runner, 330 base::SequencedTaskRunner* original_task_runner,
331 const GURL& origin, 331 const GURL& origin,
332 storage::StorageType type, 332 storage::StorageType type,
333 const GetUsageAndQuotaCallback& callback) OVERRIDE {} 333 const GetUsageAndQuotaCallback& callback) override {}
334 334
335 int notify_storage_accessed_count_; 335 int notify_storage_accessed_count_;
336 int notify_storage_modified_count_; 336 int notify_storage_modified_count_;
337 GURL last_origin_; 337 GURL last_origin_;
338 int last_delta_; 338 int last_delta_;
339 scoped_refptr<MockQuotaManager> mock_manager_; 339 scoped_refptr<MockQuotaManager> mock_manager_;
340 340
341 protected: 341 protected:
342 virtual ~MockQuotaManagerProxy() {} 342 virtual ~MockQuotaManagerProxy() {}
343 }; 343 };
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 // They rely on running a mock http server on our IO thread, 1592 // They rely on running a mock http server on our IO thread,
1593 // and involves other appcache classes to get some code 1593 // and involves other appcache classes to get some code
1594 // coverage thruout when Reinitialize happens. 1594 // coverage thruout when Reinitialize happens.
1595 1595
1596 class MockServiceObserver : public AppCacheServiceImpl::Observer { 1596 class MockServiceObserver : public AppCacheServiceImpl::Observer {
1597 public: 1597 public:
1598 explicit MockServiceObserver(AppCacheStorageImplTest* test) 1598 explicit MockServiceObserver(AppCacheStorageImplTest* test)
1599 : test_(test) {} 1599 : test_(test) {}
1600 1600
1601 virtual void OnServiceReinitialized( 1601 virtual void OnServiceReinitialized(
1602 AppCacheStorageReference* old_storage_ref) OVERRIDE { 1602 AppCacheStorageReference* old_storage_ref) override {
1603 observed_old_storage_ = old_storage_ref; 1603 observed_old_storage_ = old_storage_ref;
1604 test_->ScheduleNextTask(); 1604 test_->ScheduleNextTask();
1605 } 1605 }
1606 1606
1607 scoped_refptr<AppCacheStorageReference> observed_old_storage_; 1607 scoped_refptr<AppCacheStorageReference> observed_old_storage_;
1608 AppCacheStorageImplTest* test_; 1608 AppCacheStorageImplTest* test_;
1609 }; 1609 };
1610 1610
1611 class MockAppCacheFrontend : public AppCacheFrontend { 1611 class MockAppCacheFrontend : public AppCacheFrontend {
1612 public: 1612 public:
1613 MockAppCacheFrontend() : error_event_was_raised_(false) {} 1613 MockAppCacheFrontend() : error_event_was_raised_(false) {}
1614 1614
1615 virtual void OnCacheSelected( 1615 virtual void OnCacheSelected(
1616 int host_id, const AppCacheInfo& info) OVERRIDE {} 1616 int host_id, const AppCacheInfo& info) override {}
1617 virtual void OnStatusChanged(const std::vector<int>& host_ids, 1617 virtual void OnStatusChanged(const std::vector<int>& host_ids,
1618 AppCacheStatus status) OVERRIDE {} 1618 AppCacheStatus status) override {}
1619 virtual void OnEventRaised(const std::vector<int>& host_ids, 1619 virtual void OnEventRaised(const std::vector<int>& host_ids,
1620 AppCacheEventID event_id) OVERRIDE {} 1620 AppCacheEventID event_id) override {}
1621 virtual void OnProgressEventRaised( 1621 virtual void OnProgressEventRaised(
1622 const std::vector<int>& host_ids, 1622 const std::vector<int>& host_ids,
1623 const GURL& url, 1623 const GURL& url,
1624 int num_total, int num_complete) OVERRIDE {} 1624 int num_total, int num_complete) override {}
1625 virtual void OnErrorEventRaised(const std::vector<int>& host_ids, 1625 virtual void OnErrorEventRaised(const std::vector<int>& host_ids,
1626 const AppCacheErrorDetails& details) 1626 const AppCacheErrorDetails& details)
1627 OVERRIDE { 1627 override {
1628 error_event_was_raised_ = true; 1628 error_event_was_raised_ = true;
1629 } 1629 }
1630 virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level, 1630 virtual void OnLogMessage(int host_id, AppCacheLogLevel log_level,
1631 const std::string& message) OVERRIDE {} 1631 const std::string& message) override {}
1632 virtual void OnContentBlocked( 1632 virtual void OnContentBlocked(
1633 int host_id, const GURL& manifest_url) OVERRIDE {} 1633 int host_id, const GURL& manifest_url) override {}
1634 1634
1635 bool error_event_was_raised_; 1635 bool error_event_was_raised_;
1636 }; 1636 };
1637 1637
1638 enum ReinitTestCase { 1638 enum ReinitTestCase {
1639 CORRUPT_CACHE_ON_INSTALL, 1639 CORRUPT_CACHE_ON_INSTALL,
1640 CORRUPT_CACHE_ON_LOAD_EXISTING, 1640 CORRUPT_CACHE_ON_LOAD_EXISTING,
1641 CORRUPT_SQL_ON_INSTALL 1641 CORRUPT_SQL_ON_INSTALL
1642 }; 1642 };
1643 1643
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2); 2016 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize2);
2017 } 2017 }
2018 2018
2019 TEST_F(AppCacheStorageImplTest, Reinitialize3) { 2019 TEST_F(AppCacheStorageImplTest, Reinitialize3) {
2020 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3); 2020 RunTestOnIOThread(&AppCacheStorageImplTest::Reinitialize3);
2021 } 2021 }
2022 2022
2023 // That's all folks! 2023 // That's all folks!
2024 2024
2025 } // namespace content 2025 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_storage_impl.cc ('k') | content/browser/appcache/appcache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698