| 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 hash identifiers to spelling suggestions from spelling service | 8 // Assigns uint32_t hash identifiers to spelling suggestions from spelling |
| 9 // and stores these suggestions. Records user's actions on these suggestions. | 9 // service and stores these suggestions. Records user's actions on these |
| 10 // Periodically sends batches of user feedback to the spelling service. | 10 // suggestions. Periodically sends batches of user feedback to the spelling |
| 11 // service. |
| 11 | 12 |
| 12 #ifndef CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ | 13 #ifndef CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ |
| 13 #define CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ | 14 #define CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ |
| 14 | 15 |
| 16 #include <stddef.h> |
| 17 #include <stdint.h> |
| 18 |
| 15 #include <map> | 19 #include <map> |
| 16 #include <set> | 20 #include <set> |
| 17 #include <vector> | 21 #include <vector> |
| 18 | 22 |
| 23 #include "base/macros.h" |
| 19 #include "base/memory/scoped_vector.h" | 24 #include "base/memory/scoped_vector.h" |
| 20 #include "base/memory/weak_ptr.h" | 25 #include "base/memory/weak_ptr.h" |
| 21 #include "base/timer/timer.h" | 26 #include "base/timer/timer.h" |
| 22 #include "chrome/browser/spellchecker/feedback.h" | 27 #include "chrome/browser/spellchecker/feedback.h" |
| 23 #include "chrome/browser/spellchecker/misspelling.h" | 28 #include "chrome/browser/spellchecker/misspelling.h" |
| 24 #include "net/url_request/url_fetcher_delegate.h" | 29 #include "net/url_request/url_fetcher_delegate.h" |
| 25 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 26 | 31 |
| 27 class SpellCheckMarker; | 32 class SpellCheckMarker; |
| 28 struct SpellCheckResult; | 33 struct SpellCheckResult; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 54 public: | 59 public: |
| 55 // Constructs a feedback sender. Keeps |request_context| in a scoped_refptr, | 60 // Constructs a feedback sender. Keeps |request_context| in a scoped_refptr, |
| 56 // because URLRequestContextGetter implements RefcountedThreadSafe. | 61 // because URLRequestContextGetter implements RefcountedThreadSafe. |
| 57 FeedbackSender(net::URLRequestContextGetter* request_context, | 62 FeedbackSender(net::URLRequestContextGetter* request_context, |
| 58 const std::string& language, | 63 const std::string& language, |
| 59 const std::string& country); | 64 const std::string& country); |
| 60 ~FeedbackSender() override; | 65 ~FeedbackSender() override; |
| 61 | 66 |
| 62 // Records that user selected suggestion |suggestion_index| for the | 67 // Records that user selected suggestion |suggestion_index| for the |
| 63 // misspelling identified by |hash|. | 68 // misspelling identified by |hash|. |
| 64 void SelectedSuggestion(uint32 hash, int suggestion_index); | 69 void SelectedSuggestion(uint32_t hash, int suggestion_index); |
| 65 | 70 |
| 66 // Records that user added the misspelling identified by |hash| to the | 71 // Records that user added the misspelling identified by |hash| to the |
| 67 // dictionary. | 72 // dictionary. |
| 68 void AddedToDictionary(uint32 hash); | 73 void AddedToDictionary(uint32_t hash); |
| 69 | 74 |
| 70 // Records that user right-clicked on the misspelling identified by |hash|, | 75 // Records that user right-clicked on the misspelling identified by |hash|, |
| 71 // but did not select any suggestion. | 76 // but did not select any suggestion. |
| 72 void IgnoredSuggestions(uint32 hash); | 77 void IgnoredSuggestions(uint32_t hash); |
| 73 | 78 |
| 74 // Records that user did not choose any suggestion but manually corrected the | 79 // Records that user did not choose any suggestion but manually corrected the |
| 75 // misspelling identified by |hash| to string |correction|, which is not in | 80 // misspelling identified by |hash| to string |correction|, which is not in |
| 76 // the list of suggestions. | 81 // the list of suggestions. |
| 77 void ManuallyCorrected(uint32 hash, const base::string16& correction); | 82 void ManuallyCorrected(uint32_t hash, const base::string16& correction); |
| 78 | 83 |
| 79 // Records that user has the misspelling in the custom dictionary. The user | 84 // Records that user has the misspelling in the custom dictionary. The user |
| 80 // will never see the spellcheck suggestions for the misspelling. | 85 // will never see the spellcheck suggestions for the misspelling. |
| 81 void RecordInDictionary(uint32 hash); | 86 void RecordInDictionary(uint32_t hash); |
| 82 | 87 |
| 83 // Receives document markers for renderer with process ID |render_process_id| | 88 // Receives document markers for renderer with process ID |render_process_id| |
| 84 // when the renderer responds to a RequestDocumentMarkers() call. Finalizes | 89 // when the renderer responds to a RequestDocumentMarkers() call. Finalizes |
| 85 // feedback for the markers that are gone from the renderer. Sends feedback | 90 // feedback for the markers that are gone from the renderer. Sends feedback |
| 86 // data for the renderer with process ID |renderer_process_id| to the spelling | 91 // data for the renderer with process ID |renderer_process_id| to the spelling |
| 87 // service. If the current session has expired, then refreshes the session | 92 // service. If the current session has expired, then refreshes the session |
| 88 // start timestamp and sends out all of the feedback data. | 93 // start timestamp and sends out all of the feedback data. |
| 89 void OnReceiveDocumentMarkers(int renderer_process_id, | 94 void OnReceiveDocumentMarkers(int renderer_process_id, |
| 90 const std::vector<uint32>& markers); | 95 const std::vector<uint32_t>& markers); |
| 91 | 96 |
| 92 // Generates feedback data based on spellcheck results. The new feedback data | 97 // Generates feedback data based on spellcheck results. The new feedback data |
| 93 // is pending. Sets hash identifiers for |results|. Called when spelling | 98 // is pending. Sets hash identifiers for |results|. Called when spelling |
| 94 // service client receives results from the spelling service. Does not take | 99 // service client receives results from the spelling service. Does not take |
| 95 // ownership of |results|. | 100 // ownership of |results|. |
| 96 void OnSpellcheckResults(int renderer_process_id, | 101 void OnSpellcheckResults(int renderer_process_id, |
| 97 const base::string16& text, | 102 const base::string16& text, |
| 98 const std::vector<SpellCheckMarker>& markers, | 103 const std::vector<SpellCheckMarker>& markers, |
| 99 std::vector<SpellCheckResult>* results); | 104 std::vector<SpellCheckResult>* results); |
| 100 | 105 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // If a sender is destroyed before it finishes, then sending feedback will be | 173 // If a sender is destroyed before it finishes, then sending feedback will be |
| 169 // canceled. | 174 // canceled. |
| 170 ScopedVector<net::URLFetcher> senders_; | 175 ScopedVector<net::URLFetcher> senders_; |
| 171 | 176 |
| 172 DISALLOW_COPY_AND_ASSIGN(FeedbackSender); | 177 DISALLOW_COPY_AND_ASSIGN(FeedbackSender); |
| 173 }; | 178 }; |
| 174 | 179 |
| 175 } // namespace spellcheck | 180 } // namespace spellcheck |
| 176 | 181 |
| 177 #endif // CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ | 182 #endif // CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ |
| OLD | NEW |