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

Unified Diff: chrome/browser/spellchecker/feedback.cc

Issue 15318004: Store feedback for spellcheck results from spelling service (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/spellchecker/feedback.h ('k') | chrome/browser/spellchecker/feedback_sender_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/spellchecker/feedback.cc
diff --git a/chrome/browser/spellchecker/feedback.cc b/chrome/browser/spellchecker/feedback.cc
index 7e6ce5fb58af2886d1cd4bc2e81b099cc05f722a..4890beef6cf9029f4d2541b544da5395d231dfa2 100644
--- a/chrome/browser/spellchecker/feedback.cc
+++ b/chrome/browser/spellchecker/feedback.cc
@@ -6,7 +6,6 @@
#include <algorithm>
#include <iterator>
-#include <set>
namespace spellcheck {
@@ -17,7 +16,7 @@ Feedback::~Feedback() {
}
Misspelling* Feedback::GetMisspelling(uint32 hash) {
- std::map<uint32, Misspelling>::iterator it = misspellings_.find(hash);
+ HashMisspellingMap::iterator it = misspellings_.find(hash);
if (it == misspellings_.end())
return NULL;
return &it->second;
@@ -26,45 +25,41 @@ Misspelling* Feedback::GetMisspelling(uint32 hash) {
void Feedback::FinalizeRemovedMisspellings(
int renderer_process_id,
const std::vector<uint32>& remaining_markers) {
- std::map<int, std::vector<uint32> >::iterator i =
- hashes_.find(renderer_process_id);
+ RendererHashesMap::iterator i = hashes_.find(renderer_process_id);
if (i == hashes_.end() || i->second.empty())
return;
- std::vector<uint32> remaining_copy(remaining_markers);
- std::sort(remaining_copy.begin(), remaining_copy.end());
- std::sort(i->second.begin(), i->second.end());
+ HashCollection remaining_set(remaining_markers.begin(),
+ remaining_markers.end());
std::vector<uint32> removed_markers;
std::set_difference(i->second.begin(),
i->second.end(),
- remaining_copy.begin(),
- remaining_copy.end(),
+ remaining_set.begin(),
+ remaining_set.end(),
std::back_inserter(removed_markers));
for (std::vector<uint32>::const_iterator j = removed_markers.begin();
j != removed_markers.end();
++j) {
- std::map<uint32, Misspelling>::iterator k = misspellings_.find(*j);
+ HashMisspellingMap::iterator k = misspellings_.find(*j);
if (k != misspellings_.end() && !k->second.action.IsFinal())
k->second.action.Finalize();
}
}
bool Feedback::RendererHasMisspellings(int renderer_process_id) const {
- std::map<int, std::vector<uint32> >::const_iterator it =
- hashes_.find(renderer_process_id);
+ RendererHashesMap::const_iterator it = hashes_.find(renderer_process_id);
return it != hashes_.end() && !it->second.empty();
}
std::vector<Misspelling> Feedback::GetMisspellingsInRenderer(
int renderer_process_id) const {
std::vector<Misspelling> result;
- std::map<int, std::vector<uint32> >::const_iterator i =
- hashes_.find(renderer_process_id);
+ RendererHashesMap::const_iterator i = hashes_.find(renderer_process_id);
if (i == hashes_.end() || i->second.empty())
return result;
- for (std::vector<uint32>::const_iterator j = i->second.begin();
+ for (HashCollection::const_iterator j = i->second.begin();
j != i->second.end();
++j) {
- std::map<uint32, Misspelling>::const_iterator k = misspellings_.find(*j);
+ HashMisspellingMap::const_iterator k = misspellings_.find(*j);
if (k != misspellings_.end())
result.push_back(k->second);
}
@@ -72,20 +67,19 @@ std::vector<Misspelling> Feedback::GetMisspellingsInRenderer(
}
void Feedback::EraseFinalizedMisspellings(int renderer_process_id) {
- std::map<int, std::vector<uint32> >::iterator i =
- hashes_.find(renderer_process_id);
+ RendererHashesMap::iterator i = hashes_.find(renderer_process_id);
if (i == hashes_.end() || i->second.empty())
return;
- std::vector<uint32> pending;
- for (std::vector<uint32>::const_iterator j = i->second.begin();
+ HashCollection pending;
+ for (HashCollection::const_iterator j = i->second.begin();
j != i->second.end();
++j) {
- std::map<uint32, Misspelling>::iterator k = misspellings_.find(*j);
+ HashMisspellingMap::iterator k = misspellings_.find(*j);
if (k != misspellings_.end()) {
if (k->second.action.IsFinal())
misspellings_.erase(k);
else
- pending.push_back(*j);
+ pending.insert(*j);
}
}
i->second.swap(pending);
@@ -98,7 +92,7 @@ bool Feedback::HasMisspelling(uint32 hash) const {
void Feedback::AddMisspelling(int renderer_process_id,
const Misspelling& misspelling) {
misspellings_[misspelling.hash] = misspelling;
- hashes_[renderer_process_id].push_back(misspelling.hash);
+ hashes_[renderer_process_id].insert(misspelling.hash);
}
bool Feedback::Empty() const {
@@ -107,7 +101,7 @@ bool Feedback::Empty() const {
std::vector<int> Feedback::GetRendersWithMisspellings() const {
std::vector<int> result;
- for (std::map<int, std::vector<uint32> >::const_iterator it = hashes_.begin();
+ for (RendererHashesMap::const_iterator it = hashes_.begin();
it != hashes_.end();
++it) {
if (!it->second.empty())
@@ -117,7 +111,7 @@ std::vector<int> Feedback::GetRendersWithMisspellings() const {
}
void Feedback::FinalizeAllMisspellings() {
- for (std::map<uint32, Misspelling>::iterator it = misspellings_.begin();
+ for (HashMisspellingMap::iterator it = misspellings_.begin();
it != misspellings_.end();
++it) {
if (!it->second.action.IsFinal())
@@ -127,7 +121,7 @@ void Feedback::FinalizeAllMisspellings() {
std::vector<Misspelling> Feedback::GetAllMisspellings() const {
std::vector<Misspelling> result;
- for (std::map<uint32, Misspelling>::const_iterator it = misspellings_.begin();
+ for (HashMisspellingMap::const_iterator it = misspellings_.begin();
it != misspellings_.end();
++it) {
result.push_back(it->second);
« no previous file with comments | « chrome/browser/spellchecker/feedback.h ('k') | chrome/browser/spellchecker/feedback_sender_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698