| OLD | NEW |
| 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 Loading... |
| 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 (auto sender_it = senders_.begin(); sender_it != senders_.end(); | 379 for (ScopedVector<net::URLFetcher>::iterator sender_it = senders_.begin(); |
| 380 sender_it != senders_.end(); |
| 380 ++sender_it) { | 381 ++sender_it) { |
| 381 if ((*sender_it).get() == source) { | 382 if (*sender_it == source) { |
| 382 senders_.erase(sender_it); | 383 senders_.erase(sender_it); |
| 383 return; | 384 return; |
| 384 } | 385 } |
| 385 } | 386 } |
| 386 delete source; | 387 delete source; |
| 387 } | 388 } |
| 388 | 389 |
| 389 void FeedbackSender::RequestDocumentMarkers() { | 390 void FeedbackSender::RequestDocumentMarkers() { |
| 390 // Request document markers from all the renderers that are still alive. | 391 // Request document markers from all the renderers that are still alive. |
| 391 std::set<int> alive_renderers; | 392 std::set<int> alive_renderers; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 std::unique_ptr<base::Value> feedback_value(BuildFeedbackValue( | 434 std::unique_ptr<base::Value> feedback_value(BuildFeedbackValue( |
| 434 BuildParams( | 435 BuildParams( |
| 435 BuildSuggestionInfo(feedback_data, is_first_feedback_batch, salt_), | 436 BuildSuggestionInfo(feedback_data, is_first_feedback_batch, salt_), |
| 436 language_, country_), | 437 language_, country_), |
| 437 api_version_)); | 438 api_version_)); |
| 438 std::string feedback; | 439 std::string feedback; |
| 439 base::JSONWriter::Write(*feedback_value, &feedback); | 440 base::JSONWriter::Write(*feedback_value, &feedback); |
| 440 | 441 |
| 441 // The tests use this identifier to mock the URL fetcher. | 442 // The tests use this identifier to mock the URL fetcher. |
| 442 static const int kUrlFetcherId = 0; | 443 static const int kUrlFetcherId = 0; |
| 443 auto sender = net::URLFetcher::Create(kUrlFetcherId, feedback_service_url_, | 444 net::URLFetcher* sender = |
| 444 net::URLFetcher::POST, this); | 445 net::URLFetcher::Create(kUrlFetcherId, feedback_service_url_, |
| 446 net::URLFetcher::POST, this).release(); |
| 445 data_use_measurement::DataUseUserData::AttachToFetcher( | 447 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 446 sender.get(), data_use_measurement::DataUseUserData::SPELL_CHECKER); | 448 sender, data_use_measurement::DataUseUserData::SPELL_CHECKER); |
| 447 sender->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 449 sender->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 448 net::LOAD_DO_NOT_SAVE_COOKIES); | 450 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 449 sender->SetUploadData("application/json", feedback); | 451 sender->SetUploadData("application/json", feedback); |
| 450 senders_.push_back(std::move(sender)); | 452 senders_.push_back(sender); |
| 451 | 453 |
| 452 // Request context is nullptr in testing. | 454 // Request context is nullptr in testing. |
| 453 if (request_context_.get()) { | 455 if (request_context_.get()) { |
| 454 sender->SetRequestContext(request_context_.get()); | 456 sender->SetRequestContext(request_context_.get()); |
| 455 sender->Start(); | 457 sender->Start(); |
| 456 } | 458 } |
| 457 } | 459 } |
| 458 | 460 |
| 459 } // namespace spellcheck | 461 } // namespace spellcheck |
| OLD | NEW |