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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 // Scoping value for page IDs (required by the history service). | 130 // Scoping value for page IDs (required by the history service). |
131 void* id_scope = reinterpret_cast<void*>(1); | 131 void* id_scope = reinterpret_cast<void*>(1); |
132 | 132 |
133 scoped_ptr<SkBitmap> google_bitmap( | 133 scoped_ptr<SkBitmap> google_bitmap( |
134 gfx::JPEGCodec::Decode(kGoogleThumbnail, sizeof(kGoogleThumbnail))); | 134 gfx::JPEGCodec::Decode(kGoogleThumbnail, sizeof(kGoogleThumbnail))); |
135 scoped_ptr<SkBitmap> weewar_bitmap( | 135 scoped_ptr<SkBitmap> weewar_bitmap( |
136 gfx::JPEGCodec::Decode(kWeewarThumbnail, sizeof(kWeewarThumbnail))); | 136 gfx::JPEGCodec::Decode(kWeewarThumbnail, sizeof(kWeewarThumbnail))); |
137 | 137 |
138 printf("Inserting %d URLs...\n", batch_size); | 138 printf("Inserting %d URLs...\n", batch_size); |
139 GURL previous_url; | 139 GURL previous_url; |
140 PageTransition::Type transition = PageTransition::TYPED; | 140 content::PageTransition transition = content::PAGE_TRANSITION_TYPED; |
141 const int end_page_id = page_id + batch_size; | 141 const int end_page_id = page_id + batch_size; |
142 history::TopSites* top_sites = profile->GetTopSites(); | 142 history::TopSites* top_sites = profile->GetTopSites(); |
143 for (; page_id < end_page_id; ++page_id) { | 143 for (; page_id < end_page_id; ++page_id) { |
144 // Randomly decide whether this new URL simulates following a link or | 144 // Randomly decide whether this new URL simulates following a link or |
145 // whether it's a jump to a new URL. | 145 // whether it's a jump to a new URL. |
146 if (!previous_url.is_empty() && RandomFloat() < kFollowLinkProbability) { | 146 if (!previous_url.is_empty() && RandomFloat() < kFollowLinkProbability) { |
147 transition = PageTransition::LINK; | 147 transition = content::PAGE_TRANSITION_LINK; |
148 } else { | 148 } else { |
149 previous_url = GURL(); | 149 previous_url = GURL(); |
150 transition = PageTransition::TYPED; | 150 transition = content::PAGE_TRANSITION_TYPED; |
151 } | 151 } |
152 | 152 |
153 // Pick a URL, either newly at random or from our list of previously | 153 // Pick a URL, either newly at random or from our list of previously |
154 // visited URLs. | 154 // visited URLs. |
155 GURL url; | 155 GURL url; |
156 if (!revisit_urls.empty() && RandomFloat() < kRevisitLinkProbability) { | 156 if (!revisit_urls.empty() && RandomFloat() < kRevisitLinkProbability) { |
157 // Draw a URL from revisit_urls at random. | 157 // Draw a URL from revisit_urls at random. |
158 url = revisit_urls[RandomInt(0, static_cast<int>(revisit_urls.size()))]; | 158 url = revisit_urls[RandomInt(0, static_cast<int>(revisit_urls.size()))]; |
159 } else { | 159 } else { |
160 url = ConstructRandomURL(); | 160 url = ConstructRandomURL(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 dst_file.value().c_str()); | 276 dst_file.value().c_str()); |
277 if (!file_util::CopyFile(path, dst_file)) { | 277 if (!file_util::CopyFile(path, dst_file)) { |
278 printf("Copying file failed: %d\n", ::GetLastError()); | 278 printf("Copying file failed: %d\n", ::GetLastError()); |
279 return -1; | 279 return -1; |
280 } | 280 } |
281 path = file_iterator.Next(); | 281 path = file_iterator.Next(); |
282 } | 282 } |
283 | 283 |
284 return 0; | 284 return 0; |
285 } | 285 } |
OLD | NEW |