| 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 #include "chrome/browser/history/history_backend.h" | 5 #include "chrome/browser/history/history_backend.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 20 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
| 25 #include "chrome/browser/history/history_notifications.h" | 25 #include "chrome/browser/history/history_notifications.h" |
| 26 #include "chrome/browser/history/history_service.h" | 26 #include "chrome/browser/history/history_service.h" |
| 27 #include "chrome/browser/history/history_service_factory.h" | 27 #include "chrome/browser/history/history_service_factory.h" |
| 28 #include "chrome/browser/history/in_memory_history_backend.h" | 28 #include "chrome/browser/history/in_memory_history_backend.h" |
| 29 #include "chrome/browser/history/visit_filter.h" | 29 #include "chrome/browser/history/visit_filter.h" |
| 30 #include "chrome/common/chrome_constants.h" | |
| 31 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/importer/imported_favicon_usage.h" | 31 #include "chrome/common/importer/imported_favicon_usage.h" |
| 33 #include "chrome/test/base/testing_profile.h" | 32 #include "chrome/test/base/testing_profile.h" |
| 33 #include "components/history/core/browser/history_constants.h" |
| 34 #include "components/history/core/browser/in_memory_database.h" | 34 #include "components/history/core/browser/in_memory_database.h" |
| 35 #include "components/history/core/browser/keyword_search_term.h" | 35 #include "components/history/core/browser/keyword_search_term.h" |
| 36 #include "components/history/core/test/history_client_fake_bookmarks.h" | 36 #include "components/history/core/test/history_client_fake_bookmarks.h" |
| 37 #include "content/public/browser/notification_details.h" | 37 #include "content/public/browser/notification_details.h" |
| 38 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
| 39 #include "content/public/test/test_browser_thread.h" | 39 #include "content/public/test/test_browser_thread.h" |
| 40 #include "testing/gmock/include/gmock/gmock.h" | 40 #include "testing/gmock/include/gmock/gmock.h" |
| 41 #include "testing/gtest/include/gtest/gtest.h" | 41 #include "testing/gtest/include/gtest/gtest.h" |
| 42 #include "third_party/skia/include/core/SkBitmap.h" | 42 #include "third_party/skia/include/core/SkBitmap.h" |
| 43 #include "ui/gfx/codec/png_codec.h" | 43 #include "ui/gfx/codec/png_codec.h" |
| (...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 base::FilePath old_history_path; | 1537 base::FilePath old_history_path; |
| 1538 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); | 1538 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); |
| 1539 old_history_path = old_history_path.AppendASCII("History"); | 1539 old_history_path = old_history_path.AppendASCII("History"); |
| 1540 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); | 1540 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); |
| 1541 | 1541 |
| 1542 // Copy history database file to current directory so that it will be deleted | 1542 // Copy history database file to current directory so that it will be deleted |
| 1543 // in Teardown. | 1543 // in Teardown. |
| 1544 base::FilePath new_history_path(test_dir()); | 1544 base::FilePath new_history_path(test_dir()); |
| 1545 base::DeleteFile(new_history_path, true); | 1545 base::DeleteFile(new_history_path, true); |
| 1546 base::CreateDirectory(new_history_path); | 1546 base::CreateDirectory(new_history_path); |
| 1547 base::FilePath new_history_file = | 1547 base::FilePath new_history_file = new_history_path.Append(kHistoryFilename); |
| 1548 new_history_path.Append(chrome::kHistoryFilename); | |
| 1549 ASSERT_TRUE(base::CopyFile(old_history_path, new_history_file)); | 1548 ASSERT_TRUE(base::CopyFile(old_history_path, new_history_file)); |
| 1550 | 1549 |
| 1551 backend_ = new HistoryBackend( | 1550 backend_ = new HistoryBackend( |
| 1552 new_history_path, new HistoryBackendTestDelegate(this), &history_client_); | 1551 new_history_path, new HistoryBackendTestDelegate(this), &history_client_); |
| 1553 backend_->Init(std::string(), false); | 1552 backend_->Init(std::string(), false); |
| 1554 backend_->Closing(); | 1553 backend_->Closing(); |
| 1555 backend_ = NULL; | 1554 backend_ = NULL; |
| 1556 | 1555 |
| 1557 // Now the database should already be migrated. | 1556 // Now the database should already be migrated. |
| 1558 // Check version first. | 1557 // Check version first. |
| (...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2790 base::FilePath old_history_path, old_history; | 2789 base::FilePath old_history_path, old_history; |
| 2791 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); | 2790 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); |
| 2792 old_history_path = old_history_path.AppendASCII("History"); | 2791 old_history_path = old_history_path.AppendASCII("History"); |
| 2793 old_history = old_history_path.AppendASCII("HistoryNoDuration"); | 2792 old_history = old_history_path.AppendASCII("HistoryNoDuration"); |
| 2794 | 2793 |
| 2795 // Copy history database file to current directory so that it will be deleted | 2794 // Copy history database file to current directory so that it will be deleted |
| 2796 // in Teardown. | 2795 // in Teardown. |
| 2797 base::FilePath new_history_path(test_dir()); | 2796 base::FilePath new_history_path(test_dir()); |
| 2798 base::DeleteFile(new_history_path, true); | 2797 base::DeleteFile(new_history_path, true); |
| 2799 base::CreateDirectory(new_history_path); | 2798 base::CreateDirectory(new_history_path); |
| 2800 base::FilePath new_history_file = | 2799 base::FilePath new_history_file = new_history_path.Append(kHistoryFilename); |
| 2801 new_history_path.Append(chrome::kHistoryFilename); | |
| 2802 ASSERT_TRUE(base::CopyFile(old_history, new_history_file)); | 2800 ASSERT_TRUE(base::CopyFile(old_history, new_history_file)); |
| 2803 | 2801 |
| 2804 backend_ = new HistoryBackend( | 2802 backend_ = new HistoryBackend( |
| 2805 new_history_path, new HistoryBackendTestDelegate(this), &history_client_); | 2803 new_history_path, new HistoryBackendTestDelegate(this), &history_client_); |
| 2806 backend_->Init(std::string(), false); | 2804 backend_->Init(std::string(), false); |
| 2807 backend_->Closing(); | 2805 backend_->Closing(); |
| 2808 backend_ = NULL; | 2806 backend_ = NULL; |
| 2809 | 2807 |
| 2810 // Now the history database should already be migrated. | 2808 // Now the history database should already be migrated. |
| 2811 | 2809 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3274 // Verify that the second term is no longer returned as result, and also check | 3272 // Verify that the second term is no longer returned as result, and also check |
| 3275 // at the low level that it is gone for good. The term corresponding to the | 3273 // at the low level that it is gone for good. The term corresponding to the |
| 3276 // first URLRow should not be affected. | 3274 // first URLRow should not be affected. |
| 3277 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3275 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
| 3278 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3276 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
| 3279 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3277 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
| 3280 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3278 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
| 3281 } | 3279 } |
| 3282 | 3280 |
| 3283 } // namespace history | 3281 } // namespace history |
| OLD | NEW |