| OLD | NEW |
| 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 GURL found_url_; | 244 GURL found_url_; |
| 245 AppCacheEntry found_entry_; | 245 AppCacheEntry found_entry_; |
| 246 GURL found_namespace_entry_url_; | 246 GURL found_namespace_entry_url_; |
| 247 AppCacheEntry found_fallback_entry_; | 247 AppCacheEntry found_fallback_entry_; |
| 248 int64 found_cache_id_; | 248 int64 found_cache_id_; |
| 249 int64 found_group_id_; | 249 int64 found_group_id_; |
| 250 GURL found_manifest_url_; | 250 GURL found_manifest_url_; |
| 251 AppCacheStorageImplTest* test_; | 251 AppCacheStorageImplTest* test_; |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 class MockQuotaManager : public quota::QuotaManager { | 254 class MockQuotaManager : public storage::QuotaManager { |
| 255 public: | 255 public: |
| 256 MockQuotaManager() | 256 MockQuotaManager() |
| 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 quota::StorageType type, | 266 storage::StorageType type, |
| 267 const GetUsageAndQuotaCallback& callback) OVERRIDE { | 267 const GetUsageAndQuotaCallback& callback) OVERRIDE { |
| 268 EXPECT_EQ(quota::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); |
| 278 } | 278 } |
| 279 | 279 |
| 280 void CallCallback(const GetUsageAndQuotaCallback& callback) { | 280 void CallCallback(const GetUsageAndQuotaCallback& callback) { |
| 281 callback.Run(quota::kQuotaStatusOk, 0, kMockQuota); | 281 callback.Run(storage::kQuotaStatusOk, 0, kMockQuota); |
| 282 } | 282 } |
| 283 | 283 |
| 284 bool async_; | 284 bool async_; |
| 285 | 285 |
| 286 protected: | 286 protected: |
| 287 virtual ~MockQuotaManager() {} | 287 virtual ~MockQuotaManager() {} |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 class MockQuotaManagerProxy : public quota::QuotaManagerProxy { | 290 class MockQuotaManagerProxy : public storage::QuotaManagerProxy { |
| 291 public: | 291 public: |
| 292 MockQuotaManagerProxy() | 292 MockQuotaManagerProxy() |
| 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(quota::QuotaClient::ID client_id, | 301 virtual void NotifyStorageAccessed(storage::QuotaClient::ID client_id, |
| 302 const GURL& origin, | 302 const GURL& origin, |
| 303 quota::StorageType type) OVERRIDE { | 303 storage::StorageType type) OVERRIDE { |
| 304 EXPECT_EQ(quota::QuotaClient::kAppcache, client_id); | 304 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id); |
| 305 EXPECT_EQ(quota::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(quota::QuotaClient::ID client_id, | 310 virtual void NotifyStorageModified(storage::QuotaClient::ID client_id, |
| 311 const GURL& origin, | 311 const GURL& origin, |
| 312 quota::StorageType type, | 312 storage::StorageType type, |
| 313 int64 delta) OVERRIDE { | 313 int64 delta) OVERRIDE { |
| 314 EXPECT_EQ(quota::QuotaClient::kAppcache, client_id); | 314 EXPECT_EQ(storage::QuotaClient::kAppcache, client_id); |
| 315 EXPECT_EQ(quota::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(quota::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(quota::QuotaClient::ID client_id, | 325 virtual void SetUsageCacheEnabled(storage::QuotaClient::ID client_id, |
| 326 const GURL& origin, | 326 const GURL& origin, |
| 327 quota::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 quota::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() {} |
| (...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |