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" |
15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
17 #include "base/sys_info.h" | 18 #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; |
28 using storage::kQuotaErrorAbort; | 29 using storage::kQuotaErrorAbort; |
29 using storage::kQuotaErrorInvalidModification; | 30 using storage::kQuotaErrorInvalidModification; |
30 using storage::kQuotaErrorNotSupported; | 31 using storage::kQuotaErrorNotSupported; |
31 using storage::kQuotaStatusOk; | 32 using storage::kQuotaStatusOk; |
32 using storage::kQuotaStatusUnknown; | 33 using storage::kQuotaStatusUnknown; |
33 using storage::kStorageTypePersistent; | 34 using storage::kStorageTypePersistent; |
34 using storage::kStorageTypeSyncable; | 35 using storage::kStorageTypeSyncable; |
35 using storage::kStorageTypeTemporary; | 36 using storage::kStorageTypeTemporary; |
36 using storage::kStorageTypeUnknown; | 37 using storage::kStorageTypeUnknown; |
37 using storage::QuotaClient; | 38 using storage::QuotaClient; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 85 } |
85 | 86 |
86 void TearDown() override { | 87 void TearDown() override { |
87 // Make sure the quota manager cleans up correctly. | 88 // Make sure the quota manager cleans up correctly. |
88 quota_manager_ = NULL; | 89 quota_manager_ = NULL; |
89 base::RunLoop().RunUntilIdle(); | 90 base::RunLoop().RunUntilIdle(); |
90 } | 91 } |
91 | 92 |
92 protected: | 93 protected: |
93 void ResetQuotaManager(bool is_incognito) { | 94 void ResetQuotaManager(bool is_incognito) { |
94 quota_manager_ = new QuotaManager(is_incognito, data_dir_.path(), | 95 quota_manager_ = new QuotaManager(is_incognito, |
95 base::ThreadTaskRunnerHandle::Get().get(), | 96 data_dir_.path(), |
96 base::ThreadTaskRunnerHandle::Get().get(), | 97 MessageLoopProxy::current().get(), |
| 98 MessageLoopProxy::current().get(), |
97 mock_special_storage_policy_.get()); | 99 mock_special_storage_policy_.get()); |
98 // Don't (automatically) start the eviction for testing. | 100 // Don't (automatically) start the eviction for testing. |
99 quota_manager_->eviction_disabled_ = true; | 101 quota_manager_->eviction_disabled_ = true; |
100 // Don't query the hard disk for remaining capacity. | 102 // Don't query the hard disk for remaining capacity. |
101 quota_manager_->get_disk_space_fn_ = &GetAvailableDiskSpaceForTest; | 103 quota_manager_->get_disk_space_fn_ = &GetAvailableDiskSpaceForTest; |
102 additional_callback_count_ = 0; | 104 additional_callback_count_ = 0; |
103 } | 105 } |
104 | 106 |
105 MockStorageClient* CreateClient( | 107 MockStorageClient* CreateClient( |
106 const MockOriginData* mock_data, | 108 const MockOriginData* mock_data, |
(...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2179 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); |
2178 | 2180 |
2179 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2181 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
2180 base::RunLoop().RunUntilIdle(); | 2182 base::RunLoop().RunUntilIdle(); |
2181 EXPECT_EQ(kQuotaStatusOk, status()); | 2183 EXPECT_EQ(kQuotaStatusOk, status()); |
2182 EXPECT_EQ(10, usage()); | 2184 EXPECT_EQ(10, usage()); |
2183 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2185 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); |
2184 } | 2186 } |
2185 | 2187 |
2186 } // namespace content | 2188 } // namespace content |
OLD | NEW |