Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/history/in_memory_history_backend.cc

Issue 808123003: Eliminate sending NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed fwd declaration of KeywordSearchUpdatedDetails Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/in_memory_history_backend.h" 5 #include "chrome/browser/history/in_memory_history_backend.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // runs without a browser process. generate_profile should really create 54 // runs without a browser process. generate_profile should really create
55 // a browser process, at which point this check can then be nuked. 55 // a browser process, at which point this check can then be nuked.
56 if (!g_browser_process) 56 if (!g_browser_process)
57 return; 57 return;
58 58
59 // Register for the notifications we care about. 59 // Register for the notifications we care about.
60 // We only want notifications for the associated profile. 60 // We only want notifications for the associated profile.
61 content::Source<Profile> source(profile_); 61 content::Source<Profile> source(profile_);
62 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source); 62 registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source);
63 registrar_.Add( 63 registrar_.Add(
64 this, chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED, source);
65 registrar_.Add(
66 this, chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_DELETED, source); 64 this, chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_DELETED, source);
67 } 65 }
68 66
69 void InMemoryHistoryBackend::DeleteAllSearchTermsForKeyword( 67 void InMemoryHistoryBackend::DeleteAllSearchTermsForKeyword(
70 KeywordID keyword_id) { 68 KeywordID keyword_id) {
71 // For simplicity, this will not remove the corresponding URLRows, but 69 // For simplicity, this will not remove the corresponding URLRows, but
72 // this is okay, as the main database does not do so either. 70 // this is okay, as the main database does not do so either.
73 db_->DeleteAllSearchTermsForKeyword(keyword_id); 71 db_->DeleteAllSearchTermsForKeyword(keyword_id);
74 } 72 }
75 73
76 void InMemoryHistoryBackend::OnURLVisited(HistoryService* history_service, 74 void InMemoryHistoryBackend::OnURLVisited(HistoryService* history_service,
77 ui::PageTransition transition, 75 ui::PageTransition transition,
78 const URLRow& row, 76 const URLRow& row,
79 const RedirectList& redirects, 77 const RedirectList& redirects,
80 base::Time visit_time) { 78 base::Time visit_time) {
81 OnURLVisitedOrModified(row); 79 OnURLVisitedOrModified(row);
82 } 80 }
83 81
84 void InMemoryHistoryBackend::OnURLsModified(HistoryService* history_service, 82 void InMemoryHistoryBackend::OnURLsModified(HistoryService* history_service,
85 const URLRows& changed_urls) { 83 const URLRows& changed_urls) {
86 for (const auto& row : changed_urls) { 84 for (const auto& row : changed_urls) {
87 OnURLVisitedOrModified(row); 85 OnURLVisitedOrModified(row);
88 } 86 }
89 } 87 }
90 88
89 void InMemoryHistoryBackend::HistoryKeywordSearchTermUpdated(
90 HistoryService* history_service,
91 const URLRow& row,
92 KeywordID keyword_id,
93 const base::string16& term) {
94 OnKeywordSearchTermUpdated(row, keyword_id, term);
95 }
96
91 void InMemoryHistoryBackend::Observe( 97 void InMemoryHistoryBackend::Observe(
92 int type, 98 int type,
93 const content::NotificationSource& source, 99 const content::NotificationSource& source,
94 const content::NotificationDetails& details) { 100 const content::NotificationDetails& details) {
95 switch (type) { 101 switch (type) {
96 case chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED:
97 OnKeywordSearchTermUpdated(
98 *content::Details<KeywordSearchUpdatedDetails>(details).ptr());
99 break;
100 case chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_DELETED: 102 case chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_DELETED:
101 OnKeywordSearchTermDeleted( 103 OnKeywordSearchTermDeleted(
102 *content::Details<KeywordSearchDeletedDetails>(details).ptr()); 104 *content::Details<KeywordSearchDeletedDetails>(details).ptr());
103 break; 105 break;
104 case chrome::NOTIFICATION_HISTORY_URLS_DELETED: 106 case chrome::NOTIFICATION_HISTORY_URLS_DELETED:
105 OnURLsDeleted(*content::Details<URLsDeletedDetails>(details).ptr()); 107 OnURLsDeleted(*content::Details<URLsDeletedDetails>(details).ptr());
106 break; 108 break;
107 default: 109 default:
108 // For simplicity, the unit tests send us all notifications, even when 110 // For simplicity, the unit tests send us all notifications, even when
109 // we haven't registered for them, so don't assert here. 111 // we haven't registered for them, so don't assert here.
(...skipping 25 matching lines...) Expand all
135 // Delete all matching URLs in our database. 137 // Delete all matching URLs in our database.
136 for (URLRows::const_iterator row = details.rows.begin(); 138 for (URLRows::const_iterator row = details.rows.begin();
137 row != details.rows.end(); ++row) { 139 row != details.rows.end(); ++row) {
138 // This will also delete the corresponding keyword search term. 140 // This will also delete the corresponding keyword search term.
139 // Ignore errors, as we typically only cache a subset of URLRows. 141 // Ignore errors, as we typically only cache a subset of URLRows.
140 db_->DeleteURLRow(row->id()); 142 db_->DeleteURLRow(row->id());
141 } 143 }
142 } 144 }
143 145
144 void InMemoryHistoryBackend::OnKeywordSearchTermUpdated( 146 void InMemoryHistoryBackend::OnKeywordSearchTermUpdated(
145 const KeywordSearchUpdatedDetails& details) { 147 const URLRow& row,
146 DCHECK(details.url_row.id()); 148 KeywordID keyword_id,
147 db_->InsertOrUpdateURLRowByID(details.url_row); 149 const base::string16& term) {
148 db_->SetKeywordSearchTermsForURL( 150 DCHECK(row.id());
149 details.url_row.id(), details.keyword_id, details.term); 151 db_->InsertOrUpdateURLRowByID(row);
152 db_->SetKeywordSearchTermsForURL(row.id(), keyword_id, term);
150 } 153 }
151 154
152 void InMemoryHistoryBackend::OnKeywordSearchTermDeleted( 155 void InMemoryHistoryBackend::OnKeywordSearchTermDeleted(
153 const KeywordSearchDeletedDetails& details) { 156 const KeywordSearchDeletedDetails& details) {
154 // For simplicity, this will not remove the corresponding URLRow, but this is 157 // For simplicity, this will not remove the corresponding URLRow, but this is
155 // okay, as the main database does not do so either. 158 // okay, as the main database does not do so either.
156 db_->DeleteKeywordSearchTermForURL(details.url_row_id); 159 db_->DeleteKeywordSearchTermForURL(details.url_row_id);
157 } 160 }
158 161
159 } // namespace history 162 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698