| 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 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 void NotifyProfileError(sql::InitStatus init_status) override {} | 120 void NotifyProfileError(sql::InitStatus init_status) override {} |
| 121 void SetInMemoryBackend(scoped_ptr<InMemoryHistoryBackend> backend) override; | 121 void SetInMemoryBackend(scoped_ptr<InMemoryHistoryBackend> backend) override; |
| 122 void NotifyAddVisit(const BriefVisitInfo& info) override {} | 122 void NotifyAddVisit(const BriefVisitInfo& info) override {} |
| 123 void NotifyFaviconChanged(const std::set<GURL>& urls) override; | 123 void NotifyFaviconChanged(const std::set<GURL>& urls) override; |
| 124 void NotifyURLVisited(ui::PageTransition transition, | 124 void NotifyURLVisited(ui::PageTransition transition, |
| 125 const URLRow& row, | 125 const URLRow& row, |
| 126 const RedirectList& redirects, | 126 const RedirectList& redirects, |
| 127 base::Time visit_time) override; | 127 base::Time visit_time) override; |
| 128 void NotifyURLsModified(const URLRows& changed_urls) override; | 128 void NotifyURLsModified(const URLRows& changed_urls) override; |
| 129 void NotifyKeywordSearchTermUpdated(const URLRow& row, |
| 130 KeywordID keyword_id, |
| 131 const base::string16& term) override; |
| 129 void BroadcastNotifications(int type, | 132 void BroadcastNotifications(int type, |
| 130 scoped_ptr<HistoryDetails> details) override; | 133 scoped_ptr<HistoryDetails> details) override; |
| 131 void DBLoaded() override; | 134 void DBLoaded() override; |
| 132 | 135 |
| 133 private: | 136 private: |
| 134 // Not owned by us. | 137 // Not owned by us. |
| 135 HistoryBackendTestBase* test_; | 138 HistoryBackendTestBase* test_; |
| 136 | 139 |
| 137 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); | 140 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); |
| 138 }; | 141 }; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 mem_backend_->OnURLVisited(nullptr, transition, row, redirects, visit_time); | 210 mem_backend_->OnURLVisited(nullptr, transition, row, redirects, visit_time); |
| 208 url_visited_notifications_.push_back(std::make_pair(transition, row)); | 211 url_visited_notifications_.push_back(std::make_pair(transition, row)); |
| 209 } | 212 } |
| 210 | 213 |
| 211 void NotifyURLsModified(const URLRows& changed_urls) { | 214 void NotifyURLsModified(const URLRows& changed_urls) { |
| 212 // Send the notifications directly to the in-memory database. | 215 // Send the notifications directly to the in-memory database. |
| 213 mem_backend_->OnURLsModified(nullptr, changed_urls); | 216 mem_backend_->OnURLsModified(nullptr, changed_urls); |
| 214 urls_modified_notifications_.push_back(changed_urls); | 217 urls_modified_notifications_.push_back(changed_urls); |
| 215 } | 218 } |
| 216 | 219 |
| 220 void NotifyKeywordSearchTermUpdated(const URLRow& row, |
| 221 KeywordID keyword_id, |
| 222 const base::string16& term) { |
| 223 mem_backend_->OnKeywordSearchTermUpdated(nullptr, row, keyword_id, term); |
| 224 } |
| 225 |
| 217 void BroadcastNotifications(int type, scoped_ptr<HistoryDetails> details) { | 226 void BroadcastNotifications(int type, scoped_ptr<HistoryDetails> details) { |
| 218 // Send the notifications directly to the in-memory database. | 227 // Send the notifications directly to the in-memory database. |
| 219 content::Details<HistoryDetails> det(details.get()); | 228 content::Details<HistoryDetails> det(details.get()); |
| 220 mem_backend_->Observe( | 229 mem_backend_->Observe( |
| 221 type, content::Source<HistoryBackendTestBase>(NULL), det); | 230 type, content::Source<HistoryBackendTestBase>(NULL), det); |
| 222 | 231 |
| 223 // The backend passes ownership of the details pointer to us. | 232 // The backend passes ownership of the details pointer to us. |
| 224 broadcasted_notifications_.push_back( | 233 broadcasted_notifications_.push_back( |
| 225 std::make_pair(type, details.release())); | 234 std::make_pair(type, details.release())); |
| 226 } | 235 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 const RedirectList& redirects, | 295 const RedirectList& redirects, |
| 287 base::Time visit_time) { | 296 base::Time visit_time) { |
| 288 test_->NotifyURLVisited(transition, row, redirects, visit_time); | 297 test_->NotifyURLVisited(transition, row, redirects, visit_time); |
| 289 } | 298 } |
| 290 | 299 |
| 291 void HistoryBackendTestDelegate::NotifyURLsModified( | 300 void HistoryBackendTestDelegate::NotifyURLsModified( |
| 292 const URLRows& changed_urls) { | 301 const URLRows& changed_urls) { |
| 293 test_->NotifyURLsModified(changed_urls); | 302 test_->NotifyURLsModified(changed_urls); |
| 294 } | 303 } |
| 295 | 304 |
| 305 void HistoryBackendTestDelegate::NotifyKeywordSearchTermUpdated( |
| 306 const URLRow& row, |
| 307 KeywordID keyword_id, |
| 308 const base::string16& term) { |
| 309 test_->NotifyKeywordSearchTermUpdated(row, keyword_id, term); |
| 310 } |
| 311 |
| 296 void HistoryBackendTestDelegate::BroadcastNotifications( | 312 void HistoryBackendTestDelegate::BroadcastNotifications( |
| 297 int type, | 313 int type, |
| 298 scoped_ptr<HistoryDetails> details) { | 314 scoped_ptr<HistoryDetails> details) { |
| 299 test_->BroadcastNotifications(type, details.Pass()); | 315 test_->BroadcastNotifications(type, details.Pass()); |
| 300 } | 316 } |
| 301 | 317 |
| 302 void HistoryBackendTestDelegate::DBLoaded() { | 318 void HistoryBackendTestDelegate::DBLoaded() { |
| 303 test_->loaded_ = true; | 319 test_->loaded_ = true; |
| 304 } | 320 } |
| 305 | 321 |
| (...skipping 2967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3273 // Verify that the second term is no longer returned as result, and also check | 3289 // Verify that the second term is no longer returned as result, and also check |
| 3274 // at the low level that it is gone for good. The term corresponding to the | 3290 // at the low level that it is gone for good. The term corresponding to the |
| 3275 // first URLRow should not be affected. | 3291 // first URLRow should not be affected. |
| 3276 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3292 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
| 3277 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3293 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
| 3278 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3294 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
| 3279 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3295 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
| 3280 } | 3296 } |
| 3281 | 3297 |
| 3282 } // namespace history | 3298 } // namespace history |
| OLD | NEW |