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

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

Issue 1113493004: Cleanup return values in autofill_sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/sync/test/integration/autofill_helper.h" 7 #include "chrome/browser/sync/test/integration/autofill_helper.h"
8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 8 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
9 #include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h" 9 #include "chrome/browser/sync/test/integration/performance/sync_timing_helper.h"
10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 10 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 void UpdateProfiles(int profile); 48 void UpdateProfiles(int profile);
49 49
50 // Removes all autofill profiles from |profile|. 50 // Removes all autofill profiles from |profile|.
51 void RemoveProfiles(int profile); 51 void RemoveProfiles(int profile);
52 52
53 // Adds |num_keys| new autofill keys to the sync profile |profile|. 53 // Adds |num_keys| new autofill keys to the sync profile |profile|.
54 void AddKeys(int profile, int num_keys); 54 void AddKeys(int profile, int num_keys);
55 55
56 private: 56 private:
57 // Returns a new unique autofill profile. 57 // Returns a new unique autofill profile.
58 const AutofillProfile NextAutofillProfile(); 58 const AutofillProfile& NextAutofillProfile();
59 59
60 // Returns a new unique autofill key. 60 // Returns a new unique autofill key.
61 const AutofillKey NextAutofillKey(); 61 const AutofillKey& NextAutofillKey();
62 62
63 // Returns an unused unique guid. 63 // Returns an unused unique guid.
64 const std::string NextGUID(); 64 const std::string& NextGUID();
65 65
66 // Returns a unique guid based on the input integer |n|. 66 // Returns a unique guid based on the input integer |n|.
67 const std::string IntToGUID(int n); 67 const std::string& IntToGUID(int n);
68 68
69 // Returns a new unused unique name. 69 // Returns a new unused unique name.
70 const std::string NextName(); 70 const std::string& NextName();
71 71
72 // Returns a unique name based on the input integer |n|. 72 // Returns a unique name based on the input integer |n|.
73 const std::string IntToName(int n); 73 const std::string& IntToName(int n);
74 74
75 // Returns a new unused unique value for autofill entries. 75 // Returns a new unused unique value for autofill entries.
76 const std::string NextValue(); 76 const std::string& NextValue();
77 77
78 // Returnes a unique value based on the input integer |n|. 78 // Returnes a unique value based on the input integer |n|.
79 const std::string IntToValue(int n); 79 const std::string& IntToValue(int n);
80 80
81 int guid_number_; 81 int guid_number_;
82 int name_number_; 82 int name_number_;
83 int value_number_; 83 int value_number_;
84 DISALLOW_COPY_AND_ASSIGN(AutofillSyncPerfTest); 84 DISALLOW_COPY_AND_ASSIGN(AutofillSyncPerfTest);
85 }; 85 };
86 86
87 void AutofillSyncPerfTest::AddProfiles(int profile, int num_profiles) { 87 void AutofillSyncPerfTest::AddProfiles(int profile, int num_profiles) {
88 const std::vector<AutofillProfile*>& all_profiles = 88 const std::vector<AutofillProfile*>& all_profiles =
89 GetAllProfiles(profile); 89 GetAllProfiles(profile);
(...skipping 25 matching lines...) Expand all
115 } 115 }
116 116
117 void AutofillSyncPerfTest::AddKeys(int profile, int num_keys) { 117 void AutofillSyncPerfTest::AddKeys(int profile, int num_keys) {
118 std::set<AutofillKey> keys; 118 std::set<AutofillKey> keys;
119 for (int i = 0; i < num_keys; ++i) { 119 for (int i = 0; i < num_keys; ++i) {
120 keys.insert(NextAutofillKey()); 120 keys.insert(NextAutofillKey());
121 } 121 }
122 autofill_helper::AddKeys(profile, keys); 122 autofill_helper::AddKeys(profile, keys);
123 } 123 }
124 124
125 const AutofillProfile AutofillSyncPerfTest::NextAutofillProfile() { 125 const AutofillProfile& AutofillSyncPerfTest::NextAutofillProfile() {
126 AutofillProfile profile; 126 AutofillProfile profile;
127 autofill::test::SetProfileInfoWithGuid(&profile, NextGUID().c_str(), 127 autofill::test::SetProfileInfoWithGuid(&profile, NextGUID().c_str(),
128 NextName().c_str(), "", "", "", "", "", 128 NextName().c_str(), "", "", "", "", "",
129 "", "", "", "", "", ""); 129 "", "", "", "", "", "");
130 return profile; 130 return profile;
131 } 131 }
132 132
133 const AutofillKey AutofillSyncPerfTest::NextAutofillKey() { 133 const AutofillKey& AutofillSyncPerfTest::NextAutofillKey() {
134 return AutofillKey(NextName().c_str(), NextName().c_str()); 134 return AutofillKey(NextName().c_str(), NextName().c_str());
135 } 135 }
136 136
137 const std::string AutofillSyncPerfTest::NextGUID() { 137 const std::string& AutofillSyncPerfTest::NextGUID() {
138 return IntToGUID(guid_number_++); 138 return IntToGUID(guid_number_++);
139 } 139 }
140 140
141 const std::string AutofillSyncPerfTest::IntToGUID(int n) { 141 const std::string& AutofillSyncPerfTest::IntToGUID(int n) {
142 return base::StringPrintf("00000000-0000-0000-0000-%012X", n); 142 return base::StringPrintf("00000000-0000-0000-0000-%012X", n);
143 } 143 }
144 144
145 const std::string AutofillSyncPerfTest::NextName() { 145 const std::string& AutofillSyncPerfTest::NextName() {
146 return IntToName(name_number_++); 146 return IntToName(name_number_++);
147 } 147 }
148 148
149 const std::string AutofillSyncPerfTest::IntToName(int n) { 149 const std::string& AutofillSyncPerfTest::IntToName(int n) {
150 return base::StringPrintf("Name%d", n); 150 return base::StringPrintf("Name%d", n);
151 } 151 }
152 152
153 const std::string AutofillSyncPerfTest::NextValue() { 153 const std::string& AutofillSyncPerfTest::NextValue() {
154 return IntToValue(value_number_++); 154 return IntToValue(value_number_++);
155 } 155 }
156 156
157 const std::string AutofillSyncPerfTest::IntToValue(int n) { 157 const std::string& AutofillSyncPerfTest::IntToValue(int n) {
158 return base::StringPrintf("Value%d", n); 158 return base::StringPrintf("Value%d", n);
159 } 159 }
160 160
161 void ForceSync(int profile) { 161 void ForceSync(int profile) {
162 static int id = 0; 162 static int id = 0;
163 ++id; 163 ++id;
164 EXPECT_TRUE( 164 EXPECT_TRUE(
165 bookmarks_helper::AddURL(profile, 0, 165 bookmarks_helper::AddURL(profile, 0,
166 bookmarks_helper::IndexedURLTitle(id), 166 bookmarks_helper::IndexedURLTitle(id),
167 GURL(bookmarks_helper::IndexedURL(id))) != NULL); 167 GURL(bookmarks_helper::IndexedURL(id))) != NULL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ASSERT_EQ(kNumKeys, GetKeyCount(1)); 201 ASSERT_EQ(kNumKeys, GetKeyCount(1));
202 SyncTimingHelper::PrintResult("autofill", "add_autofill_keys", dt); 202 SyncTimingHelper::PrintResult("autofill", "add_autofill_keys", dt);
203 203
204 RemoveKeys(0); 204 RemoveKeys(0);
205 // TODO(lipalani): fix this. The following line is added to force sync. 205 // TODO(lipalani): fix this. The following line is added to force sync.
206 ForceSync(0); 206 ForceSync(0);
207 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1)); 207 dt = SyncTimingHelper::TimeMutualSyncCycle(GetClient(0), GetClient(1));
208 ASSERT_EQ(0, GetKeyCount(1)); 208 ASSERT_EQ(0, GetKeyCount(1));
209 SyncTimingHelper::PrintResult("autofill", "delete_autofill_keys", dt); 209 SyncTimingHelper::PrintResult("autofill", "delete_autofill_keys", dt);
210 } 210 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698