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

Side by Side Diff: net/disk_cache/simple/simple_index_file_unittest.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
6
7 #include <memory>
8
5 #include "base/files/file.h" 9 #include "base/files/file.h"
6 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
8 #include "base/hash.h" 12 #include "base/hash.h"
9 #include "base/location.h" 13 #include "base/location.h"
10 #include "base/logging.h" 14 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/pickle.h" 15 #include "base/pickle.h"
13 #include "base/run_loop.h" 16 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
15 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
16 #include "base/thread_task_runner_handle.h" 19 #include "base/thread_task_runner_handle.h"
17 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
18 #include "base/time/time.h" 21 #include "base/time/time.h"
19 #include "net/base/cache_type.h" 22 #include "net/base/cache_type.h"
20 #include "net/base/test_completion_callback.h" 23 #include "net/base/test_completion_callback.h"
21 #include "net/disk_cache/disk_cache_test_util.h" 24 #include "net/disk_cache/disk_cache_test_util.h"
22 #include "net/disk_cache/simple/simple_backend_impl.h" 25 #include "net/disk_cache/simple/simple_backend_impl.h"
23 #include "net/disk_cache/simple/simple_backend_version.h" 26 #include "net/disk_cache/simple/simple_backend_version.h"
24 #include "net/disk_cache/simple/simple_entry_format.h" 27 #include "net/disk_cache/simple/simple_entry_format.h"
25 #include "net/disk_cache/simple/simple_index.h" 28 #include "net/disk_cache/simple/simple_index.h"
26 #include "net/disk_cache/simple/simple_index_file.h"
27 #include "net/disk_cache/simple/simple_util.h" 29 #include "net/disk_cache/simple/simple_util.h"
28 #include "net/disk_cache/simple/simple_version_upgrade.h" 30 #include "net/disk_cache/simple/simple_version_upgrade.h"
29 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
30 32
31 using base::Time; 33 using base::Time;
32 using disk_cache::SimpleIndexFile; 34 using disk_cache::SimpleIndexFile;
33 using disk_cache::SimpleIndex; 35 using disk_cache::SimpleIndex;
34 36
35 namespace disk_cache { 37 namespace disk_cache {
36 38
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 EntryMetadata metadata_entries[kNumHashes]; 115 EntryMetadata metadata_entries[kNumHashes];
114 116
115 SimpleIndexFile::IndexMetadata index_metadata( 117 SimpleIndexFile::IndexMetadata index_metadata(
116 static_cast<uint64_t>(kNumHashes), 456); 118 static_cast<uint64_t>(kNumHashes), 456);
117 for (size_t i = 0; i < kNumHashes; ++i) { 119 for (size_t i = 0; i < kNumHashes; ++i) {
118 uint64_t hash = kHashes[i]; 120 uint64_t hash = kHashes[i];
119 metadata_entries[i] = EntryMetadata(Time(), hash); 121 metadata_entries[i] = EntryMetadata(Time(), hash);
120 SimpleIndex::InsertInEntrySet(hash, metadata_entries[i], &entries); 122 SimpleIndex::InsertInEntrySet(hash, metadata_entries[i], &entries);
121 } 123 }
122 124
123 scoped_ptr<base::Pickle> pickle = 125 std::unique_ptr<base::Pickle> pickle =
124 WrappedSimpleIndexFile::Serialize(index_metadata, entries); 126 WrappedSimpleIndexFile::Serialize(index_metadata, entries);
125 EXPECT_TRUE(pickle.get() != NULL); 127 EXPECT_TRUE(pickle.get() != NULL);
126 base::Time now = base::Time::Now(); 128 base::Time now = base::Time::Now();
127 EXPECT_TRUE(WrappedSimpleIndexFile::SerializeFinalData(now, pickle.get())); 129 EXPECT_TRUE(WrappedSimpleIndexFile::SerializeFinalData(now, pickle.get()));
128 base::Time when_index_last_saw_cache; 130 base::Time when_index_last_saw_cache;
129 SimpleIndexLoadResult deserialize_result; 131 SimpleIndexLoadResult deserialize_result;
130 WrappedSimpleIndexFile::Deserialize(static_cast<const char*>(pickle->data()), 132 WrappedSimpleIndexFile::Deserialize(static_cast<const char*>(pickle->data()),
131 pickle->size(), 133 pickle->size(),
132 &when_index_last_saw_cache, 134 &when_index_last_saw_cache,
133 &deserialize_result); 135 &deserialize_result);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 closure.WaitForResult(); 341 closure.WaitForResult();
340 342
341 // Check that the temporary file was deleted and the index file was created. 343 // Check that the temporary file was deleted and the index file was created.
342 EXPECT_FALSE(base::PathExists(simple_index_file.GetTempIndexFilePath())); 344 EXPECT_FALSE(base::PathExists(simple_index_file.GetTempIndexFilePath()));
343 EXPECT_TRUE(base::PathExists(simple_index_file.GetIndexFilePath())); 345 EXPECT_TRUE(base::PathExists(simple_index_file.GetIndexFilePath()));
344 } 346 }
345 347
346 #endif // defined(OS_POSIX) 348 #endif // defined(OS_POSIX)
347 349
348 } // namespace disk_cache 350 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_index_file_posix.cc ('k') | net/disk_cache/simple/simple_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698