| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/cache_storage/cache_storage_operation.h" | 5 #include "content/browser/cache_storage/cache_storage_operation.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 int callback_count_ = 0; | 32 int callback_count_ = 0; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 class CacheStorageOperationTest : public testing::Test { | 37 class CacheStorageOperationTest : public testing::Test { |
| 38 protected: | 38 protected: |
| 39 CacheStorageOperationTest() | 39 CacheStorageOperationTest() |
| 40 : mock_task_runner_(new base::TestMockTimeTaskRunner()) { | 40 : mock_task_runner_(new base::TestMockTimeTaskRunner()) { |
| 41 operation_ = base::MakeUnique<CacheStorageOperation>( | 41 operation_ = base::MakeUnique<CacheStorageOperation>( |
| 42 base::Bind(&TestTask::Run, base::Unretained(&task_)), | 42 base::BindOnce(&TestTask::Run, base::Unretained(&task_)), |
| 43 CacheStorageSchedulerClient::CLIENT_STORAGE, mock_task_runner_); | 43 CacheStorageSchedulerClient::CLIENT_STORAGE, mock_task_runner_); |
| 44 } | 44 } |
| 45 | 45 |
| 46 base::HistogramTester histogram_tester_; | 46 base::HistogramTester histogram_tester_; |
| 47 TestTask task_; | 47 TestTask task_; |
| 48 scoped_refptr<base::TestMockTimeTaskRunner> mock_task_runner_; | 48 scoped_refptr<base::TestMockTimeTaskRunner> mock_task_runner_; |
| 49 std::unique_ptr<CacheStorageOperation> operation_; | 49 std::unique_ptr<CacheStorageOperation> operation_; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 TEST_F(CacheStorageOperationTest, OperationFast) { | 52 TEST_F(CacheStorageOperationTest, OperationFast) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 78 | 78 |
| 79 // Finish the operation. | 79 // Finish the operation. |
| 80 operation_.reset(); | 80 operation_.reset(); |
| 81 mock_task_runner_->RunUntilIdle(); | 81 mock_task_runner_->RunUntilIdle(); |
| 82 EXPECT_EQ(1, task_.callback_count()); | 82 EXPECT_EQ(1, task_.callback_count()); |
| 83 histogram_tester_.ExpectTotalCount(kSlowOperation, 1); | 83 histogram_tester_.ExpectTotalCount(kSlowOperation, 1); |
| 84 histogram_tester_.ExpectBucketCount(kSlowOperation, true, 1); | 84 histogram_tester_.ExpectBucketCount(kSlowOperation, true, 1); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace content | 87 } // namespace content |
| OLD | NEW |