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

Side by Side Diff: content/browser/quota/storage_monitor_unittest.cc

Issue 2592793002: Revert of Change how the quota system computes the total poolsize for temporary storage (Closed)
Patch Set: Created 4 years 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 }; 61 };
62 62
63 // A mock quota manager for overriding GetUsageAndQuotaForWebApps(). 63 // A mock quota manager for overriding GetUsageAndQuotaForWebApps().
64 class UsageMockQuotaManager : public QuotaManager { 64 class UsageMockQuotaManager : public QuotaManager {
65 public: 65 public:
66 UsageMockQuotaManager(SpecialStoragePolicy* special_storage_policy) 66 UsageMockQuotaManager(SpecialStoragePolicy* special_storage_policy)
67 : QuotaManager(false, 67 : QuotaManager(false,
68 base::FilePath(), 68 base::FilePath(),
69 base::ThreadTaskRunnerHandle::Get().get(), 69 base::ThreadTaskRunnerHandle::Get().get(),
70 base::ThreadTaskRunnerHandle::Get().get(), 70 base::ThreadTaskRunnerHandle::Get().get(),
71 special_storage_policy, 71 special_storage_policy),
72 storage::GetQuotaSettingsFunc()),
73 callback_usage_(0), 72 callback_usage_(0),
74 callback_quota_(0), 73 callback_quota_(0),
75 callback_status_(kQuotaStatusOk), 74 callback_status_(kQuotaStatusOk),
76 initialized_(false) {} 75 initialized_(false) {}
77 76
78 void SetCallbackParams(int64_t usage, int64_t quota, QuotaStatusCode status) { 77 void SetCallbackParams(int64_t usage, int64_t quota, QuotaStatusCode status) {
79 initialized_ = true; 78 initialized_ = true;
80 callback_quota_ = quota; 79 callback_quota_ = quota;
81 callback_usage_ = usage; 80 callback_usage_ = usage;
82 callback_status_ = status; 81 callback_status_ = status;
83 } 82 }
84 83
85 void InvokeCallback() { 84 void InvokeCallback() {
86 delayed_callback_.Run(callback_status_, callback_usage_, callback_quota_); 85 delayed_callback_.Run(callback_status_, callback_usage_, callback_quota_);
87 } 86 }
88 87
89 void GetUsageAndQuotaForWebApps( 88 void GetUsageAndQuotaForWebApps(
90 const GURL& origin, 89 const GURL& origin,
91 StorageType type, 90 StorageType type,
92 const UsageAndQuotaCallback& callback) override { 91 const GetUsageAndQuotaCallback& callback) override {
93 if (initialized_) 92 if (initialized_)
94 callback.Run(callback_status_, callback_usage_, callback_quota_); 93 callback.Run(callback_status_, callback_usage_, callback_quota_);
95 else 94 else
96 delayed_callback_ = callback; 95 delayed_callback_ = callback;
97 } 96 }
98 97
99 protected: 98 protected:
100 ~UsageMockQuotaManager() override {} 99 ~UsageMockQuotaManager() override {}
101 100
102 private: 101 private:
103 int64_t callback_usage_; 102 int64_t callback_usage_;
104 int64_t callback_quota_; 103 int64_t callback_quota_;
105 QuotaStatusCode callback_status_; 104 QuotaStatusCode callback_status_;
106 bool initialized_; 105 bool initialized_;
107 UsageAndQuotaCallback delayed_callback_; 106 GetUsageAndQuotaCallback delayed_callback_;
108 }; 107 };
109 108
110 } // namespace 109 } // namespace
111 110
112 class StorageMonitorTestBase : public testing::Test { 111 class StorageMonitorTestBase : public testing::Test {
113 protected: 112 protected:
114 void DispatchPendingEvents(StorageObserverList& observer_list) { 113 void DispatchPendingEvents(StorageObserverList& observer_list) {
115 observer_list.DispatchPendingEvent(); 114 observer_list.DispatchPendingEvent();
116 } 115 }
117 116
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 642
644 // Integration test for QuotaManager and StorageMonitor: 643 // Integration test for QuotaManager and StorageMonitor:
645 644
646 class StorageMonitorIntegrationTest : public testing::Test { 645 class StorageMonitorIntegrationTest : public testing::Test {
647 public: 646 public:
648 void SetUp() override { 647 void SetUp() override {
649 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 648 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
650 storage_policy_ = new MockSpecialStoragePolicy(); 649 storage_policy_ = new MockSpecialStoragePolicy();
651 quota_manager_ = new QuotaManager( 650 quota_manager_ = new QuotaManager(
652 false, data_dir_.GetPath(), base::ThreadTaskRunnerHandle::Get().get(), 651 false, data_dir_.GetPath(), base::ThreadTaskRunnerHandle::Get().get(),
653 base::ThreadTaskRunnerHandle::Get().get(), storage_policy_.get(), 652 base::ThreadTaskRunnerHandle::Get().get(), storage_policy_.get());
654 storage::GetQuotaSettingsFunc());
655 653
656 client_ = new MockStorageClient(quota_manager_->proxy(), 654 client_ = new MockStorageClient(quota_manager_->proxy(),
657 NULL, 655 NULL,
658 QuotaClient::kFileSystem, 656 QuotaClient::kFileSystem,
659 0); 657 0);
660 658
661 quota_manager_->proxy()->RegisterClient(client_); 659 quota_manager_->proxy()->RegisterClient(client_);
662 } 660 }
663 661
664 void TearDown() override { 662 void TearDown() override {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 base::RunLoop().RunUntilIdle(); 694 base::RunLoop().RunUntilIdle();
697 695
698 // Verify that the observer receives it. 696 // Verify that the observer receives it.
699 ASSERT_EQ(1, mock_observer.EventCount()); 697 ASSERT_EQ(1, mock_observer.EventCount());
700 const StorageObserver::Event& event = mock_observer.LastEvent(); 698 const StorageObserver::Event& event = mock_observer.LastEvent();
701 EXPECT_EQ(params.filter, event.filter); 699 EXPECT_EQ(params.filter, event.filter);
702 EXPECT_EQ(kTestUsage, event.usage); 700 EXPECT_EQ(kTestUsage, event.usage);
703 } 701 }
704 702
705 } // namespace content 703 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/quota/quota_temporary_storage_evictor_unittest.cc ('k') | content/browser/storage_partition_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698