| 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 hash identifiers to spelling suggestions from spelling service |
| 9 // and stores these suggestions. Records user's actions on these suggestions. | 9 // and stores these suggestions. Records user's actions on these suggestions. |
| 10 // Periodically sends batches of user feedback to the spelling service. | 10 // Periodically sends batches of user feedback to the spelling service. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // existing_hashes); | 50 // existing_hashes); |
| 51 // sender.SelectedSuggestion(hash, suggestion_index); | 51 // sender.SelectedSuggestion(hash, suggestion_index); |
| 52 class FeedbackSender : public base::SupportsWeakPtr<FeedbackSender>, | 52 class FeedbackSender : public base::SupportsWeakPtr<FeedbackSender>, |
| 53 public net::URLFetcherDelegate { | 53 public net::URLFetcherDelegate { |
| 54 public: | 54 public: |
| 55 // Constructs a feedback sender. Keeps |request_context| in a scoped_refptr, | 55 // Constructs a feedback sender. Keeps |request_context| in a scoped_refptr, |
| 56 // because URLRequestContextGetter implements RefcountedThreadSafe. | 56 // because URLRequestContextGetter implements RefcountedThreadSafe. |
| 57 FeedbackSender(net::URLRequestContextGetter* request_context, | 57 FeedbackSender(net::URLRequestContextGetter* request_context, |
| 58 const std::string& language, | 58 const std::string& language, |
| 59 const std::string& country); | 59 const std::string& country); |
| 60 virtual ~FeedbackSender(); | 60 ~FeedbackSender() override; |
| 61 | 61 |
| 62 // Records that user selected suggestion |suggestion_index| for the | 62 // Records that user selected suggestion |suggestion_index| for the |
| 63 // misspelling identified by |hash|. | 63 // misspelling identified by |hash|. |
| 64 void SelectedSuggestion(uint32 hash, int suggestion_index); | 64 void SelectedSuggestion(uint32 hash, int suggestion_index); |
| 65 | 65 |
| 66 // Records that user added the misspelling identified by |hash| to the | 66 // Records that user added the misspelling identified by |hash| to the |
| 67 // dictionary. | 67 // dictionary. |
| 68 void AddedToDictionary(uint32 hash); | 68 void AddedToDictionary(uint32 hash); |
| 69 | 69 |
| 70 // Records that user right-clicked on the misspelling identified by |hash|, | 70 // Records that user right-clicked on the misspelling identified by |hash|, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void StartFeedbackCollection(); | 107 void StartFeedbackCollection(); |
| 108 | 108 |
| 109 // Sends out all previously collected data and stops collecting feedback, if | 109 // Sends out all previously collected data and stops collecting feedback, if |
| 110 // it was being collected. | 110 // it was being collected. |
| 111 void StopFeedbackCollection(); | 111 void StopFeedbackCollection(); |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 friend class FeedbackSenderTest; | 114 friend class FeedbackSenderTest; |
| 115 | 115 |
| 116 // net::URLFetcherDelegate implementation. Takes ownership of |source|. | 116 // net::URLFetcherDelegate implementation. Takes ownership of |source|. |
| 117 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 117 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 118 | 118 |
| 119 // Requests the document markers from all of the renderers to determine which | 119 // Requests the document markers from all of the renderers to determine which |
| 120 // feedback can be finalized. Finalizes feedback for renderers that are gone. | 120 // feedback can be finalized. Finalizes feedback for renderers that are gone. |
| 121 // Called periodically when |timer_| fires. | 121 // Called periodically when |timer_| fires. |
| 122 void RequestDocumentMarkers(); | 122 void RequestDocumentMarkers(); |
| 123 | 123 |
| 124 // Sends out all feedback data. Resets the session-start timestamp to now. | 124 // Sends out all feedback data. Resets the session-start timestamp to now. |
| 125 // Restarts the timer that requests markers from the renderers. | 125 // Restarts the timer that requests markers from the renderers. |
| 126 void FlushFeedback(); | 126 void FlushFeedback(); |
| 127 | 127 |
| (...skipping 40 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 | 168 // If a sender is destroyed before it finishes, then sending feedback will be |
| 169 // canceled. | 169 // canceled. |
| 170 ScopedVector<net::URLFetcher> senders_; | 170 ScopedVector<net::URLFetcher> senders_; |
| 171 | 171 |
| 172 DISALLOW_COPY_AND_ASSIGN(FeedbackSender); | 172 DISALLOW_COPY_AND_ASSIGN(FeedbackSender); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace spellcheck | 175 } // namespace spellcheck |
| 176 | 176 |
| 177 #endif // CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ | 177 #endif // CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ |
| OLD | NEW |