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

Side by Side Diff: services/prediction/dictionary_service.cc

Issue 1408793006: Convert "return local_var.Pass();" to "return local_var;". (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <algorithm> 5 #include <algorithm>
6 #include <deque> 6 #include <deque>
7 #include <fstream> 7 #include <fstream>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 // dictionary 72 // dictionary
73 base::FilePath dir_temp; 73 base::FilePath dir_temp;
74 PathService::Get(base::DIR_TEMP, &dir_temp); 74 PathService::Get(base::DIR_TEMP, &dir_temp);
75 std::string path = dir_temp.value() + "/main_en.dict"; 75 std::string path = dir_temp.value() + "/main_en.dict";
76 if (!default_dictionary_) { 76 if (!default_dictionary_) {
77 CreatDictFromEmbeddedDataIfNotExist(path); 77 CreatDictFromEmbeddedDataIfNotExist(path);
78 default_dictionary_ = scoped_ptr<latinime::Dictionary>( 78 default_dictionary_ = scoped_ptr<latinime::Dictionary>(
79 OpenDictionary(path, 0, prediction::kDictFile.size, false)); 79 OpenDictionary(path, 0, prediction::kDictFile.size, false));
80 if (!default_dictionary_) { 80 if (!default_dictionary_) {
81 return suggestion_words.Clone().Pass(); 81 return suggestion_words;
82 } 82 }
83 } 83 }
84 84
85 // dic_traverse_session 85 // dic_traverse_session
86 if (!default_session_) { 86 if (!default_session_) {
87 default_session_ = scoped_ptr<latinime::DicTraverseSession>( 87 default_session_ = scoped_ptr<latinime::DicTraverseSession>(
88 reinterpret_cast<latinime::DicTraverseSession*>( 88 reinterpret_cast<latinime::DicTraverseSession*>(
89 latinime::DicTraverseSession::getSessionInstance( 89 latinime::DicTraverseSession::getSessionInstance(
90 "en", prediction::kDictFile.size))); 90 "en", prediction::kDictFile.size)));
91 latinime::PrevWordsInfo empty_prev_words; 91 latinime::PrevWordsInfo empty_prev_words;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 j--; 159 j--;
160 } 160 }
161 } 161 }
162 } 162 }
163 163
164 for (std::deque<std::string>::iterator it = suggestion_words_reverse.begin(); 164 for (std::deque<std::string>::iterator it = suggestion_words_reverse.begin();
165 it != suggestion_words_reverse.end(); ++it) { 165 it != suggestion_words_reverse.end(); ++it) {
166 suggestion_words.push_back(mojo::String(*it)); 166 suggestion_words.push_back(mojo::String(*it));
167 } 167 }
168 168
169 return suggestion_words.Clone().Pass(); 169 return suggestion_words;
170 } 170 }
171 171
172 // modified from Android JniDataUtils::constructPrevWordsInfo 172 // modified from Android JniDataUtils::constructPrevWordsInfo
173 latinime::PrevWordsInfo DictionaryService::ProcessPrevWord( 173 latinime::PrevWordsInfo DictionaryService::ProcessPrevWord(
174 mojo::Array<PrevWordInfoPtr>& prev_words) { 174 mojo::Array<PrevWordInfoPtr>& prev_words) {
175 int prev_word_codepoints[MAX_PREV_WORD_COUNT_FOR_N_GRAM][MAX_WORD_LENGTH] = { 175 int prev_word_codepoints[MAX_PREV_WORD_COUNT_FOR_N_GRAM][MAX_WORD_LENGTH] = {
176 {0}}; 176 {0}};
177 int prev_word_codepoint_count[MAX_PREV_WORD_COUNT_FOR_N_GRAM] = {0}; 177 int prev_word_codepoint_count[MAX_PREV_WORD_COUNT_FOR_N_GRAM] = {0};
178 bool are_beginning_of_sentence[MAX_PREV_WORD_COUNT_FOR_N_GRAM] = {false}; 178 bool are_beginning_of_sentence[MAX_PREV_WORD_COUNT_FOR_N_GRAM] = {false};
179 int prevwords_count = std::min( 179 int prevwords_count = std::min(
(...skipping 11 matching lines...) Expand all
191 prev_word_codepoint_count[i] = prev_word_size; 191 prev_word_codepoint_count[i] = prev_word_size;
192 are_beginning_of_sentence[i] = prev_words[i]->is_beginning_of_sentence; 192 are_beginning_of_sentence[i] = prev_words[i]->is_beginning_of_sentence;
193 } 193 }
194 latinime::PrevWordsInfo prev_words_info = 194 latinime::PrevWordsInfo prev_words_info =
195 latinime::PrevWordsInfo(prev_word_codepoints, prev_word_codepoint_count, 195 latinime::PrevWordsInfo(prev_word_codepoints, prev_word_codepoint_count,
196 are_beginning_of_sentence, prevwords_count); 196 are_beginning_of_sentence, prevwords_count);
197 return prev_words_info; 197 return prev_words_info;
198 } 198 }
199 199
200 } // namespace prediction 200 } // namespace prediction
OLDNEW
« no previous file with comments | « services/kiosk_wm/merged_service_provider.cc ('k') | services/url_response_disk_cache/url_response_disk_cache_db.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698