| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, | 129 void NotifyKeywordSearchTermUpdated(const URLRow& row, |
| 130 KeywordID keyword_id, | 130 KeywordID keyword_id, |
| 131 const base::string16& term) override; | 131 const base::string16& term) override; |
| 132 void NotifyKeywordSearchTermDeleted(URLID url_id) override; |
| 132 void BroadcastNotifications(int type, | 133 void BroadcastNotifications(int type, |
| 133 scoped_ptr<HistoryDetails> details) override; | 134 scoped_ptr<HistoryDetails> details) override; |
| 134 void DBLoaded() override; | 135 void DBLoaded() override; |
| 135 | 136 |
| 136 private: | 137 private: |
| 137 // Not owned by us. | 138 // Not owned by us. |
| 138 HistoryBackendTestBase* test_; | 139 HistoryBackendTestBase* test_; |
| 139 | 140 |
| 140 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); | 141 DISALLOW_COPY_AND_ASSIGN(HistoryBackendTestDelegate); |
| 141 }; | 142 }; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 mem_backend_->OnURLsModified(nullptr, changed_urls); | 217 mem_backend_->OnURLsModified(nullptr, changed_urls); |
| 217 urls_modified_notifications_.push_back(changed_urls); | 218 urls_modified_notifications_.push_back(changed_urls); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void NotifyKeywordSearchTermUpdated(const URLRow& row, | 221 void NotifyKeywordSearchTermUpdated(const URLRow& row, |
| 221 KeywordID keyword_id, | 222 KeywordID keyword_id, |
| 222 const base::string16& term) { | 223 const base::string16& term) { |
| 223 mem_backend_->OnKeywordSearchTermUpdated(nullptr, row, keyword_id, term); | 224 mem_backend_->OnKeywordSearchTermUpdated(nullptr, row, keyword_id, term); |
| 224 } | 225 } |
| 225 | 226 |
| 227 void NotifyKeywordSearchTermDeleted(URLID url_id) { |
| 228 mem_backend_->OnKeywordSearchTermDeleted(nullptr, url_id); |
| 229 } |
| 230 |
| 226 void BroadcastNotifications(int type, scoped_ptr<HistoryDetails> details) { | 231 void BroadcastNotifications(int type, scoped_ptr<HistoryDetails> details) { |
| 227 // Send the notifications directly to the in-memory database. | 232 // Send the notifications directly to the in-memory database. |
| 228 content::Details<HistoryDetails> det(details.get()); | 233 content::Details<HistoryDetails> det(details.get()); |
| 229 mem_backend_->Observe( | 234 mem_backend_->Observe( |
| 230 type, content::Source<HistoryBackendTestBase>(NULL), det); | 235 type, content::Source<HistoryBackendTestBase>(NULL), det); |
| 231 | 236 |
| 232 // The backend passes ownership of the details pointer to us. | 237 // The backend passes ownership of the details pointer to us. |
| 233 broadcasted_notifications_.push_back( | 238 broadcasted_notifications_.push_back( |
| 234 std::make_pair(type, details.release())); | 239 std::make_pair(type, details.release())); |
| 235 } | 240 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 test_->NotifyURLsModified(changed_urls); | 307 test_->NotifyURLsModified(changed_urls); |
| 303 } | 308 } |
| 304 | 309 |
| 305 void HistoryBackendTestDelegate::NotifyKeywordSearchTermUpdated( | 310 void HistoryBackendTestDelegate::NotifyKeywordSearchTermUpdated( |
| 306 const URLRow& row, | 311 const URLRow& row, |
| 307 KeywordID keyword_id, | 312 KeywordID keyword_id, |
| 308 const base::string16& term) { | 313 const base::string16& term) { |
| 309 test_->NotifyKeywordSearchTermUpdated(row, keyword_id, term); | 314 test_->NotifyKeywordSearchTermUpdated(row, keyword_id, term); |
| 310 } | 315 } |
| 311 | 316 |
| 317 void HistoryBackendTestDelegate::NotifyKeywordSearchTermDeleted(URLID url_id) { |
| 318 test_->NotifyKeywordSearchTermDeleted(url_id); |
| 319 } |
| 320 |
| 312 void HistoryBackendTestDelegate::BroadcastNotifications( | 321 void HistoryBackendTestDelegate::BroadcastNotifications( |
| 313 int type, | 322 int type, |
| 314 scoped_ptr<HistoryDetails> details) { | 323 scoped_ptr<HistoryDetails> details) { |
| 315 test_->BroadcastNotifications(type, details.Pass()); | 324 test_->BroadcastNotifications(type, details.Pass()); |
| 316 } | 325 } |
| 317 | 326 |
| 318 void HistoryBackendTestDelegate::DBLoaded() { | 327 void HistoryBackendTestDelegate::DBLoaded() { |
| 319 test_->loaded_ = true; | 328 test_->loaded_ = true; |
| 320 } | 329 } |
| 321 | 330 |
| (...skipping 2967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3289 // Verify that the second term is no longer returned as result, and also check | 3298 // Verify that the second term is no longer returned as result, and also check |
| 3290 // at the low level that it is gone for good. The term corresponding to the | 3299 // at the low level that it is gone for good. The term corresponding to the |
| 3291 // first URLRow should not be affected. | 3300 // first URLRow should not be affected. |
| 3292 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); | 3301 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); |
| 3293 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); | 3302 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); |
| 3294 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); | 3303 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); |
| 3295 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); | 3304 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
| 3296 } | 3305 } |
| 3297 | 3306 |
| 3298 } // namespace history | 3307 } // namespace history |
| OLD | NEW |