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

Side by Side Diff: net/disk_cache/simple/simple_index_file.cc

Issue 1894733002: Change scoped_ptr to std::unique_ptr in //net/disk_cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "net/disk_cache/simple/simple_index_file.h" 5 #include "net/disk_cache/simple/simple_index_file.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return it->ReadUInt64(&magic_number_) && 182 return it->ReadUInt64(&magic_number_) &&
183 it->ReadUInt32(&version_) && 183 it->ReadUInt32(&version_) &&
184 it->ReadUInt64(&number_of_entries_)&& 184 it->ReadUInt64(&number_of_entries_)&&
185 it->ReadUInt64(&cache_size_); 185 it->ReadUInt64(&cache_size_);
186 } 186 }
187 187
188 void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type, 188 void SimpleIndexFile::SyncWriteToDisk(net::CacheType cache_type,
189 const base::FilePath& cache_directory, 189 const base::FilePath& cache_directory,
190 const base::FilePath& index_filename, 190 const base::FilePath& index_filename,
191 const base::FilePath& temp_index_filename, 191 const base::FilePath& temp_index_filename,
192 scoped_ptr<base::Pickle> pickle, 192 std::unique_ptr<base::Pickle> pickle,
193 const base::TimeTicks& start_time, 193 const base::TimeTicks& start_time,
194 bool app_on_background) { 194 bool app_on_background) {
195 DCHECK_EQ(index_filename.DirName().value(), 195 DCHECK_EQ(index_filename.DirName().value(),
196 temp_index_filename.DirName().value()); 196 temp_index_filename.DirName().value());
197 base::FilePath index_file_directory = temp_index_filename.DirName(); 197 base::FilePath index_file_directory = temp_index_filename.DirName();
198 if (!base::DirectoryExists(index_file_directory) && 198 if (!base::DirectoryExists(index_file_directory) &&
199 !base::CreateDirectory(index_file_directory)) { 199 !base::CreateDirectory(index_file_directory)) {
200 LOG(ERROR) << "Could not create a directory to hold the index file"; 200 LOG(ERROR) << "Could not create a directory to hold the index file";
201 return; 201 return;
202 } 202 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 index_file_, out_result); 267 index_file_, out_result);
268 worker_pool_->PostTaskAndReply(FROM_HERE, task, callback); 268 worker_pool_->PostTaskAndReply(FROM_HERE, task, callback);
269 } 269 }
270 270
271 void SimpleIndexFile::WriteToDisk(const SimpleIndex::EntrySet& entry_set, 271 void SimpleIndexFile::WriteToDisk(const SimpleIndex::EntrySet& entry_set,
272 uint64_t cache_size, 272 uint64_t cache_size,
273 const base::TimeTicks& start, 273 const base::TimeTicks& start,
274 bool app_on_background, 274 bool app_on_background,
275 const base::Closure& callback) { 275 const base::Closure& callback) {
276 IndexMetadata index_metadata(entry_set.size(), cache_size); 276 IndexMetadata index_metadata(entry_set.size(), cache_size);
277 scoped_ptr<base::Pickle> pickle = Serialize(index_metadata, entry_set); 277 std::unique_ptr<base::Pickle> pickle = Serialize(index_metadata, entry_set);
278 base::Closure task = 278 base::Closure task =
279 base::Bind(&SimpleIndexFile::SyncWriteToDisk, 279 base::Bind(&SimpleIndexFile::SyncWriteToDisk,
280 cache_type_, cache_directory_, index_file_, temp_index_file_, 280 cache_type_, cache_directory_, index_file_, temp_index_file_,
281 base::Passed(&pickle), start, app_on_background); 281 base::Passed(&pickle), start, app_on_background);
282 if (callback.is_null()) 282 if (callback.is_null())
283 cache_thread_->PostTask(FROM_HERE, task); 283 cache_thread_->PostTask(FROM_HERE, task);
284 else 284 else
285 cache_thread_->PostTaskAndReply(FROM_HERE, task, callback); 285 cache_thread_->PostTaskAndReply(FROM_HERE, task, callback);
286 } 286 }
287 287
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 reinterpret_cast<const char*>(index_file_map.data()), 358 reinterpret_cast<const char*>(index_file_map.data()),
359 index_file_map.length(), 359 index_file_map.length(),
360 out_last_cache_seen_by_index, 360 out_last_cache_seen_by_index,
361 out_result); 361 out_result);
362 362
363 if (!out_result->did_load) 363 if (!out_result->did_load)
364 simple_util::SimpleCacheDeleteFile(index_filename); 364 simple_util::SimpleCacheDeleteFile(index_filename);
365 } 365 }
366 366
367 // static 367 // static
368 scoped_ptr<base::Pickle> SimpleIndexFile::Serialize( 368 std::unique_ptr<base::Pickle> SimpleIndexFile::Serialize(
369 const SimpleIndexFile::IndexMetadata& index_metadata, 369 const SimpleIndexFile::IndexMetadata& index_metadata,
370 const SimpleIndex::EntrySet& entries) { 370 const SimpleIndex::EntrySet& entries) {
371 scoped_ptr<base::Pickle> pickle( 371 std::unique_ptr<base::Pickle> pickle(
372 new base::Pickle(sizeof(SimpleIndexFile::PickleHeader))); 372 new base::Pickle(sizeof(SimpleIndexFile::PickleHeader)));
373 373
374 index_metadata.Serialize(pickle.get()); 374 index_metadata.Serialize(pickle.get());
375 for (SimpleIndex::EntrySet::const_iterator it = entries.begin(); 375 for (SimpleIndex::EntrySet::const_iterator it = entries.begin();
376 it != entries.end(); ++it) { 376 it != entries.end(); ++it) {
377 pickle->WriteUInt64(it->first); 377 pickle->WriteUInt64(it->first);
378 it->second.Serialize(pickle.get()); 378 it->second.Serialize(pickle.get());
379 } 379 }
380 return pickle; 380 return pickle;
381 } 381 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 bool SimpleIndexFile::LegacyIsIndexFileStale( 467 bool SimpleIndexFile::LegacyIsIndexFileStale(
468 base::Time cache_last_modified, 468 base::Time cache_last_modified,
469 const base::FilePath& index_file_path) { 469 const base::FilePath& index_file_path) {
470 base::Time index_mtime; 470 base::Time index_mtime;
471 if (!simple_util::GetMTime(index_file_path, &index_mtime)) 471 if (!simple_util::GetMTime(index_file_path, &index_mtime))
472 return true; 472 return true;
473 return index_mtime < cache_last_modified; 473 return index_mtime < cache_last_modified;
474 } 474 }
475 475
476 } // namespace disk_cache 476 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_index_file.h ('k') | net/disk_cache/simple/simple_index_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698