Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellCheckRequester.cpp

Issue 2871313002: Add histogram for Blink's spell check request interval (Closed)
Patch Set: Fri May 12 11:31:33 PDT 2017 Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 16 matching lines...) Expand all
27 27
28 #include "core/dom/Document.h" 28 #include "core/dom/Document.h"
29 #include "core/dom/Node.h" 29 #include "core/dom/Node.h"
30 #include "core/dom/TaskRunnerHelper.h" 30 #include "core/dom/TaskRunnerHelper.h"
31 #include "core/editing/EditingUtilities.h" 31 #include "core/editing/EditingUtilities.h"
32 #include "core/editing/markers/DocumentMarkerController.h" 32 #include "core/editing/markers/DocumentMarkerController.h"
33 #include "core/editing/spellcheck/SpellChecker.h" 33 #include "core/editing/spellcheck/SpellChecker.h"
34 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
35 #include "core/frame/Settings.h" 35 #include "core/frame/Settings.h"
36 #include "core/html/TextControlElement.h" 36 #include "core/html/TextControlElement.h"
37 #include "platform/Histogram.h"
37 #include "platform/text/TextCheckerClient.h" 38 #include "platform/text/TextCheckerClient.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 SpellCheckRequest::SpellCheckRequest(Range* checking_range, 42 SpellCheckRequest::SpellCheckRequest(Range* checking_range,
42 const String& text, 43 const String& text,
43 int request_number) 44 int request_number)
44 : requester_(nullptr), 45 : requester_(nullptr),
45 checking_range_(checking_range), 46 checking_range_(checking_range),
46 root_editable_element_( 47 root_editable_element_(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 DCHECK(!requester_); 119 DCHECK(!requester_);
119 DCHECK_EQ(request_data_.Sequence(), kUnrequestedTextCheckingSequence); 120 DCHECK_EQ(request_data_.Sequence(), kUnrequestedTextCheckingSequence);
120 requester_ = requester; 121 requester_ = requester;
121 request_data_.SetSequence(sequence); 122 request_data_.SetSequence(sequence);
122 } 123 }
123 124
124 SpellCheckRequester::SpellCheckRequester(LocalFrame& frame) 125 SpellCheckRequester::SpellCheckRequester(LocalFrame& frame)
125 : frame_(&frame), 126 : frame_(&frame),
126 last_request_sequence_(0), 127 last_request_sequence_(0),
127 last_processed_sequence_(0), 128 last_processed_sequence_(0),
129 last_request_time_(0.0),
128 timer_to_process_queued_request_( 130 timer_to_process_queued_request_(
129 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &frame), 131 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, &frame),
130 this, 132 this,
131 &SpellCheckRequester::TimerFiredToProcessQueuedRequest) {} 133 &SpellCheckRequester::TimerFiredToProcessQueuedRequest) {}
132 134
133 SpellCheckRequester::~SpellCheckRequester() {} 135 SpellCheckRequester::~SpellCheckRequester() {}
134 136
135 TextCheckerClient& SpellCheckRequester::Client() const { 137 TextCheckerClient& SpellCheckRequester::Client() const {
136 return GetFrame().GetSpellChecker().TextChecker(); 138 return GetFrame().GetSpellChecker().TextChecker();
137 } 139 }
138 140
139 void SpellCheckRequester::TimerFiredToProcessQueuedRequest(TimerBase*) { 141 void SpellCheckRequester::TimerFiredToProcessQueuedRequest(TimerBase*) {
140 DCHECK(!request_queue_.IsEmpty()); 142 DCHECK(!request_queue_.IsEmpty());
141 if (request_queue_.IsEmpty()) 143 if (request_queue_.IsEmpty())
142 return; 144 return;
143 145
144 InvokeRequest(request_queue_.TakeFirst()); 146 InvokeRequest(request_queue_.TakeFirst());
145 } 147 }
146 148
147 void SpellCheckRequester::RequestCheckingFor(const EphemeralRange& range) { 149 void SpellCheckRequester::RequestCheckingFor(const EphemeralRange& range) {
148 RequestCheckingFor(range, 0); 150 RequestCheckingFor(range, 0);
149 } 151 }
150 152
151 void SpellCheckRequester::RequestCheckingFor(const EphemeralRange& range, 153 void SpellCheckRequester::RequestCheckingFor(const EphemeralRange& range,
152 int request_num) { 154 int request_num) {
153 SpellCheckRequest* request = SpellCheckRequest::Create(range, request_num); 155 SpellCheckRequest* request = SpellCheckRequest::Create(range, request_num);
154 if (!request) 156 if (!request)
155 return; 157 return;
156 158
159 DEFINE_STATIC_LOCAL(CustomCountHistogram,
160 spell_checker_request_interval_histogram,
161 ("WebCore.SpellChecker.RequestInterval", 0, 10000, 50));
162 const double current_request_time = MonotonicallyIncreasingTime();
163 if (request_num == 0 && last_request_time_ > 0) {
164 const double interval_ms =
165 (current_request_time - last_request_time_) * 1000.0;
166 spell_checker_request_interval_histogram.Count(interval_ms);
167 }
168 last_request_time_ = current_request_time;
169
157 DCHECK_EQ(request->Data().Sequence(), kUnrequestedTextCheckingSequence); 170 DCHECK_EQ(request->Data().Sequence(), kUnrequestedTextCheckingSequence);
158 int sequence = ++last_request_sequence_; 171 int sequence = ++last_request_sequence_;
159 if (sequence == kUnrequestedTextCheckingSequence) 172 if (sequence == kUnrequestedTextCheckingSequence)
160 sequence = ++last_request_sequence_; 173 sequence = ++last_request_sequence_;
161 174
162 request->SetCheckerAndSequence(this, sequence); 175 request->SetCheckerAndSequence(this, sequence);
163 176
164 if (timer_to_process_queued_request_.IsActive() || processing_request_) { 177 if (timer_to_process_queued_request_.IsActive() || processing_request_) {
165 EnqueueRequest(request); 178 EnqueueRequest(request);
166 return; 179 return;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 DidCheck(sequence, results); 290 DidCheck(sequence, results);
278 } 291 }
279 292
280 DEFINE_TRACE(SpellCheckRequester) { 293 DEFINE_TRACE(SpellCheckRequester) {
281 visitor->Trace(frame_); 294 visitor->Trace(frame_);
282 visitor->Trace(processing_request_); 295 visitor->Trace(processing_request_);
283 visitor->Trace(request_queue_); 296 visitor->Trace(request_queue_);
284 } 297 }
285 298
286 } // namespace blink 299 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/spellcheck/SpellCheckRequester.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698