| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/file_enumerator.h" |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/i18n/icu_util.h" | 15 #include "base/i18n/icu_util.h" |
| 15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 16 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/process_util.h" | 19 #include "base/process_util.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/time.h" | 21 #include "base/time.h" |
| 21 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 22 #include "chrome/browser/history/history_service.h" | 23 #include "chrome/browser/history/history_service.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 page_id += batch_size; | 284 page_id += batch_size; |
| 284 } | 285 } |
| 285 | 286 |
| 286 printf("Writing to disk\n"); | 287 printf("Writing to disk\n"); |
| 287 | 288 |
| 288 profile.DestroyTopSites(); | 289 profile.DestroyTopSites(); |
| 289 profile.DestroyHistoryService(); | 290 profile.DestroyHistoryService(); |
| 290 | 291 |
| 291 message_loop.RunUntilIdle(); | 292 message_loop.RunUntilIdle(); |
| 292 | 293 |
| 293 file_util::FileEnumerator file_iterator(profile.GetPath(), false, | 294 base::FileEnumerator file_iterator(profile.GetPath(), false, |
| 294 file_util::FileEnumerator::FILES); | 295 base::FileEnumerator::FILES); |
| 295 base::FilePath path = file_iterator.Next(); | 296 base::FilePath path = file_iterator.Next(); |
| 296 while (!path.empty()) { | 297 while (!path.empty()) { |
| 297 base::FilePath dst_file = dst_dir.Append(path.BaseName()); | 298 base::FilePath dst_file = dst_dir.Append(path.BaseName()); |
| 298 file_util::Delete(dst_file, false); | 299 file_util::Delete(dst_file, false); |
| 299 printf("Copying file %" PRFilePath " to " | 300 printf("Copying file %" PRFilePath " to " |
| 300 "%" PRFilePath "\n", path.value().c_str(), | 301 "%" PRFilePath "\n", path.value().c_str(), |
| 301 dst_file.value().c_str()); | 302 dst_file.value().c_str()); |
| 302 if (!file_util::CopyFile(path, dst_file)) { | 303 if (!file_util::CopyFile(path, dst_file)) { |
| 303 PLOG(ERROR) << "Copying file failed"; | 304 PLOG(ERROR) << "Copying file failed"; |
| 304 return -1; | 305 return -1; |
| 305 } | 306 } |
| 306 path = file_iterator.Next(); | 307 path = file_iterator.Next(); |
| 307 } | 308 } |
| 308 | 309 |
| 309 return 0; | 310 return 0; |
| 310 } | 311 } |
| OLD | NEW |