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

Unified Diff: net/disk_cache/cache_creator.cc

Issue 13517004: Test cache creation retry via public interface only. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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: net/disk_cache/cache_creator.cc
diff --git a/net/disk_cache/cache_creator.cc b/net/disk_cache/cache_creator.cc
index 718fc0dcf827eb0234e1caef4fd80b7ff1fff22c..c9add38bd3311c1645bd5ad06c5f8678453150ee 100644
--- a/net/disk_cache/cache_creator.cc
+++ b/net/disk_cache/cache_creator.cc
@@ -11,7 +11,43 @@
#include "net/disk_cache/mem_backend_impl.h"
#include "net/disk_cache/simple/simple_backend_impl.h"
-namespace disk_cache {
+namespace {
+
+// Builds an instance of the backend depending on platform, type, experiments
+// etc. Takes care of the retry state. This object will self-destroy when
+// finished.
+class CacheCreator {
+ public:
+ CacheCreator(const base::FilePath& path, bool force, int max_bytes,
+ net::CacheType type, uint32 flags,
+ base::MessageLoopProxy* thread, net::NetLog* net_log,
+ disk_cache::Backend** backend,
+ const net::CompletionCallback& callback);
+
+ // Creates the backend.
+ int Run();
+
+ private:
+ ~CacheCreator();
+
+ void DoCallback(int result);
+
+ void OnIOComplete(int result);
+
+ const base::FilePath& path_;
+ bool force_;
+ bool retry_;
+ int max_bytes_;
+ net::CacheType type_;
+ uint32 flags_;
+ scoped_refptr<base::MessageLoopProxy> thread_;
+ disk_cache::Backend** backend_;
+ net::CompletionCallback callback_;
+ disk_cache::Backend* created_cache_;
+ net::NetLog* net_log_;
+
+ DISALLOW_COPY_AND_ASSIGN(CacheCreator);
+};
CacheCreator::CacheCreator(
const base::FilePath& path, bool force, int max_bytes,
@@ -96,6 +132,10 @@ void CacheCreator::OnIOComplete(int result) {
DCHECK_EQ(net::ERR_IO_PENDING, rv);
}
+} // namespace
+
+namespace disk_cache {
+
int CreateCacheBackend(net::CacheType type, const base::FilePath& path,
int max_bytes,
bool force, base::MessageLoopProxy* thread,

Powered by Google App Engine
This is Rietveld 408576698