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

Side by Side Diff: chrome/browser/sync/test/integration/extension_settings_helper.cc

Issue 1882243004: Convert //chrome/browser/sync from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback 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) 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 "chrome/browser/sync/test/integration/extension_settings_helper.h" 5 #include "chrome/browser/sync/test/integration/extension_settings_helper.h"
6 6
7 #include <memory>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sync/test/integration/extensions_helper.h" 15 #include "chrome/browser/sync/test/integration/extensions_helper.h"
15 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 16 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
16 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" 17 #include "chrome/browser/sync/test/integration/sync_extension_helper.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "extensions/browser/api/storage/storage_frontend.h" 19 #include "extensions/browser/api/storage/storage_frontend.h"
19 #include "extensions/browser/extension_registry.h" 20 #include "extensions/browser/extension_registry.h"
20 #include "extensions/browser/value_store/value_store.h" 21 #include "extensions/browser/value_store/value_store.h"
(...skipping 16 matching lines...) Expand all
37 } 38 }
38 39
39 void GetAllSettingsOnFileThread(base::DictionaryValue* out, 40 void GetAllSettingsOnFileThread(base::DictionaryValue* out,
40 base::WaitableEvent* signal, 41 base::WaitableEvent* signal,
41 ValueStore* storage) { 42 ValueStore* storage) {
42 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 43 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
43 out->Swap(&storage->Get()->settings()); 44 out->Swap(&storage->Get()->settings());
44 signal->Signal(); 45 signal->Signal();
45 } 46 }
46 47
47 scoped_ptr<base::DictionaryValue> GetAllSettings( 48 std::unique_ptr<base::DictionaryValue> GetAllSettings(Profile* profile,
48 Profile* profile, const std::string& id) { 49 const std::string& id) {
49 base::WaitableEvent signal(false, false); 50 base::WaitableEvent signal(false, false);
50 scoped_ptr<base::DictionaryValue> settings(new base::DictionaryValue()); 51 std::unique_ptr<base::DictionaryValue> settings(new base::DictionaryValue());
51 extensions::StorageFrontend::Get(profile)->RunWithStorage( 52 extensions::StorageFrontend::Get(profile)->RunWithStorage(
52 ExtensionRegistry::Get(profile)->enabled_extensions().GetByID(id), 53 ExtensionRegistry::Get(profile)->enabled_extensions().GetByID(id),
53 extensions::settings_namespace::SYNC, 54 extensions::settings_namespace::SYNC,
54 base::Bind(&GetAllSettingsOnFileThread, settings.get(), &signal)); 55 base::Bind(&GetAllSettingsOnFileThread, settings.get(), &signal));
55 signal.Wait(); 56 signal.Wait();
56 return settings; 57 return settings;
57 } 58 }
58 59
59 bool AreSettingsSame(Profile* expected_profile, Profile* actual_profile) { 60 bool AreSettingsSame(Profile* expected_profile, Profile* actual_profile) {
60 const extensions::ExtensionSet& extensions = 61 const extensions::ExtensionSet& extensions =
61 ExtensionRegistry::Get(expected_profile)->enabled_extensions(); 62 ExtensionRegistry::Get(expected_profile)->enabled_extensions();
62 if (extensions.size() != 63 if (extensions.size() !=
63 ExtensionRegistry::Get(actual_profile)->enabled_extensions().size()) { 64 ExtensionRegistry::Get(actual_profile)->enabled_extensions().size()) {
64 ADD_FAILURE(); 65 ADD_FAILURE();
65 return false; 66 return false;
66 } 67 }
67 68
68 bool same = true; 69 bool same = true;
69 for (extensions::ExtensionSet::const_iterator it = extensions.begin(); 70 for (extensions::ExtensionSet::const_iterator it = extensions.begin();
70 it != extensions.end(); 71 it != extensions.end();
71 ++it) { 72 ++it) {
72 const std::string& id = (*it)->id(); 73 const std::string& id = (*it)->id();
73 scoped_ptr<base::DictionaryValue> expected( 74 std::unique_ptr<base::DictionaryValue> expected(
74 GetAllSettings(expected_profile, id)); 75 GetAllSettings(expected_profile, id));
75 scoped_ptr<base::DictionaryValue> actual( 76 std::unique_ptr<base::DictionaryValue> actual(
76 GetAllSettings(actual_profile, id)); 77 GetAllSettings(actual_profile, id));
77 if (!expected->Equals(actual.get())) { 78 if (!expected->Equals(actual.get())) {
78 ADD_FAILURE() << 79 ADD_FAILURE() <<
79 "Expected " << ToJson(*expected) << " got " << ToJson(*actual); 80 "Expected " << ToJson(*expected) << " got " << ToJson(*actual);
80 same = false; 81 same = false;
81 } 82 }
82 } 83 }
83 return same; 84 return same;
84 } 85 }
85 86
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 bool all_profiles_same = true; 118 bool all_profiles_same = true;
118 for (int i = 0; i < test()->num_clients(); ++i) { 119 for (int i = 0; i < test()->num_clients(); ++i) {
119 // &= so that all profiles are tested; analogous to EXPECT over ASSERT. 120 // &= so that all profiles are tested; analogous to EXPECT over ASSERT.
120 all_profiles_same &= 121 all_profiles_same &=
121 AreSettingsSame(test()->verifier(), test()->GetProfile(i)); 122 AreSettingsSame(test()->verifier(), test()->GetProfile(i));
122 } 123 }
123 return all_profiles_same; 124 return all_profiles_same;
124 } 125 }
125 126
126 } // namespace extension_settings_helper 127 } // namespace extension_settings_helper
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/bookmarks_helper.cc ('k') | chrome/browser/sync/test/integration/preferences_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698