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

Side by Side Diff: net/disk_cache/cache_creator.cc

Issue 15203004: Disk cache: Reference CL for the implementation of file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: IndexTable review Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/block_files_unittest.cc ('k') | net/disk_cache/disk_cache_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/metrics/field_trial.h" 6 #include "base/metrics/field_trial.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "net/base/cache_type.h" 8 #include "net/base/cache_type.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/disk_cache/backend_impl.h" 10 #include "net/disk_cache/backend_impl.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 CacheCreator::~CacheCreator() { 78 CacheCreator::~CacheCreator() {
79 } 79 }
80 80
81 int CacheCreator::Run() { 81 int CacheCreator::Run() {
82 // TODO(gavinp,pasko): While simple backend development proceeds, we're only 82 // TODO(gavinp,pasko): While simple backend development proceeds, we're only
83 // testing it against net::DISK_CACHE. Turn it on for more cache types as 83 // testing it against net::DISK_CACHE. Turn it on for more cache types as
84 // appropriate. 84 // appropriate.
85 if (backend_type_ == net::CACHE_BACKEND_SIMPLE && type_ == net::DISK_CACHE) { 85 if (backend_type_ == net::CACHE_BACKEND_SIMPLE && type_ == net::DISK_CACHE) {
86 disk_cache::SimpleBackendImpl* simple_cache = 86 disk_cache::SimpleBackendImpl* simple_cache =
87 new disk_cache::SimpleBackendImpl(path_, max_bytes_, type_, thread_, 87 new disk_cache::SimpleBackendImpl(path_, max_bytes_, type_,
88 net_log_); 88 thread_.get(), net_log_);
89 created_cache_ = simple_cache; 89 created_cache_ = simple_cache;
90 return simple_cache->Init( 90 return simple_cache->Init(
91 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this))); 91 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this)));
92 } 92 }
93 DCHECK(backend_type_ == net::CACHE_BACKEND_BLOCKFILE ||
94 backend_type_ == net::CACHE_BACKEND_DEFAULT);
95 disk_cache::BackendImpl* new_cache = 93 disk_cache::BackendImpl* new_cache =
96 new disk_cache::BackendImpl(path_, thread_, net_log_); 94 new disk_cache::BackendImpl(path_, thread_.get(), net_log_);
97 created_cache_ = new_cache; 95 created_cache_ = new_cache;
98 new_cache->SetMaxSize(max_bytes_); 96 new_cache->SetMaxSize(max_bytes_);
99 new_cache->SetType(type_); 97 new_cache->SetType(type_);
100 new_cache->SetFlags(flags_); 98 new_cache->SetFlags(flags_);
101 int rv = new_cache->Init( 99 int rv = new_cache->Init(
102 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this))); 100 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this)));
103 DCHECK_EQ(net::ERR_IO_PENDING, rv); 101 DCHECK_EQ(net::ERR_IO_PENDING, rv);
104 return rv; 102 return rv;
105 } 103 }
106 104
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return *backend ? net::OK : net::ERR_FAILED; 156 return *backend ? net::OK : net::ERR_FAILED;
159 } 157 }
160 DCHECK(thread); 158 DCHECK(thread);
161 CacheCreator* creator = new CacheCreator(path, force, max_bytes, type, 159 CacheCreator* creator = new CacheCreator(path, force, max_bytes, type,
162 backend_type, kNone, 160 backend_type, kNone,
163 thread, net_log, backend, callback); 161 thread, net_log, backend, callback);
164 return creator->Run(); 162 return creator->Run();
165 } 163 }
166 164
167 } // namespace disk_cache 165 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/block_files_unittest.cc ('k') | net/disk_cache/disk_cache_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698