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

Side by Side Diff: components/sync/syncable/test_user_share.cc

Issue 2422253002: [Sync] Rewriting ".reset(new" pattern to use "= base::MakeUnique" instead. (Closed)
Patch Set: Fixing compile. Created 4 years, 2 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/sync/syncable/test_user_share.h" 5 #include "components/sync/syncable/test_user_share.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/ptr_util.h"
8 #include "components/sync/syncable/directory.h" 9 #include "components/sync/syncable/directory.h"
9 #include "components/sync/syncable/mutable_entry.h" 10 #include "components/sync/syncable/mutable_entry.h"
10 #include "components/sync/syncable/syncable_read_transaction.h" 11 #include "components/sync/syncable/syncable_read_transaction.h"
11 #include "components/sync/syncable/syncable_write_transaction.h" 12 #include "components/sync/syncable/syncable_write_transaction.h"
12 #include "components/sync/test/engine/test_directory_setter_upper.h" 13 #include "components/sync/test/engine/test_directory_setter_upper.h"
13 #include "components/sync/test/engine/test_id_factory.h" 14 #include "components/sync/test/engine/test_id_factory.h"
14 #include "components/sync/test/engine/test_syncable_utils.h" 15 #include "components/sync/test/engine/test_syncable_utils.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 namespace syncer { 18 namespace syncer {
18 19
19 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {} 20 TestUserShare::TestUserShare() : dir_maker_(new TestDirectorySetterUpper()) {}
20 21
21 TestUserShare::~TestUserShare() { 22 TestUserShare::~TestUserShare() {
22 if (user_share_) 23 if (user_share_)
23 ADD_FAILURE() << "Should have called TestUserShare::TearDown()"; 24 ADD_FAILURE() << "Should have called TestUserShare::TearDown()";
24 } 25 }
25 26
26 void TestUserShare::SetUp() { 27 void TestUserShare::SetUp() {
27 user_share_.reset(new UserShare()); 28 user_share_ = base::MakeUnique<UserShare>();
28 dir_maker_->SetUp(); 29 dir_maker_->SetUp();
29 30
30 // The pointer is owned by dir_maker_, we should not be storing it in a 31 // The pointer is owned by dir_maker_, we should not be storing it in a
31 // unique_ptr. We must be careful to ensure the unique_ptr never deletes it. 32 // unique_ptr. We must be careful to ensure the unique_ptr never deletes it.
32 user_share_->directory.reset(dir_maker_->directory()); 33 user_share_->directory.reset(dir_maker_->directory());
33 } 34 }
34 35
35 void TestUserShare::TearDown() { 36 void TestUserShare::TearDown() {
36 // Ensure the unique_ptr doesn't delete the memory we don't own. 37 // Ensure the unique_ptr doesn't delete the memory we don't own.
37 ignore_result(user_share_->directory.release()); 38 ignore_result(user_share_->directory.release());
38 39
39 user_share_.reset(); 40 user_share_.reset();
40 dir_maker_->TearDown(); 41 dir_maker_->TearDown();
41 } 42 }
42 43
43 bool TestUserShare::Reload() { 44 bool TestUserShare::Reload() {
44 if (!user_share_->directory->SaveChanges()) 45 if (!user_share_->directory->SaveChanges())
45 return false; 46 return false;
46 47
47 syncable::DirectoryBackingStore* saved_store = 48 syncable::DirectoryBackingStore* saved_store =
48 user_share_->directory->store_.release(); 49 user_share_->directory->store_.release();
49 50
50 // Ensure the unique_ptr doesn't delete the memory we don't own. 51 // Ensure the unique_ptr doesn't delete the memory we don't own.
51 ignore_result(user_share_->directory.release()); 52 ignore_result(user_share_->directory.release());
52 user_share_.reset(new UserShare()); 53 user_share_ = base::MakeUnique<UserShare>();
53 dir_maker_->SetUpWith(saved_store); 54 dir_maker_->SetUpWith(saved_store);
54 user_share_->directory.reset(dir_maker_->directory()); 55 user_share_->directory.reset(dir_maker_->directory());
55 return true; 56 return true;
56 } 57 }
57 58
58 UserShare* TestUserShare::user_share() { 59 UserShare* TestUserShare::user_share() {
59 return user_share_.get(); 60 return user_share_.get();
60 } 61 }
61 62
62 SyncEncryptionHandler* TestUserShare::encryption_handler() { 63 SyncEncryptionHandler* TestUserShare::encryption_handler() {
(...skipping 11 matching lines...) Expand all
74 CreateTypeRoot(&wtrans, directory, model_type); 75 CreateTypeRoot(&wtrans, directory, model_type);
75 return true; 76 return true;
76 } 77 }
77 78
78 size_t TestUserShare::GetDeleteJournalSize() const { 79 size_t TestUserShare::GetDeleteJournalSize() const {
79 syncable::ReadTransaction trans(FROM_HERE, user_share_->directory.get()); 80 syncable::ReadTransaction trans(FROM_HERE, user_share_->directory.get());
80 return user_share_->directory->delete_journal()->GetDeleteJournalSize(&trans); 81 return user_share_->directory->delete_journal()->GetDeleteJournalSize(&trans);
81 } 82 }
82 83
83 } // namespace syncer 84 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/syncable_unittest.cc ('k') | components/sync/test/engine/test_directory_setter_upper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698