| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/browsing_data/mock_browsing_data_quota_helper.h" | 5 #include "chrome/browser/browsing_data/mock_browsing_data_quota_helper.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_thread.h" | 7 #include "content/public/browser/browser_thread.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 using content::BrowserThread; | 10 using content::BrowserThread; |
| 11 | 11 |
| 12 MockBrowsingDataQuotaHelper::MockBrowsingDataQuotaHelper(Profile* profile) | 12 MockBrowsingDataQuotaHelper::MockBrowsingDataQuotaHelper(Profile* profile) |
| 13 : BrowsingDataQuotaHelper() {} | 13 : BrowsingDataQuotaHelper() {} |
| 14 | 14 |
| 15 MockBrowsingDataQuotaHelper::~MockBrowsingDataQuotaHelper() {} | 15 MockBrowsingDataQuotaHelper::~MockBrowsingDataQuotaHelper() {} |
| 16 | 16 |
| 17 void MockBrowsingDataQuotaHelper::StartFetching( | 17 void MockBrowsingDataQuotaHelper::StartFetching( |
| 18 const FetchResultCallback& callback) { | 18 const FetchResultCallback& callback) { |
| 19 ASSERT_FALSE(callback.is_null()); | 19 ASSERT_FALSE(callback.is_null()); |
| 20 ASSERT_TRUE(callback_.is_null()); | 20 ASSERT_TRUE(callback_.is_null()); |
| 21 callback_ = callback; | 21 callback_ = callback; |
| 22 } | 22 } |
| 23 | 23 |
| 24 void MockBrowsingDataQuotaHelper::RevokeHostQuota(const std::string& host) { | 24 void MockBrowsingDataQuotaHelper::RevokeHostQuota(const std::string& host) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 void MockBrowsingDataQuotaHelper::AddHost( | 27 void MockBrowsingDataQuotaHelper::AddHost(const std::string& host, |
| 28 const std::string& host, | 28 int64_t temporary_usage, |
| 29 int64 temporary_usage, | 29 int64_t persistent_usage, |
| 30 int64 persistent_usage, | 30 int64_t syncable_usage) { |
| 31 int64 syncable_usage) { | |
| 32 response_.push_back(QuotaInfo( | 31 response_.push_back(QuotaInfo( |
| 33 host, | 32 host, |
| 34 temporary_usage, | 33 temporary_usage, |
| 35 persistent_usage, | 34 persistent_usage, |
| 36 syncable_usage)); | 35 syncable_usage)); |
| 37 } | 36 } |
| 38 | 37 |
| 39 void MockBrowsingDataQuotaHelper::AddQuotaSamples() { | 38 void MockBrowsingDataQuotaHelper::AddQuotaSamples() { |
| 40 AddHost("quotahost1", 1, 2, 1); | 39 AddHost("quotahost1", 1, 2, 1); |
| 41 AddHost("quotahost2", 10, 20, 10); | 40 AddHost("quotahost2", 10, 20, 10); |
| 42 } | 41 } |
| 43 | 42 |
| 44 void MockBrowsingDataQuotaHelper::Notify() { | 43 void MockBrowsingDataQuotaHelper::Notify() { |
| 45 callback_.Run(response_); | 44 callback_.Run(response_); |
| 46 callback_.Reset(); | 45 callback_.Reset(); |
| 47 response_.clear(); | 46 response_.clear(); |
| 48 } | 47 } |
| OLD | NEW |