| OLD | NEW |
| 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.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/timer.h" | 12 #include "base/timer.h" |
| 13 #include "base/tuple.h" | 13 #include "base/tuple.h" |
| 14 #include "net/base/completion_callback.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 | 16 |
| 16 // Re-creates a given test file inside the cache test folder. | 17 // Re-creates a given test file inside the cache test folder. |
| 17 bool CreateCacheTestFile(const base::FilePath& name); | 18 bool CreateCacheTestFile(const base::FilePath& name); |
| 18 | 19 |
| 19 // Deletes all file son the cache. | 20 // Deletes all file son the cache. |
| 20 bool DeleteCache(const base::FilePath& path); | 21 bool DeleteCache(const base::FilePath& path); |
| 21 | 22 |
| 22 // Fills buffer with random values (may contain nulls unless no_nulls is true). | 23 // Fills buffer with random values (may contain nulls unless no_nulls is true). |
| 23 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls); | 24 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 public: | 87 public: |
| 87 // Creates a new CallbackTest object. When the callback is called, it will | 88 // Creates a new CallbackTest object. When the callback is called, it will |
| 88 // update |helper|. If |reuse| is false and a callback is called more than | 89 // update |helper|. If |reuse| is false and a callback is called more than |
| 89 // once, or if |reuse| is true and a callback is called more than twice, an | 90 // once, or if |reuse| is true and a callback is called more than twice, an |
| 90 // error will be reported to |helper|. | 91 // error will be reported to |helper|. |
| 91 CallbackTest(MessageLoopHelper* helper, bool reuse); | 92 CallbackTest(MessageLoopHelper* helper, bool reuse); |
| 92 ~CallbackTest(); | 93 ~CallbackTest(); |
| 93 | 94 |
| 94 void Run(int result); | 95 void Run(int result); |
| 95 | 96 |
| 97 const net::CompletionCallback& callback() const { return callback_; } |
| 98 |
| 96 int last_result() const { return last_result_; } | 99 int last_result() const { return last_result_; } |
| 97 | 100 |
| 98 private: | 101 private: |
| 102 net::CompletionCallback callback_; |
| 99 MessageLoopHelper* helper_; | 103 MessageLoopHelper* helper_; |
| 100 int reuse_; | 104 int reuse_; |
| 101 int last_result_; | 105 int last_result_; |
| 102 DISALLOW_COPY_AND_ASSIGN(CallbackTest); | 106 DISALLOW_COPY_AND_ASSIGN(CallbackTest); |
| 103 }; | 107 }; |
| 104 | 108 |
| 105 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ | 109 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ |
| OLD | NEW |