| 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 // This program generates a user profile and history by randomly generating | 5 // This program generates a user profile and history by randomly generating |
| 6 // data and feeding it to the history service. | 6 // data and feeding it to the history service. |
| 7 | 7 |
| 8 #include "chrome/tools/profiles/thumbnail-inl.h" | 8 #include "chrome/tools/profiles/thumbnail-inl.h" |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); | 251 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); |
| 252 | 252 |
| 253 // The maximum number of URLs to insert into history in one batch. | 253 // The maximum number of URLs to insert into history in one batch. |
| 254 const int kBatchSize = 2000; | 254 const int kBatchSize = 2000; |
| 255 int page_id = 0; | 255 int page_id = 0; |
| 256 while (page_id < url_count) { | 256 while (page_id < url_count) { |
| 257 const int batch_size = std::min(kBatchSize, url_count - page_id); | 257 const int batch_size = std::min(kBatchSize, url_count - page_id); |
| 258 InsertURLBatch(&profile, page_id, batch_size, types); | 258 InsertURLBatch(&profile, page_id, batch_size, types); |
| 259 // Run all pending messages to give TopSites a chance to catch up. | 259 // Run all pending messages to give TopSites a chance to catch up. |
| 260 message_loop.RunAllPending(); | 260 message_loop.RunUntilIdle(); |
| 261 page_id += batch_size; | 261 page_id += batch_size; |
| 262 } | 262 } |
| 263 | 263 |
| 264 printf("Writing to disk\n"); | 264 printf("Writing to disk\n"); |
| 265 | 265 |
| 266 profile.DestroyTopSites(); | 266 profile.DestroyTopSites(); |
| 267 profile.DestroyHistoryService(); | 267 profile.DestroyHistoryService(); |
| 268 | 268 |
| 269 message_loop.RunAllPending(); | 269 message_loop.RunUntilIdle(); |
| 270 | 270 |
| 271 file_util::FileEnumerator file_iterator(profile.GetPath(), false, | 271 file_util::FileEnumerator file_iterator(profile.GetPath(), false, |
| 272 file_util::FileEnumerator::FILES); | 272 file_util::FileEnumerator::FILES); |
| 273 FilePath path = file_iterator.Next(); | 273 FilePath path = file_iterator.Next(); |
| 274 while (!path.empty()) { | 274 while (!path.empty()) { |
| 275 FilePath dst_file = dst_dir.Append(path.BaseName()); | 275 FilePath dst_file = dst_dir.Append(path.BaseName()); |
| 276 file_util::Delete(dst_file, false); | 276 file_util::Delete(dst_file, false); |
| 277 printf("Copying file %ls to %ls\n", path.value().c_str(), | 277 printf("Copying file %ls to %ls\n", path.value().c_str(), |
| 278 dst_file.value().c_str()); | 278 dst_file.value().c_str()); |
| 279 if (!file_util::CopyFile(path, dst_file)) { | 279 if (!file_util::CopyFile(path, dst_file)) { |
| 280 printf("Copying file failed: %d\n", ::GetLastError()); | 280 printf("Copying file failed: %d\n", ::GetLastError()); |
| 281 return -1; | 281 return -1; |
| 282 } | 282 } |
| 283 path = file_iterator.Next(); | 283 path = file_iterator.Next(); |
| 284 } | 284 } |
| 285 | 285 |
| 286 return 0; | 286 return 0; |
| 287 } | 287 } |
| OLD | NEW |