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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 void OnSpellcheckResults(int renderer_process_id, | 96 void OnSpellcheckResults(int renderer_process_id, |
97 const string16& text, | 97 const string16& text, |
98 const std::vector<SpellCheckMarker>& markers, | 98 const std::vector<SpellCheckMarker>& markers, |
99 std::vector<SpellCheckResult>* results); | 99 std::vector<SpellCheckResult>* results); |
100 | 100 |
101 // Receives updated language and country code for feedback. Finalizes and | 101 // Receives updated language and country code for feedback. Finalizes and |
102 // sends out all of the feedback data. | 102 // sends out all of the feedback data. |
103 void OnLanguageCountryChange(const std::string& language, | 103 void OnLanguageCountryChange(const std::string& language, |
104 const std::string& country); | 104 const std::string& country); |
105 | 105 |
106 // Stops collecting feedback. Sends out all previously collected data. | |
107 void StopFeedbackCollection(); | |
groby-ooo-7-16
2013/11/21 02:48:41
Please put Start before Stop - makes sense both al
| |
108 | |
109 // Starts collecting feedback. | |
110 void StartFeedbackCollection(); | |
111 | |
106 private: | 112 private: |
107 friend class FeedbackSenderTest; | 113 friend class FeedbackSenderTest; |
108 | 114 |
109 // net::URLFetcherDelegate implementation. Takes ownership of |source|. | 115 // net::URLFetcherDelegate implementation. Takes ownership of |source|. |
110 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 116 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
111 | 117 |
112 // Requests the document markers from all of the renderers to determine which | 118 // Requests the document markers from all of the renderers to determine which |
113 // feedback can be finalized. Finalizes feedback for renderers that are gone. | 119 // feedback can be finalized. Finalizes feedback for renderers that are gone. |
114 // Called periodically when |timer_| fires. | 120 // Called periodically when |timer_| fires. |
115 void RequestDocumentMarkers(); | 121 void RequestDocumentMarkers(); |
116 | 122 |
117 // Sends out all feedback data. Resets the session-start timestamp to now. | 123 // Sends out all feedback data. Resets the session-start timestamp to now. |
118 // Restarts the timer that requests markers from the renderers. | 124 // Restarts the timer that requests markers from the renderers. |
119 void FlushFeedback(); | 125 void FlushFeedback(); |
120 | 126 |
121 // Sends out the |feedback_data|. | 127 // Sends out the |feedback_data|. |
122 void SendFeedback(const std::vector<Misspelling>& feedback_data, | 128 void SendFeedback(const std::vector<Misspelling>& feedback_data, |
123 bool is_first_feedback_batch); | 129 bool is_first_feedback_batch); |
124 | 130 |
125 // URL request context for the feedback senders. | 131 // URL request context for the feedback senders. |
126 scoped_refptr<net::URLRequestContextGetter> request_context_; | 132 scoped_refptr<net::URLRequestContextGetter> request_context_; |
127 | 133 |
134 // The feedback API version. | |
135 const std::string api_version_; | |
136 | |
128 // The language of text. The string is a BCP 47 language tag. | 137 // The language of text. The string is a BCP 47 language tag. |
129 std::string language_; | 138 std::string language_; |
130 | 139 |
131 // The country of origin. The string is the ISO 3166-1 alpha-3 code. | 140 // The country of origin. The string is the ISO 3166-1 alpha-3 code. |
132 std::string country_; | 141 std::string country_; |
133 | 142 |
134 // Misspelling counter used to generate unique hash identifier for each | 143 // Misspelling counter used to generate unique hash identifier for each |
135 // misspelling. | 144 // misspelling. |
136 size_t misspelling_counter_; | 145 size_t misspelling_counter_; |
137 | 146 |
(...skipping 19 matching lines...) Expand all Loading... | |
157 // If a sender is destroyed before it finishes, then sending feedback will be | 166 // If a sender is destroyed before it finishes, then sending feedback will be |
158 // canceled. | 167 // canceled. |
159 ScopedVector<net::URLFetcher> senders_; | 168 ScopedVector<net::URLFetcher> senders_; |
160 | 169 |
161 DISALLOW_COPY_AND_ASSIGN(FeedbackSender); | 170 DISALLOW_COPY_AND_ASSIGN(FeedbackSender); |
162 }; | 171 }; |
163 | 172 |
164 } // namespace spellcheck | 173 } // namespace spellcheck |
165 | 174 |
166 #endif // CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ | 175 #endif // CHROME_BROWSER_SPELLCHECKER_FEEDBACK_SENDER_H_ |
OLD | NEW |