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..300e3a0da2ad4cf4ebb7883b24e5093e6bace02e |
--- /dev/null |
+++ b/chrome/browser/browsing_data/cache_test_util.h |
@@ -0,0 +1,60 @@ |
+// 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 CreateCacheEntries(const std::set<std::string>& keys); |
+ |
+ std::vector<std::string> GetEntryKeys(); |
+ |
+ content::StoragePartition* partition() { return partition_; } |
+ disk_cache::Backend* backend() { return backend_; } |
+ |
+ private: |
+ void SetUpOnIOThread(); |
+ 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); |
+ |
+ 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> keys_; |
+ |
+ std::unique_ptr<base::WaitableEvent> waitable_event_; |
+ int remaining_tasks_; |
+}; |
+ |
+#endif // CHROME_BROWSER_BROWSING_DATA_CACHE_TEST_UTIL_H_ |