Chromium Code Reviews| Index: chrome/browser/browsing_data/cache_test_util.h |
| diff --git a/chrome/browser/browsing_data/cache_test_util.h b/chrome/browser/browsing_data/cache_test_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d4e1d20babc5c1e779d88b3273d19e24fa9fc0d6 |
| --- /dev/null |
| +++ b/chrome/browser/browsing_data/cache_test_util.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_BROWSING_DATA_CACHE_TEST_UTIL_H_ |
| +#define CHROME_BROWSER_BROWSING_DATA_CACHE_TEST_UTIL_H_ |
| + |
| +#include <set> |
| +#include <vector> |
| +#include "base/run_loop.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/storage_partition.h" |
| +#include "net/disk_cache/disk_cache.h" |
| + |
| +using content::BrowserThread; |
| + |
| +// A util class that can be used to create and retreive cache entries. |
| +class CacheTestUtil { |
| + public: |
| + explicit CacheTestUtil(content::StoragePartition* partition_); |
| + |
| + ~CacheTestUtil(); |
| + |
| + void SetUpOnMainThread(); |
| + void TearDownOnMainThread(); |
| + |
| + void CreateCacheEntries(const std::set<std::string>& keys); |
| + |
| + std::vector<std::string> GetEntryKeys(); |
| + |
| + content::StoragePartition* partition() { return partition_; } |
| + disk_cache::Backend* backend() { return backend_; } |
| + |
| + private: |
| + base::Callback<void(int)> done_callback_; |
| + |
| + content::StoragePartition* partition_; |
| + disk_cache::Backend* backend_ = nullptr; |
| + std::vector<disk_cache::Entry*> entries_; |
| + std::unique_ptr<disk_cache::Backend::Iterator> iterator_; |
| + |
| + disk_cache::Entry* current_entry_; |
| + std::vector<std::string> remaining_keys_; |
| + |
| + std::unique_ptr<base::RunLoop> run_loop_; |
| + int remaining_tasks_; |
| + |
| + void SetUpOnIOThread(); |
|
msramek
2016/12/20 01:02:59
Ordering: Methods before attributes (if you got in
dullweber
2016/12/21 10:29:19
Fixed here and in cache counter. I guess that was
|
| + void TearDownOnIOThread(); |
| + |
| + void CreateCacheEntriesOnIOThread(const std::set<std::string>& keys); |
| + |
| + void GetEntryKeysOnIOThread(); |
| + void GetNextKey(int error); |
| + |
| + void WaitForTasksOnIOThread(); |
| + void WaitForCompletion(int value); |
| + void SetNumberOfWaitedTasks(int count); |
| + |
| + void DoneCallback(int value); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_BROWSING_DATA_CACHE_TEST_UTIL_H_ |