| 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 // An object to record and send user feedback to spelling service. The spelling | 5 // An object to record and send user feedback to spelling service. The spelling |
| 6 // service uses the feedback to improve its suggestions. | 6 // service uses the feedback to improve its suggestions. |
| 7 // | 7 // |
| 8 // Assigns uint32_t hash identifiers to spelling suggestions from spelling | 8 // Assigns uint32_t hash identifiers to spelling suggestions from spelling |
| 9 // service and stores these suggestions. Records user's actions on these | 9 // service and stores these suggestions. Records user's actions on these |
| 10 // suggestions. Periodically sends batches of user feedback to the spelling | 10 // suggestions. Periodically sends batches of user feedback to the spelling |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // renderer_process_id, | 53 // renderer_process_id, |
| 54 // spellchecked_text, | 54 // spellchecked_text, |
| 55 // existing_hashes); | 55 // existing_hashes); |
| 56 // sender.SelectedSuggestion(hash, suggestion_index); | 56 // sender.SelectedSuggestion(hash, suggestion_index); |
| 57 class FeedbackSender : public base::SupportsWeakPtr<FeedbackSender>, | 57 class FeedbackSender : public base::SupportsWeakPtr<FeedbackSender>, |
| 58 public net::URLFetcherDelegate { | 58 public net::URLFetcherDelegate { |
| 59 public: | 59 public: |
| 60 // Constructs a feedback sender. Keeps |request_context| in a scoped_refptr, | 60 // Constructs a feedback sender. Keeps |request_context| in a scoped_refptr, |
| 61 // because URLRequestContextGetter implements RefcountedThreadSafe. | 61 // because URLRequestContextGetter implements RefcountedThreadSafe. |
| 62 FeedbackSender(net::URLRequestContextGetter* request_context, | 62 FeedbackSender(net::URLRequestContextGetter* request_context, |
| 63 const std::string& language, | 63 const std::string& language, const std::string& country); |
| 64 const std::string& country); | |
| 65 ~FeedbackSender() override; | 64 ~FeedbackSender() override; |
| 66 | 65 |
| 67 // Records that user selected suggestion |suggestion_index| for the | 66 // Records that user selected suggestion |suggestion_index| for the |
| 68 // misspelling identified by |hash|. | 67 // misspelling identified by |hash|. |
| 69 void SelectedSuggestion(uint32_t hash, int suggestion_index); | 68 void SelectedSuggestion(uint32_t hash, int suggestion_index); |
| 70 | 69 |
| 71 // Records that user added the misspelling identified by |hash| to the | 70 // Records that user added the misspelling identified by |hash| to the |
| 72 // dictionary. | 71 // dictionary. |
| 73 void AddedToDictionary(uint32_t hash); | 72 void AddedToDictionary(uint32_t hash); |
| 74 | 73 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 91 // data for the renderer with process ID |renderer_process_id| to the spelling | 90 // data for the renderer with process ID |renderer_process_id| to the spelling |
| 92 // service. If the current session has expired, then refreshes the session | 91 // service. If the current session has expired, then refreshes the session |
| 93 // start timestamp and sends out all of the feedback data. | 92 // start timestamp and sends out all of the feedback data. |
| 94 void OnReceiveDocumentMarkers(int renderer_process_id, | 93 void OnReceiveDocumentMarkers(int renderer_process_id, |
| 95 const std::vector<uint32_t>& markers); | 94 const std::vector<uint32_t>& markers); |
| 96 | 95 |
| 97 // Generates feedback data based on spellcheck results. The new feedback data | 96 // Generates feedback data based on spellcheck results. The new feedback data |
| 98 // is pending. Sets hash identifiers for |results|. Called when spelling | 97 // is pending. Sets hash identifiers for |results|. Called when spelling |
| 99 // service client receives results from the spelling service. Does not take | 98 // service client receives results from the spelling service. Does not take |
| 100 // ownership of |results|. | 99 // ownership of |results|. |
| 101 void OnSpellcheckResults(int renderer_process_id, | 100 void OnSpellcheckResults(int renderer_process_id, const base::string16& text, |
| 102 const base::string16& text, | |
| 103 const std::vector<SpellCheckMarker>& markers, | 101 const std::vector<SpellCheckMarker>& markers, |
| 104 std::vector<SpellCheckResult>* results); | 102 std::vector<SpellCheckResult>* results); |
| 105 | 103 |
| 106 // Receives updated language and country code for feedback. Finalizes and | 104 // Receives updated language and country code for feedback. Finalizes and |
| 107 // sends out all of the feedback data. | 105 // sends out all of the feedback data. |
| 108 void OnLanguageCountryChange(const std::string& language, | 106 void OnLanguageCountryChange(const std::string& language, |
| 109 const std::string& country); | 107 const std::string& country); |
| 110 | 108 |
| 111 // Starts collecting feedback, if it's not already being collected. | 109 // Starts collecting feedback, if it's not already being collected. |
| 112 void StartFeedbackCollection(); | 110 void StartFeedbackCollection(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // If a sender is destroyed before it finishes, then sending feedback will be | 171 // If a sender is destroyed before it finishes, then sending feedback will be |
| 174 // canceled. | 172 // canceled. |
| 175 ScopedVector<net::URLFetcher> senders_; | 173 ScopedVector<net::URLFetcher> senders_; |
| 176 | 174 |
| 177 DISALLOW_COPY_AND_ASSIGN(FeedbackSender); | 175 DISALLOW_COPY_AND_ASSIGN(FeedbackSender); |
| 178 }; | 176 }; |
| 179 | 177 |
| 180 } // namespace spellcheck | 178 } // namespace spellcheck |
| 181 | 179 |
| 182 #endif // CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ | 180 #endif // CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ |
| OLD | NEW |