| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/message_loop/message_loop_proxy.h" | |
| 16 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 17 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 18 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
| 18 #include "base/thread_task_runner_handle.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "content/public/test/mock_special_storage_policy.h" | 20 #include "content/public/test/mock_special_storage_policy.h" |
| 21 #include "content/public/test/mock_storage_client.h" | 21 #include "content/public/test/mock_storage_client.h" |
| 22 #include "storage/browser/quota/quota_database.h" | 22 #include "storage/browser/quota/quota_database.h" |
| 23 #include "storage/browser/quota/quota_manager.h" | 23 #include "storage/browser/quota/quota_manager.h" |
| 24 #include "storage/browser/quota/quota_manager_proxy.h" | 24 #include "storage/browser/quota/quota_manager_proxy.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 27 | 27 |
| 28 using base::MessageLoopProxy; | |
| 29 using storage::kQuotaErrorAbort; | 28 using storage::kQuotaErrorAbort; |
| 30 using storage::kQuotaErrorInvalidModification; | 29 using storage::kQuotaErrorInvalidModification; |
| 31 using storage::kQuotaErrorNotSupported; | 30 using storage::kQuotaErrorNotSupported; |
| 32 using storage::kQuotaStatusOk; | 31 using storage::kQuotaStatusOk; |
| 33 using storage::kQuotaStatusUnknown; | 32 using storage::kQuotaStatusUnknown; |
| 34 using storage::kStorageTypePersistent; | 33 using storage::kStorageTypePersistent; |
| 35 using storage::kStorageTypeSyncable; | 34 using storage::kStorageTypeSyncable; |
| 36 using storage::kStorageTypeTemporary; | 35 using storage::kStorageTypeTemporary; |
| 37 using storage::kStorageTypeUnknown; | 36 using storage::kStorageTypeUnknown; |
| 38 using storage::QuotaClient; | 37 using storage::QuotaClient; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 84 } |
| 86 | 85 |
| 87 void TearDown() override { | 86 void TearDown() override { |
| 88 // Make sure the quota manager cleans up correctly. | 87 // Make sure the quota manager cleans up correctly. |
| 89 quota_manager_ = NULL; | 88 quota_manager_ = NULL; |
| 90 base::RunLoop().RunUntilIdle(); | 89 base::RunLoop().RunUntilIdle(); |
| 91 } | 90 } |
| 92 | 91 |
| 93 protected: | 92 protected: |
| 94 void ResetQuotaManager(bool is_incognito) { | 93 void ResetQuotaManager(bool is_incognito) { |
| 95 quota_manager_ = new QuotaManager(is_incognito, | 94 quota_manager_ = new QuotaManager(is_incognito, data_dir_.path(), |
| 96 data_dir_.path(), | 95 base::ThreadTaskRunnerHandle::Get().get(), |
| 97 MessageLoopProxy::current().get(), | 96 base::ThreadTaskRunnerHandle::Get().get(), |
| 98 MessageLoopProxy::current().get(), | |
| 99 mock_special_storage_policy_.get()); | 97 mock_special_storage_policy_.get()); |
| 100 // Don't (automatically) start the eviction for testing. | 98 // Don't (automatically) start the eviction for testing. |
| 101 quota_manager_->eviction_disabled_ = true; | 99 quota_manager_->eviction_disabled_ = true; |
| 102 // Don't query the hard disk for remaining capacity. | 100 // Don't query the hard disk for remaining capacity. |
| 103 quota_manager_->get_disk_space_fn_ = &GetAvailableDiskSpaceForTest; | 101 quota_manager_->get_disk_space_fn_ = &GetAvailableDiskSpaceForTest; |
| 104 additional_callback_count_ = 0; | 102 additional_callback_count_ = 0; |
| 105 } | 103 } |
| 106 | 104 |
| 107 MockStorageClient* CreateClient( | 105 MockStorageClient* CreateClient( |
| 108 const MockOriginData* mock_data, | 106 const MockOriginData* mock_data, |
| (...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2177 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); |
| 2180 | 2178 |
| 2181 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2179 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| 2182 base::RunLoop().RunUntilIdle(); | 2180 base::RunLoop().RunUntilIdle(); |
| 2183 EXPECT_EQ(kQuotaStatusOk, status()); | 2181 EXPECT_EQ(kQuotaStatusOk, status()); |
| 2184 EXPECT_EQ(10, usage()); | 2182 EXPECT_EQ(10, usage()); |
| 2185 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2183 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); |
| 2186 } | 2184 } |
| 2187 | 2185 |
| 2188 } // namespace content | 2186 } // namespace content |
| OLD | NEW |