OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/format_macros.h" |
8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/browser/browser_thread.h" | 14 #include "chrome/browser/browser_thread.h" |
14 #include "chrome/browser/dom_ui/most_visited_handler.h" | 15 #include "chrome/browser/dom_ui/most_visited_handler.h" |
15 #include "chrome/browser/history/history_backend.h" | 16 #include "chrome/browser/history/history_backend.h" |
16 #include "chrome/browser/history/history_database.h" | 17 #include "chrome/browser/history/history_database.h" |
17 #include "chrome/browser/history/history_marshaling.h" | 18 #include "chrome/browser/history/history_marshaling.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 376 |
376 // Favicon assertions are handled in ThumbnailDatabase. | 377 // Favicon assertions are handled in ThumbnailDatabase. |
377 } | 378 } |
378 | 379 |
379 private: | 380 private: |
380 // Executes the sql from the file |sql_path| in the database at |db_path|. | 381 // Executes the sql from the file |sql_path| in the database at |db_path|. |
381 void ExecuteSQL(const FilePath& sql_path, | 382 void ExecuteSQL(const FilePath& sql_path, |
382 const FilePath& db_path) { | 383 const FilePath& db_path) { |
383 std::string sql; | 384 std::string sql; |
384 ASSERT_TRUE(file_util::ReadFileToString(sql_path, &sql)); | 385 ASSERT_TRUE(file_util::ReadFileToString(sql_path, &sql)); |
| 386 |
| 387 // Replace the 'last_visit_time', 'visit_time', 'time_slot' values in this |
| 388 // SQL with the current time. |
| 389 int64 now = base::Time::Now().ToInternalValue(); |
| 390 std::vector<std::string> sql_time; |
| 391 sql_time.push_back(StringPrintf("%" PRId64, now)); // last_visit_time |
| 392 sql_time.push_back(StringPrintf("%" PRId64, now)); // visit_time |
| 393 sql_time.push_back(StringPrintf("%" PRId64, now)); // time_slot |
| 394 sql = ReplaceStringPlaceholders(sql, sql_time, NULL); |
| 395 |
385 sql::Connection connection; | 396 sql::Connection connection; |
386 ASSERT_TRUE(connection.Open(db_path)); | 397 ASSERT_TRUE(connection.Open(db_path)); |
387 ASSERT_TRUE(connection.Execute(sql.c_str())); | 398 ASSERT_TRUE(connection.Execute(sql.c_str())); |
388 } | 399 } |
389 | 400 |
390 DISALLOW_COPY_AND_ASSIGN(TopSitesMigrationTest); | 401 DISALLOW_COPY_AND_ASSIGN(TopSitesMigrationTest); |
391 }; | 402 }; |
392 | 403 |
393 // Helper function for appending a URL to a vector of "most visited" URLs, | 404 // Helper function for appending a URL to a vector of "most visited" URLs, |
394 // using the default values for everything but the URL. | 405 // using the default values for everything but the URL. |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 WaitForTopSites(); | 1348 WaitForTopSites(); |
1338 EXPECT_FALSE(IsTopSitesLoaded()); | 1349 EXPECT_FALSE(IsTopSitesLoaded()); |
1339 | 1350 |
1340 // Load history, which should make TopSites finish loading too. | 1351 // Load history, which should make TopSites finish loading too. |
1341 profile()->CreateHistoryService(false, false); | 1352 profile()->CreateHistoryService(false, false); |
1342 profile()->BlockUntilTopSitesLoaded(); | 1353 profile()->BlockUntilTopSitesLoaded(); |
1343 EXPECT_TRUE(IsTopSitesLoaded()); | 1354 EXPECT_TRUE(IsTopSitesLoaded()); |
1344 } | 1355 } |
1345 | 1356 |
1346 } // namespace history | 1357 } // namespace history |
OLD | NEW |