Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_BROWSING_DATA_CACHE_TEST_UTIL_H_ | |
| 6 #define CHROME_BROWSER_BROWSING_DATA_CACHE_TEST_UTIL_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <vector> | |
| 10 #include "base/run_loop.h" | |
| 11 #include "content/public/browser/browser_thread.h" | |
| 12 #include "content/public/browser/storage_partition.h" | |
| 13 #include "net/disk_cache/disk_cache.h" | |
| 14 | |
| 15 using content::BrowserThread; | |
| 16 | |
| 17 // A util class that can be used to create and retreive cache entries. | |
| 18 class CacheTestUtil { | |
| 19 public: | |
| 20 explicit CacheTestUtil(content::StoragePartition* partition_); | |
| 21 | |
| 22 ~CacheTestUtil(); | |
| 23 | |
| 24 void SetUpOnMainThread(); | |
| 25 void TearDownOnMainThread(); | |
| 26 | |
| 27 void CreateCacheEntries(const std::set<std::string>& keys); | |
| 28 | |
| 29 std::vector<std::string> GetEntryKeys(); | |
| 30 | |
| 31 content::StoragePartition* partition() { return partition_; } | |
| 32 disk_cache::Backend* backend() { return backend_; } | |
| 33 | |
| 34 private: | |
| 35 base::Callback<void(int)> done_callback_; | |
| 36 | |
| 37 content::StoragePartition* partition_; | |
| 38 disk_cache::Backend* backend_ = nullptr; | |
| 39 std::vector<disk_cache::Entry*> entries_; | |
| 40 std::unique_ptr<disk_cache::Backend::Iterator> iterator_; | |
| 41 | |
| 42 disk_cache::Entry* current_entry_; | |
| 43 std::vector<std::string> remaining_keys_; | |
| 44 | |
| 45 std::unique_ptr<base::RunLoop> run_loop_; | |
| 46 int remaining_tasks_; | |
| 47 | |
| 48 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
| |
| 49 void TearDownOnIOThread(); | |
| 50 | |
| 51 void CreateCacheEntriesOnIOThread(const std::set<std::string>& keys); | |
| 52 | |
| 53 void GetEntryKeysOnIOThread(); | |
| 54 void GetNextKey(int error); | |
| 55 | |
| 56 void WaitForTasksOnIOThread(); | |
| 57 void WaitForCompletion(int value); | |
| 58 void SetNumberOfWaitedTasks(int count); | |
| 59 | |
| 60 void DoneCallback(int value); | |
| 61 }; | |
| 62 | |
| 63 #endif // CHROME_BROWSER_BROWSING_DATA_CACHE_TEST_UTIL_H_ | |
| OLD | NEW |