OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // visited URLs. | 133 // visited URLs. |
134 GURL url; | 134 GURL url; |
135 if (!revisit_urls.empty() && RandomFloat() < kRevisitLinkProbability) { | 135 if (!revisit_urls.empty() && RandomFloat() < kRevisitLinkProbability) { |
136 // Draw a URL from revisit_urls at random. | 136 // Draw a URL from revisit_urls at random. |
137 url = revisit_urls[RandomInt(0, static_cast<int>(revisit_urls.size()))]; | 137 url = revisit_urls[RandomInt(0, static_cast<int>(revisit_urls.size()))]; |
138 } else { | 138 } else { |
139 url = ConstructRandomURL(); | 139 url = ConstructRandomURL(); |
140 } | 140 } |
141 | 141 |
142 // Randomly construct a redirect chain. | 142 // Randomly construct a redirect chain. |
143 HistoryService::RedirectList redirects; | 143 history::RedirectList redirects; |
144 if (RandomFloat() < kRedirectProbability) { | 144 if (RandomFloat() < kRedirectProbability) { |
145 const int redir_count = RandomInt(1, 4); | 145 const int redir_count = RandomInt(1, 4); |
146 for (int i = 0; i < redir_count; ++i) | 146 for (int i = 0; i < redir_count; ++i) |
147 redirects.push_back(ConstructRandomURL()); | 147 redirects.push_back(ConstructRandomURL()); |
148 redirects.push_back(url); | 148 redirects.push_back(url); |
149 } | 149 } |
150 | 150 |
151 // Add all of this information to the history service. | 151 // Add all of this information to the history service. |
152 history_service->AddPage(url, | 152 history_service->AddPage(url, |
153 id_scope, page_id, | 153 id_scope, page_id, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 const int kBatchSize = 2000; | 212 const int kBatchSize = 2000; |
213 int page_id = 0; | 213 int page_id = 0; |
214 while (page_id < url_count) { | 214 while (page_id < url_count) { |
215 const int batch_size = std::min(kBatchSize, url_count - page_id); | 215 const int batch_size = std::min(kBatchSize, url_count - page_id); |
216 InsertURLBatch(profile_dir, page_id, batch_size, history_only); | 216 InsertURLBatch(profile_dir, page_id, batch_size, history_only); |
217 page_id += batch_size; | 217 page_id += batch_size; |
218 } | 218 } |
219 | 219 |
220 return 0; | 220 return 0; |
221 } | 221 } |
OLD | NEW |