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

Side by Side Diff: components/spellcheck/browser/misspelling.cc

Issue 2244083002: Componentize spellcheck [4]: spellcheck/browser and android java-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 // The |Misspelling| object stores the misspelling, a spellcheck suggestion for 5 // The |Misspelling| object stores the misspelling, a spellcheck suggestion for
6 // it, and user's action on it. The misspelling is stored as |context|, 6 // it, and user's action on it. The misspelling is stored as |context|,
7 // |location|, and |length| instead of only misspelled text, because the 7 // |location|, and |length| instead of only misspelled text, because the
8 // spellcheck algorithm uses the context. 8 // spellcheck algorithm uses the context.
9 9
10 #include "chrome/browser/spellchecker/misspelling.h" 10 #include "components/spellcheck/browser/misspelling.h"
11 11
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 14
15 namespace { 15 namespace {
16 16
17 // Builds a value from a list of spellcheck suggestions. 17 // Builds a value from a list of spellcheck suggestions.
18 std::unique_ptr<base::Value> BuildSuggestionsValue( 18 std::unique_ptr<base::Value> BuildSuggestionsValue(
19 const std::vector<base::string16>& list) { 19 const std::vector<base::string16>& list) {
20 std::unique_ptr<base::ListValue> result(new base::ListValue); 20 std::unique_ptr<base::ListValue> result(new base::ListValue);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 size_t ApproximateSerializedSize(const Misspelling& misspelling) { 79 size_t ApproximateSerializedSize(const Misspelling& misspelling) {
80 // Estimated by eyeballing JSON overhead. 80 // Estimated by eyeballing JSON overhead.
81 const size_t kNumberOfOverheadBytes = 180; 81 const size_t kNumberOfOverheadBytes = 180;
82 size_t result = misspelling.context.length() + kNumberOfOverheadBytes; 82 size_t result = misspelling.context.length() + kNumberOfOverheadBytes;
83 for (const base::string16& suggestion : misspelling.suggestions) 83 for (const base::string16& suggestion : misspelling.suggestions)
84 result += suggestion.size(); 84 result += suggestion.size();
85 return result; 85 return result;
86 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698