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

Side by Side Diff: chrome/browser/android/history_report/delta_file_backend_leveldb.cc

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/android/history_report/delta_file_backend_leveldb.h" 5 #include "chrome/browser/android/history_report/delta_file_backend_leveldb.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (status.ok()) 189 if (status.ok())
190 return true; 190 return true;
191 LOG(WARNING) << "Recreate failed: " << status.ToString(); 191 LOG(WARNING) << "Recreate failed: " << status.ToString();
192 return false; 192 return false;
193 } 193 }
194 194
195 std::unique_ptr<std::vector<DeltaFileEntryWithData>> DeltaFileBackend::Query( 195 std::unique_ptr<std::vector<DeltaFileEntryWithData>> DeltaFileBackend::Query(
196 int64_t last_seq_no, 196 int64_t last_seq_no,
197 int32_t limit) { 197 int32_t limit) {
198 if (!EnsureInitialized()) 198 if (!EnsureInitialized())
199 return base::WrapUnique(new std::vector<DeltaFileEntryWithData>()); 199 return base::MakeUnique<std::vector<DeltaFileEntryWithData>>();
200 std::string start; 200 std::string start;
201 base::SStringPrintf(&start, "%" PRId64, last_seq_no + 1); 201 base::SStringPrintf(&start, "%" PRId64, last_seq_no + 1);
202 leveldb::ReadOptions options; 202 leveldb::ReadOptions options;
203 std::unique_ptr<leveldb::Iterator> db_it(db_->NewIterator(options)); 203 std::unique_ptr<leveldb::Iterator> db_it(db_->NewIterator(options));
204 std::unique_ptr<std::vector<DeltaFileEntryWithData>> result( 204 std::unique_ptr<std::vector<DeltaFileEntryWithData>> result(
205 new std::vector<DeltaFileEntryWithData>()); 205 new std::vector<DeltaFileEntryWithData>());
206 int32_t count = 0; 206 int32_t count = 0;
207 for (db_it->Seek(start); db_it->Valid() && count < limit; db_it->Next()) { 207 for (db_it->Seek(start); db_it->Valid() && count < limit; db_it->Next()) {
208 DeltaFileEntry entry; 208 DeltaFileEntry entry;
209 leveldb::Slice value_slice = db_it->value(); 209 leveldb::Slice value_slice = db_it->value();
(...skipping 22 matching lines...) Expand all
232 leveldb::ReadOptions options; 232 leveldb::ReadOptions options;
233 std::unique_ptr<leveldb::Iterator> db_it(db_->NewIterator(options)); 233 std::unique_ptr<leveldb::Iterator> db_it(db_->NewIterator(options));
234 int num_entries = 0; 234 int num_entries = 0;
235 for (db_it->SeekToFirst(); db_it->Valid(); db_it->Next()) num_entries++; 235 for (db_it->SeekToFirst(); db_it->Valid(); db_it->Next()) num_entries++;
236 dump.append(base::IntToString(num_entries)); 236 dump.append(base::IntToString(num_entries));
237 dump.append("]"); 237 dump.append("]");
238 return dump; 238 return dump;
239 } 239 }
240 240
241 } // namespace history_report 241 } // namespace history_report
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698