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

Side by Side Diff: chrome/browser/browsing_data/cache_test_util.h

Issue 2556363003: Refactor cache counting into a separate helper class (Closed)
Patch Set: extract cache_test_util and fixes Created 4 years 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 unified diff | Download patch
OLDNEW
(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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698