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

Side by Side Diff: net/disk_cache/disk_cache_test_util.h

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ 5 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_
6 #define NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ 6 #define NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "base/tuple.h" 13 #include "base/tuple.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 15
16 // Re-creates a given test file inside the cache test folder. 16 // Re-creates a given test file inside the cache test folder.
17 bool CreateCacheTestFile(const base::FilePath& name); 17 bool CreateCacheTestFile(const base::FilePath& name);
18 18
19 // Deletes all file son the cache. 19 // Deletes all file son the cache.
20 bool DeleteCache(const base::FilePath& path); 20 bool DeleteCache(const base::FilePath& path);
21 21
22 // Fills buffer with random values (may contain nulls unless no_nulls is true). 22 // Fills buffer with random values (may contain nulls unless no_nulls is true).
23 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls); 23 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls);
24 24
25 // Generates a random key of up to 200 bytes. 25 // Generates a random key of up to 200 bytes.
26 std::string GenerateKey(bool same_length); 26 std::string GenerateKey(bool same_length);
27 27
28 // Returns true if the cache is not corrupt. 28 // Returns true if the cache is not corrupt.
29 bool CheckCacheIntegrity(const base::FilePath& path, bool new_eviction, 29 bool CheckCacheIntegrity(const base::FilePath& path,
30 bool new_eviction,
30 uint32 mask); 31 uint32 mask);
31 32
32 // ----------------------------------------------------------------------- 33 // -----------------------------------------------------------------------
33 34
34 // Simple helper to deal with the message loop on a test. 35 // Simple helper to deal with the message loop on a test.
35 class MessageLoopHelper { 36 class MessageLoopHelper {
36 public: 37 public:
37 MessageLoopHelper(); 38 MessageLoopHelper();
38 ~MessageLoopHelper(); 39 ~MessageLoopHelper();
39 40
40 // Run the message loop and wait for num_callbacks before returning. Returns 41 // Run the message loop and wait for num_callbacks before returning. Returns
41 // false if we are waiting to long. Each callback that will be waited on is 42 // false if we are waiting to long. Each callback that will be waited on is
42 // required to call CallbackWasCalled() to indicate when it was called. 43 // required to call CallbackWasCalled() to indicate when it was called.
43 bool WaitUntilCacheIoFinished(int num_callbacks); 44 bool WaitUntilCacheIoFinished(int num_callbacks);
44 45
45 // True if a given callback was called more times than it expected. 46 // True if a given callback was called more times than it expected.
46 bool callback_reused_error() const { return callback_reused_error_; } 47 bool callback_reused_error() const { return callback_reused_error_; }
47 void set_callback_reused_error(bool error) { 48 void set_callback_reused_error(bool error) { callback_reused_error_ = error; }
48 callback_reused_error_ = error;
49 }
50 49
51 int callbacks_called() const { return callbacks_called_; } 50 int callbacks_called() const { return callbacks_called_; }
52 // Report that a callback was called. Each callback that will be waited on 51 // Report that a callback was called. Each callback that will be waited on
53 // via WaitUntilCacheIoFinished() is expected to call this method to 52 // via WaitUntilCacheIoFinished() is expected to call this method to
54 // indicate when it has been executed. 53 // indicate when it has been executed.
55 void CallbackWasCalled() { ++callbacks_called_; } 54 void CallbackWasCalled() { ++callbacks_called_; }
56 55
57 private: 56 private:
58 // Sets the number of callbacks that can be received so far. 57 // Sets the number of callbacks that can be received so far.
59 void ExpectCallbacks(int num_callbacks) { 58 void ExpectCallbacks(int num_callbacks) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 int last_result() const { return last_result_; } 95 int last_result() const { return last_result_; }
97 96
98 private: 97 private:
99 MessageLoopHelper* helper_; 98 MessageLoopHelper* helper_;
100 int reuse_; 99 int reuse_;
101 int last_result_; 100 int last_result_;
102 DISALLOW_COPY_AND_ASSIGN(CallbackTest); 101 DISALLOW_COPY_AND_ASSIGN(CallbackTest);
103 }; 102 };
104 103
105 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ 104 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698