| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 base::AtExitManager exit_manager; | 200 base::AtExitManager exit_manager; |
| 201 CommandLine* cl = CommandLine::ForCurrentProcess(); | 201 CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 202 | 202 |
| 203 int types = 0; | 203 int types = 0; |
| 204 if (cl->HasSwitch("top-sites")) | 204 if (cl->HasSwitch("top-sites")) |
| 205 types |= TOP_SITES; | 205 types |= TOP_SITES; |
| 206 if (cl->HasSwitch("full-text")) | 206 if (cl->HasSwitch("full-text")) |
| 207 types |= FULL_TEXT; | 207 types |= FULL_TEXT; |
| 208 | 208 |
| 209 // We require two arguments: urlcount and profiledir. | 209 // We require two arguments: urlcount and profiledir. |
| 210 if (cl->args().size() < 2) { | 210 const CommandLine::StringVector& args = cl->GetArgs(); |
| 211 if (args.size() < 2) { |
| 211 printf("usage: %s [--top-sites] [--full-text] <urlcount> " | 212 printf("usage: %s [--top-sites] [--full-text] <urlcount> " |
| 212 "<profiledir>\n", argv[0]); | 213 "<profiledir>\n", argv[0]); |
| 213 printf("\n --top-sites Generate thumbnails\n"); | 214 printf("\n --top-sites Generate thumbnails\n"); |
| 214 printf("\n --full-text Generate full text index\n"); | 215 printf("\n --full-text Generate full text index\n"); |
| 215 return -1; | 216 return -1; |
| 216 } | 217 } |
| 217 | 218 |
| 218 int url_count = 0; | 219 int url_count = 0; |
| 219 base::StringToInt(WideToUTF8(cl->args()[0]), &url_count); | 220 base::StringToInt(WideToUTF8(args[0]), &url_count); |
| 220 FilePath dst_dir(cl->args()[1]); | 221 FilePath dst_dir(args[1]); |
| 221 if (!dst_dir.IsAbsolute()) { | 222 if (!dst_dir.IsAbsolute()) { |
| 222 FilePath current_dir; | 223 FilePath current_dir; |
| 223 file_util::GetCurrentDirectory(¤t_dir); | 224 file_util::GetCurrentDirectory(¤t_dir); |
| 224 dst_dir = current_dir.Append(dst_dir); | 225 dst_dir = current_dir.Append(dst_dir); |
| 225 } | 226 } |
| 226 if (!file_util::CreateDirectory(dst_dir)) { | 227 if (!file_util::CreateDirectory(dst_dir)) { |
| 227 printf("Unable to create directory %ls: %d\n", | 228 printf("Unable to create directory %ls: %d\n", |
| 228 dst_dir.value().c_str(), | 229 dst_dir.value().c_str(), |
| 229 ::GetLastError()); | 230 ::GetLastError()); |
| 230 } | 231 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 dst_file.value().c_str()); | 278 dst_file.value().c_str()); |
| 278 if (!file_util::CopyFile(path, dst_file)) { | 279 if (!file_util::CopyFile(path, dst_file)) { |
| 279 printf("Copying file failed: %d\n", ::GetLastError()); | 280 printf("Copying file failed: %d\n", ::GetLastError()); |
| 280 return -1; | 281 return -1; |
| 281 } | 282 } |
| 282 path = file_iterator.Next(); | 283 path = file_iterator.Next(); |
| 283 } | 284 } |
| 284 | 285 |
| 285 return 0; | 286 return 0; |
| 286 } | 287 } |
| OLD | NEW |