| 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_path.h" | 11 #include "base/files/file_path.h" |
| 11 #include "base/i18n/icu_util.h" | 12 #include "base/i18n/icu_util.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #include "base/process_util.h" | 16 #include "base/process_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/time.h" | 18 #include "base/time.h" |
| 18 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 19 #include "chrome/browser/history/history_service.h" | 20 #include "chrome/browser/history/history_service.h" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // Run all pending messages to give TopSites a chance to catch up. | 244 // Run all pending messages to give TopSites a chance to catch up. |
| 244 message_loop.RunUntilIdle(); | 245 message_loop.RunUntilIdle(); |
| 245 page_id += batch_size; | 246 page_id += batch_size; |
| 246 } | 247 } |
| 247 | 248 |
| 248 profile.DestroyTopSites(); | 249 profile.DestroyTopSites(); |
| 249 profile.DestroyHistoryService(); | 250 profile.DestroyHistoryService(); |
| 250 | 251 |
| 251 message_loop.RunUntilIdle(); | 252 message_loop.RunUntilIdle(); |
| 252 | 253 |
| 253 file_util::FileEnumerator file_iterator(profile.GetPath(), false, | 254 base::FileEnumerator file_iterator(profile.GetPath(), false, |
| 254 file_util::FileEnumerator::FILES); | 255 base::FileEnumerator::FILES); |
| 255 base::FilePath path = file_iterator.Next(); | 256 base::FilePath path = file_iterator.Next(); |
| 256 while (!path.empty()) { | 257 while (!path.empty()) { |
| 257 base::FilePath dst_file = dst_dir.Append(path.BaseName()); | 258 base::FilePath dst_file = dst_dir.Append(path.BaseName()); |
| 258 file_util::Delete(dst_file, false); | 259 file_util::Delete(dst_file, false); |
| 259 if (!file_util::CopyFile(path, dst_file)) { | 260 if (!file_util::CopyFile(path, dst_file)) { |
| 260 PLOG(ERROR) << "Copying file failed"; | 261 PLOG(ERROR) << "Copying file failed"; |
| 261 return false; | 262 return false; |
| 262 } | 263 } |
| 263 path = file_iterator.Next(); | 264 path = file_iterator.Next(); |
| 264 } | 265 } |
| 265 | 266 |
| 266 printf("Finished creating profiles for testing.\n"); | 267 printf("Finished creating profiles for testing.\n"); |
| 267 | 268 |
| 268 // Restore the random seed. | 269 // Restore the random seed. |
| 269 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); | 270 srand(static_cast<unsigned int>(Time::Now().ToInternalValue())); |
| 270 | 271 |
| 271 return true; | 272 return true; |
| 272 } | 273 } |
| OLD | NEW |