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

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

Issue 2658013002: Remove ScopedVector in components/spellcheck (Closed)
Patch Set: code rebase Created 3 years, 10 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 FlushFeedback(); 370 FlushFeedback();
371 timer_.Stop(); 371 timer_.Stop();
372 } 372 }
373 373
374 void FeedbackSender::RandBytes(void* p, size_t len) { 374 void FeedbackSender::RandBytes(void* p, size_t len) {
375 crypto::RandBytes(p, len); 375 crypto::RandBytes(p, len);
376 } 376 }
377 377
378 void FeedbackSender::OnURLFetchComplete(const net::URLFetcher* source) { 378 void FeedbackSender::OnURLFetchComplete(const net::URLFetcher* source) {
379 for (ScopedVector<net::URLFetcher>::iterator sender_it = senders_.begin(); 379 for (auto sender_it = senders_.begin(); sender_it != senders_.end();
380 sender_it != senders_.end();
381 ++sender_it) { 380 ++sender_it) {
382 if (*sender_it == source) { 381 if ((*sender_it).get() == source) {
383 senders_.erase(sender_it); 382 senders_.erase(sender_it);
384 return; 383 return;
385 } 384 }
386 } 385 }
387 delete source; 386 delete source;
388 } 387 }
389 388
390 void FeedbackSender::RequestDocumentMarkers() { 389 void FeedbackSender::RequestDocumentMarkers() {
391 // Request document markers from all the renderers that are still alive. 390 // Request document markers from all the renderers that are still alive.
392 std::set<int> alive_renderers; 391 std::set<int> alive_renderers;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 std::unique_ptr<base::Value> feedback_value(BuildFeedbackValue( 433 std::unique_ptr<base::Value> feedback_value(BuildFeedbackValue(
435 BuildParams( 434 BuildParams(
436 BuildSuggestionInfo(feedback_data, is_first_feedback_batch, salt_), 435 BuildSuggestionInfo(feedback_data, is_first_feedback_batch, salt_),
437 language_, country_), 436 language_, country_),
438 api_version_)); 437 api_version_));
439 std::string feedback; 438 std::string feedback;
440 base::JSONWriter::Write(*feedback_value, &feedback); 439 base::JSONWriter::Write(*feedback_value, &feedback);
441 440
442 // The tests use this identifier to mock the URL fetcher. 441 // The tests use this identifier to mock the URL fetcher.
443 static const int kUrlFetcherId = 0; 442 static const int kUrlFetcherId = 0;
444 net::URLFetcher* sender = 443 auto sender = net::URLFetcher::Create(kUrlFetcherId, feedback_service_url_,
445 net::URLFetcher::Create(kUrlFetcherId, feedback_service_url_, 444 net::URLFetcher::POST, this);
446 net::URLFetcher::POST, this).release();
447 data_use_measurement::DataUseUserData::AttachToFetcher( 445 data_use_measurement::DataUseUserData::AttachToFetcher(
448 sender, data_use_measurement::DataUseUserData::SPELL_CHECKER); 446 sender.get(), data_use_measurement::DataUseUserData::SPELL_CHECKER);
449 sender->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | 447 sender->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES |
450 net::LOAD_DO_NOT_SAVE_COOKIES); 448 net::LOAD_DO_NOT_SAVE_COOKIES);
451 sender->SetUploadData("application/json", feedback); 449 sender->SetUploadData("application/json", feedback);
452 senders_.push_back(sender); 450 senders_.push_back(std::move(sender));
453 451
454 // Request context is nullptr in testing. 452 // Request context is nullptr in testing.
455 if (request_context_.get()) { 453 if (request_context_.get()) {
456 sender->SetRequestContext(request_context_.get()); 454 sender->SetRequestContext(request_context_.get());
457 sender->Start(); 455 sender->Start();
458 } 456 }
459 } 457 }
460 458
461 } // namespace spellcheck 459 } // namespace spellcheck
OLDNEW
« no previous file with comments | « components/spellcheck/browser/feedback_sender.h ('k') | components/spellcheck/renderer/spellcheck.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698