OLD | NEW |
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/test/perf/generate_profile.h" | 5 #include "chrome/test/perf/generate_profile.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // random number generator with the number of urls we're generating. | 222 // random number generator with the number of urls we're generating. |
223 srand(static_cast<unsigned int>(url_count)); | 223 srand(static_cast<unsigned int>(url_count)); |
224 | 224 |
225 printf("Creating profiles for testing...\n"); | 225 printf("Creating profiles for testing...\n"); |
226 | 226 |
227 InitBrowserProcess initialize_browser_process; | 227 InitBrowserProcess initialize_browser_process; |
228 base::MessageLoopForUI message_loop; | 228 base::MessageLoopForUI message_loop; |
229 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); | 229 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
230 content::TestBrowserThread db_thread(BrowserThread::DB, &message_loop); | 230 content::TestBrowserThread db_thread(BrowserThread::DB, &message_loop); |
231 TestingProfile profile; | 231 TestingProfile profile; |
232 if (!profile.CreateHistoryService(false, false)) { | 232 profile.CreateHistoryService(false, false); |
233 PLOG(ERROR) << "Creating history service failed"; | |
234 return false; | |
235 } | |
236 if (types & TOP_SITES) { | 233 if (types & TOP_SITES) { |
237 profile.CreateTopSites(); | 234 profile.CreateTopSites(); |
238 profile.BlockUntilTopSitesLoaded(); | 235 profile.BlockUntilTopSitesLoaded(); |
239 } | 236 } |
240 | 237 |
241 // The maximum number of URLs to insert into history in one batch. | 238 // The maximum number of URLs to insert into history in one batch. |
242 const int kBatchSize = 2000; | 239 const int kBatchSize = 2000; |
243 int page_id = 0; | 240 int page_id = 0; |
244 while (page_id < url_count) { | 241 while (page_id < url_count) { |
245 const int batch_size = std::min(kBatchSize, url_count - page_id); | 242 const int batch_size = std::min(kBatchSize, url_count - page_id); |
(...skipping 21 matching lines...) Expand all Loading... |
267 path = file_iterator.Next(); | 264 path = file_iterator.Next(); |
268 } | 265 } |
269 | 266 |
270 printf("Finished creating profiles for testing.\n"); | 267 printf("Finished creating profiles for testing.\n"); |
271 | 268 |
272 // Restore the random seed. | 269 // Restore the random seed. |
273 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); | 270 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); |
274 | 271 |
275 return true; | 272 return true; |
276 } | 273 } |
OLD | NEW |