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 #include "base/files/file_path.h" | 5 #include "base/files/file_path.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 Loading... |
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( |
88 net_log_); | 88 path_, max_bytes_, type_, 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 disk_cache::BackendImpl* new_cache = | 93 disk_cache::BackendImpl* new_cache = |
94 new disk_cache::BackendImpl(path_, thread_, net_log_); | 94 new disk_cache::BackendImpl(path_, thread_.get(), net_log_); |
95 created_cache_ = new_cache; | 95 created_cache_ = new_cache; |
96 new_cache->SetMaxSize(max_bytes_); | 96 new_cache->SetMaxSize(max_bytes_); |
97 new_cache->SetType(type_); | 97 new_cache->SetType(type_); |
98 new_cache->SetFlags(flags_); | 98 new_cache->SetFlags(flags_); |
99 int rv = new_cache->Init( | 99 int rv = new_cache->Init( |
100 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this))); | 100 base::Bind(&CacheCreator::OnIOComplete, base::Unretained(this))); |
101 DCHECK_EQ(net::ERR_IO_PENDING, rv); | 101 DCHECK_EQ(net::ERR_IO_PENDING, rv); |
102 return rv; | 102 return rv; |
103 } | 103 } |
104 | 104 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return *backend ? net::OK : net::ERR_FAILED; | 156 return *backend ? net::OK : net::ERR_FAILED; |
157 } | 157 } |
158 DCHECK(thread); | 158 DCHECK(thread); |
159 CacheCreator* creator = new CacheCreator(path, force, max_bytes, type, | 159 CacheCreator* creator = new CacheCreator(path, force, max_bytes, type, |
160 backend_type, kNone, | 160 backend_type, kNone, |
161 thread, net_log, backend, callback); | 161 thread, net_log, backend, callback); |
162 return creator->Run(); | 162 return creator->Run(); |
163 } | 163 } |
164 | 164 |
165 } // namespace disk_cache | 165 } // namespace disk_cache |
OLD | NEW |