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