Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1678)

Unified Diff: chrome/browser/browsing_data/cache_test_util.h

Issue 2556363003: Refactor cache counting into a separate helper class (Closed)
Patch Set: Remove code depending on GetEntrySize() Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_
« no previous file with comments | « chrome/browser/browsing_data/cache_counter_browsertest.cc ('k') | chrome/browser/browsing_data/cache_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698