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

Side by Side Diff: chrome/browser/spellchecker/feedback_sender.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 |FeedbackSender| object stores the user feedback to spellcheck 5 // The |FeedbackSender| object stores the user feedback to spellcheck
6 // suggestions in a |Feedback| object. 6 // suggestions in a |Feedback| object.
7 // 7 //
8 // When spelling service returns spellcheck results, these results first arrive 8 // When spelling service returns spellcheck results, these results first arrive
9 // in |FeedbackSender| to assign hash identifiers for each 9 // in |FeedbackSender| to assign hash identifiers for each
10 // misspelling-suggestion pair. If the spelling service identifies the same 10 // misspelling-suggestion pair. If the spelling service identifies the same
(...skipping 13 matching lines...) Expand all
24 // |FeedbackSender| periodically requests a list of hashes of all remaining 24 // |FeedbackSender| periodically requests a list of hashes of all remaining
25 // misspellings in renderers. When a renderer responds with a list of hashes, 25 // misspellings in renderers. When a renderer responds with a list of hashes,
26 // |FeedbackSender| uses the list to determine which misspellings are no longer 26 // |FeedbackSender| uses the list to determine which misspellings are no longer
27 // displayed to the user and sends the current state of user feedback to the 27 // displayed to the user and sends the current state of user feedback to the
28 // spelling service. 28 // spelling service.
29 29
30 #include "chrome/browser/spellchecker/feedback_sender.h" 30 #include "chrome/browser/spellchecker/feedback_sender.h"
31 31
32 #include <algorithm> 32 #include <algorithm>
33 #include <iterator> 33 #include <iterator>
34 #include <utility>
34 35
35 #include "base/command_line.h" 36 #include "base/command_line.h"
36 #include "base/hash.h" 37 #include "base/hash.h"
37 #include "base/json/json_writer.h" 38 #include "base/json/json_writer.h"
38 #include "base/location.h" 39 #include "base/location.h"
39 #include "base/metrics/field_trial.h" 40 #include "base/metrics/field_trial.h"
40 #include "base/single_thread_task_runner.h" 41 #include "base/single_thread_task_runner.h"
41 #include "base/stl_util.h" 42 #include "base/stl_util.h"
42 #include "base/strings/string_number_conversions.h" 43 #include "base/strings/string_number_conversions.h"
43 #include "base/strings/stringprintf.h" 44 #include "base/strings/stringprintf.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 base::Uint64ToString(BuildAnonymousHash( 128 base::Uint64ToString(BuildAnonymousHash(
128 salt, raw_misspelling.context.substr(raw_misspelling.location, 129 salt, raw_misspelling.context.substr(raw_misspelling.location,
129 raw_misspelling.length)))); 130 raw_misspelling.length))));
130 // repeated fixed64 user_suggestion_id = ... 131 // repeated fixed64 user_suggestion_id = ...
131 std::unique_ptr<base::ListValue> suggestion_list(new base::ListValue()); 132 std::unique_ptr<base::ListValue> suggestion_list(new base::ListValue());
132 for (const auto& suggestion : raw_misspelling.suggestions) { 133 for (const auto& suggestion : raw_misspelling.suggestions) {
133 suggestion_list->AppendString( 134 suggestion_list->AppendString(
134 base::Uint64ToString(BuildAnonymousHash(salt, suggestion))); 135 base::Uint64ToString(BuildAnonymousHash(salt, suggestion)));
135 } 136 }
136 misspelling->Set("userSuggestionId", suggestion_list.release()); 137 misspelling->Set("userSuggestionId", suggestion_list.release());
137 list->Append(misspelling.release()); 138 list->Append(std::move(misspelling));
138 } 139 }
139 return list; 140 return list;
140 } 141 }
141 142
142 // Builds feedback parameters from |suggestion_info|, |language|, and |country|. 143 // Builds feedback parameters from |suggestion_info|, |language|, and |country|.
143 // Takes ownership of |suggestion_list|. 144 // Takes ownership of |suggestion_list|.
144 std::unique_ptr<base::DictionaryValue> BuildParams( 145 std::unique_ptr<base::DictionaryValue> BuildParams(
145 std::unique_ptr<base::ListValue> suggestion_info, 146 std::unique_ptr<base::ListValue> suggestion_info,
146 const std::string& language, 147 const std::string& language,
147 const std::string& country) { 148 const std::string& country) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 senders_.push_back(sender); 455 senders_.push_back(sender);
455 456
456 // Request context is nullptr in testing. 457 // Request context is nullptr in testing.
457 if (request_context_.get()) { 458 if (request_context_.get()) {
458 sender->SetRequestContext(request_context_.get()); 459 sender->SetRequestContext(request_context_.get());
459 sender->Start(); 460 sender->Start();
460 } 461 }
461 } 462 }
462 463
463 } // namespace spellcheck 464 } // namespace spellcheck
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698