Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "content/browser/find_request_manager.h" | 5 #include "content/browser/find_request_manager.h" |
| 6 | 6 |
| 7 #include "content/browser/frame_host/render_frame_host_impl.h" | 7 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/common/frame_messages.h" | 9 #include "content/common/frame_messages.h" |
| 10 #include "content/common/input_messages.h" | 10 #include "content/common/input_messages.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 FindRequestManager::FindMatchRectsState::~FindMatchRectsState() {} | 84 FindRequestManager::FindMatchRectsState::~FindMatchRectsState() {} |
| 85 #endif | 85 #endif |
| 86 | 86 |
| 87 // static | 87 // static |
| 88 const int FindRequestManager::kInvalidId = -1; | 88 const int FindRequestManager::kInvalidId = -1; |
| 89 | 89 |
| 90 FindRequestManager::FindRequestManager(WebContentsImpl* web_contents) | 90 FindRequestManager::FindRequestManager(WebContentsImpl* web_contents) |
| 91 : WebContentsObserver(web_contents), | 91 : WebContentsObserver(web_contents), |
| 92 contents_(web_contents), | 92 contents_(web_contents), |
| 93 current_session_id_(kInvalidId), | 93 current_session_id_(kInvalidId), |
| 94 pending_find_next_reply_(nullptr), | |
| 94 pending_active_match_ordinal_(false), | 95 pending_active_match_ordinal_(false), |
| 95 number_of_matches_(0), | 96 number_of_matches_(0), |
| 96 active_frame_(nullptr), | 97 active_frame_(nullptr), |
| 97 relative_active_match_ordinal_(0), | 98 relative_active_match_ordinal_(0), |
| 98 active_match_ordinal_(0) {} | 99 active_match_ordinal_(0) {} |
| 99 | 100 |
| 100 FindRequestManager::~FindRequestManager() {} | 101 FindRequestManager::~FindRequestManager() {} |
| 101 | 102 |
| 102 void FindRequestManager::Find(int request_id, | 103 void FindRequestManager::Find(int request_id, |
| 103 const base::string16& search_text, | 104 const base::string16& search_text, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 active_frame_ = rfh; | 178 active_frame_ = rfh; |
| 178 relative_active_match_ordinal_ = active_match_ordinal; | 179 relative_active_match_ordinal_ = active_match_ordinal; |
| 179 UpdateActiveMatchOrdinal(); | 180 UpdateActiveMatchOrdinal(); |
| 180 } | 181 } |
| 181 if (pending_active_match_ordinal_ && request_id == current_request_.id) | 182 if (pending_active_match_ordinal_ && request_id == current_request_.id) |
| 182 pending_active_match_ordinal_ = false; | 183 pending_active_match_ordinal_ = false; |
| 183 AdvanceQueue(request_id); | 184 AdvanceQueue(request_id); |
| 184 } | 185 } |
| 185 | 186 |
| 186 if (!final_update) { | 187 if (!final_update) { |
| 187 NotifyFindReply(request_id, false /* final_update */); | 188 NotifyFindReply(request_id, false /* final_update */); |
|
lfg
2016/08/18 18:50:42
I noticed we can send NotifyFindReply with an requ
paulmeyer
2016/08/29 22:27:41
That sounds reasonable. I don't think there are an
| |
| 188 return; | 189 return; |
| 189 } | 190 } |
| 190 | 191 |
| 191 // This is the final update for this frame for the current find operation. | 192 // This is the final update for this frame for the current find operation. |
| 192 | 193 |
| 193 pending_replies_.erase(rfh); | 194 pending_initial_replies_.erase(rfh); |
| 194 if (request_id == current_session_id_ && !pending_replies_.empty()) { | 195 if (request_id == current_session_id_ && !pending_initial_replies_.empty()) |
|
lfg
2016/08/18 18:50:42
Why did you remove the NotifyFindReply() from this
paulmeyer
2016/08/29 22:27:41
I can't remember why I did that. It may have been
| |
| 195 NotifyFindReply(request_id, false /* final_update */); | |
| 196 return; | 196 return; |
| 197 } | |
| 198 DCHECK(request_id == current_session_id_ || | |
| 199 current_request_.options.findNext); | |
| 200 | 197 |
| 201 // This is the final update for the current find operation. | 198 // This is the final update for the current find operation. |
| 202 FinalUpdate(request_id, rfh); | 199 |
| 200 if (request_id == current_request_.id && request_id != current_session_id_) { | |
| 201 DCHECK(current_request_.options.findNext); | |
| 202 DCHECK(pending_find_next_reply_ == rfh); | |
|
lfg
2016/08/18 18:50:42
nit: DCHECK_EQ.
paulmeyer
2016/08/29 22:27:41
Done.
| |
| 203 pending_find_next_reply_ = nullptr; | |
| 204 } | |
| 205 | |
| 206 // The find results are normally reported under the ID of the find reply they | |
| 207 // came from (|request_id|), but if this really is the last update, then they | |
| 208 // need to be reported with the latest find request ID | |
| 209 // (|current_request_.id|), so that the receiver can know for sure that all | |
| 210 // issued find requests have completed. | |
|
lfg
2016/08/18 18:50:42
See my comment above, I don't think we should ever
paulmeyer
2016/08/29 22:27:41
Done.
| |
| 211 int report_id = request_id; | |
| 212 if (pending_initial_replies_.empty() && !pending_find_next_reply_) | |
| 213 report_id = current_request_.id; | |
| 214 FinalUpdate(report_id, rfh); | |
| 203 } | 215 } |
| 204 | 216 |
| 205 void FindRequestManager::RemoveFrame(RenderFrameHost* rfh) { | 217 void FindRequestManager::RemoveFrame(RenderFrameHost* rfh) { |
| 206 if (current_session_id_ == kInvalidId || !CheckFrame(rfh)) | 218 if (current_session_id_ == kInvalidId || !CheckFrame(rfh)) |
| 207 return; | 219 return; |
| 208 | 220 |
| 209 // If matches are counted for the frame that is being removed, decrement the | 221 // If matches are counted for the frame that is being removed, decrement the |
| 210 // match total before erasing that entry. | 222 // match total before erasing that entry. |
| 211 auto it = matches_per_frame_.find(rfh); | 223 auto it = matches_per_frame_.find(rfh); |
| 212 if (it != matches_per_frame_.end()) { | 224 if (it != matches_per_frame_.end()) { |
| 213 number_of_matches_ -= it->second; | 225 number_of_matches_ -= it->second; |
| 214 matches_per_frame_.erase(it); | 226 matches_per_frame_.erase(it); |
| 215 } | 227 } |
| 216 | 228 |
| 217 // Update the active match ordinal, since it may have changed. | 229 // Update the active match ordinal, since it may have changed. |
| 218 if (active_frame_ == rfh) { | 230 if (active_frame_ == rfh) { |
| 219 active_frame_ = nullptr; | 231 active_frame_ = nullptr; |
| 220 relative_active_match_ordinal_ = 0; | 232 relative_active_match_ordinal_ = 0; |
| 233 selection_rect_ = gfx::Rect(); | |
| 221 } | 234 } |
| 222 UpdateActiveMatchOrdinal(); | 235 UpdateActiveMatchOrdinal(); |
| 223 | 236 |
| 224 #if defined(OS_ANDROID) | 237 #if defined(OS_ANDROID) |
| 225 // The removed frame may contain the nearest find result known so far. Note | 238 // The removed frame may contain the nearest find result known so far. Note |
| 226 // that once all queried frames have responded, if this result was the overall | 239 // that once all queried frames have responded, if this result was the overall |
| 227 // nearest, then no activation will occur. | 240 // nearest, then no activation will occur. |
| 228 if (rfh == activate_.nearest_frame) | 241 if (rfh == activate_.nearest_frame) |
| 229 activate_.nearest_frame = nullptr; | 242 activate_.nearest_frame = nullptr; |
| 230 | 243 |
| 231 // Match rects in the removed frame are no longer relevant. | 244 // Match rects in the removed frame are no longer relevant. |
| 232 if (match_rects_.frame_rects.count(rfh)) { | 245 if (match_rects_.frame_rects.count(rfh)) { |
| 233 match_rects_.frame_rects.erase(rfh); | 246 match_rects_.frame_rects.erase(rfh); |
| 234 ++match_rects_.known_version; | 247 ++match_rects_.known_version; |
| 235 } | 248 } |
| 236 | 249 |
| 237 // A reply should not be expected from the removed frame. | 250 // A reply should not be expected from the removed frame. |
| 238 RemoveNearestFindResultPendingReply(rfh); | 251 RemoveNearestFindResultPendingReply(rfh); |
| 239 RemoveFindMatchRectsPendingReply(rfh); | 252 RemoveFindMatchRectsPendingReply(rfh); |
| 240 #endif | 253 #endif |
| 241 | 254 |
| 242 if (pending_replies_.count(rfh)) { | 255 // If no pending find replies are expected for the removed frame, then just |
| 256 // report the updated results. | |
| 257 if (!pending_initial_replies_.count(rfh) && pending_find_next_reply_ != rfh) { | |
| 258 bool final_update = | |
| 259 pending_initial_replies_.empty() && !pending_find_next_reply_; | |
| 260 NotifyFindReply(current_session_id_, final_update); | |
|
lfg
2016/08/18 18:50:42
I don't understand why we avoid calling FinalUpdat
paulmeyer
2016/08/29 22:27:41
See comment on FinalUpdate(). In this case, a fram
lfg
2016/08/30 14:57:38
Is it possible that the final update will be sent
paulmeyer
2016/08/30 15:40:12
Yes, that is possible, and intended. Once all fram
| |
| 261 return; | |
| 262 } | |
| 263 | |
| 264 if (pending_initial_replies_.count(rfh)) { | |
| 243 // A reply should not be expected from the removed frame. | 265 // A reply should not be expected from the removed frame. |
| 244 pending_replies_.erase(rfh); | 266 pending_initial_replies_.erase(rfh); |
| 245 if (pending_replies_.empty()) { | 267 if (pending_initial_replies_.empty()) { |
| 246 FinalUpdate(current_request_.id, rfh); | 268 FinalUpdate(current_session_id_, rfh); |
|
lfg
2016/08/18 18:50:42
Do we want to send a FinalUpdate if pending_find_n
paulmeyer
2016/08/29 22:27:41
See comment on FinalUpdate().
| |
| 247 return; | |
| 248 } | 269 } |
| 249 } | 270 } |
| 250 | 271 |
| 251 NotifyFindReply(current_session_id_, | 272 if (pending_find_next_reply_ == rfh) { |
| 252 pending_replies_.empty() /* final_update */); | 273 // A reply should not be expected from the removed frame. |
| 274 pending_find_next_reply_ = nullptr; | |
| 275 FinalUpdate(current_request_.id, rfh); | |
|
lfg
2016/08/18 18:50:42
Same as above, do we want to send a FinalUpdate if
paulmeyer
2016/08/29 22:27:41
See comment on FinalUpdate().
| |
| 276 } | |
| 253 } | 277 } |
| 254 | 278 |
| 255 #if defined(OS_ANDROID) | 279 #if defined(OS_ANDROID) |
| 256 void FindRequestManager::ActivateNearestFindResult(float x, float y) { | 280 void FindRequestManager::ActivateNearestFindResult(float x, float y) { |
| 257 if (current_session_id_ == kInvalidId) | 281 if (current_session_id_ == kInvalidId) |
| 258 return; | 282 return; |
| 259 | 283 |
| 260 activate_ = ActivateNearestFindResultState(x, y); | 284 activate_ = ActivateNearestFindResultState(x, y); |
| 261 | 285 |
| 262 // Request from each frame the distance to the nearest find result (in that | 286 // Request from each frame the distance to the nearest find result (in that |
| 263 // frame) from the point (x, y), defined in find-in-page coordinates. | 287 // frame) from the point (x, y), defined in find-in-page coordinates. |
| 264 for (FrameTreeNode* node : contents_->GetFrameTree()->Nodes()) { | 288 for (FrameTreeNode* node : contents_->GetFrameTree()->Nodes()) { |
| 265 RenderFrameHost* rfh = node->current_frame_host(); | 289 RenderFrameHost* rfh = node->current_frame_host(); |
| 266 | 290 |
| 267 if (!CheckFrame(rfh)) | 291 if (!CheckFrame(rfh) || !rfh->IsRenderFrameLive()) |
| 268 continue; | 292 continue; |
| 269 | 293 |
| 270 activate_.pending_replies.insert(rfh); | 294 activate_.pending_replies.insert(rfh); |
| 271 rfh->Send(new FrameMsg_GetNearestFindResult( | 295 rfh->Send(new FrameMsg_GetNearestFindResult( |
| 272 rfh->GetRoutingID(), activate_.current_request_id, | 296 rfh->GetRoutingID(), activate_.current_request_id, |
| 273 activate_.x, activate_.y)); | 297 activate_.x, activate_.y)); |
| 274 } | 298 } |
| 275 } | 299 } |
| 276 | 300 |
| 277 void FindRequestManager::OnGetNearestFindResultReply(RenderFrameHost* rfh, | 301 void FindRequestManager::OnGetNearestFindResultReply(RenderFrameHost* rfh, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 292 } | 316 } |
| 293 | 317 |
| 294 void FindRequestManager::RequestFindMatchRects(int current_version) { | 318 void FindRequestManager::RequestFindMatchRects(int current_version) { |
| 295 match_rects_.pending_replies.clear(); | 319 match_rects_.pending_replies.clear(); |
| 296 match_rects_.request_version = current_version; | 320 match_rects_.request_version = current_version; |
| 297 | 321 |
| 298 // Request the latest find match rects from each frame. | 322 // Request the latest find match rects from each frame. |
| 299 for (FrameTreeNode* node : contents_->GetFrameTree()->Nodes()) { | 323 for (FrameTreeNode* node : contents_->GetFrameTree()->Nodes()) { |
| 300 RenderFrameHost* rfh = node->current_frame_host(); | 324 RenderFrameHost* rfh = node->current_frame_host(); |
| 301 | 325 |
| 302 if (!CheckFrame(rfh)) | 326 if (!CheckFrame(rfh) || !rfh->IsRenderFrameLive()) |
| 303 continue; | 327 continue; |
| 304 | 328 |
| 305 match_rects_.pending_replies.insert(rfh); | 329 match_rects_.pending_replies.insert(rfh); |
| 306 auto it = match_rects_.frame_rects.find(rfh); | 330 auto it = match_rects_.frame_rects.find(rfh); |
| 307 int version = (it != match_rects_.frame_rects.end()) | 331 int version = (it != match_rects_.frame_rects.end()) |
| 308 ? it->second.version : kInvalidId; | 332 ? it->second.version : kInvalidId; |
| 309 rfh->Send(new FrameMsg_FindMatchRects(rfh->GetRoutingID(), version)); | 333 rfh->Send(new FrameMsg_FindMatchRects(rfh->GetRoutingID(), version)); |
| 310 } | 334 } |
| 311 } | 335 } |
| 312 | 336 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 336 RemoveFrame(old_host); | 360 RemoveFrame(old_host); |
| 337 } | 361 } |
| 338 | 362 |
| 339 void FindRequestManager::FrameDeleted(RenderFrameHost* rfh) { | 363 void FindRequestManager::FrameDeleted(RenderFrameHost* rfh) { |
| 340 RemoveFrame(rfh); | 364 RemoveFrame(rfh); |
| 341 } | 365 } |
| 342 | 366 |
| 343 void FindRequestManager::Reset(const FindRequest& initial_request) { | 367 void FindRequestManager::Reset(const FindRequest& initial_request) { |
| 344 current_session_id_ = initial_request.id; | 368 current_session_id_ = initial_request.id; |
| 345 current_request_ = initial_request; | 369 current_request_ = initial_request; |
| 346 pending_replies_.clear(); | 370 pending_initial_replies_.clear(); |
| 371 pending_find_next_reply_ = nullptr; | |
| 347 pending_active_match_ordinal_ = true; | 372 pending_active_match_ordinal_ = true; |
| 348 matches_per_frame_.clear(); | 373 matches_per_frame_.clear(); |
| 349 number_of_matches_ = 0; | 374 number_of_matches_ = 0; |
| 350 active_frame_ = nullptr; | 375 active_frame_ = nullptr; |
| 351 relative_active_match_ordinal_ = 0; | 376 relative_active_match_ordinal_ = 0; |
| 352 active_match_ordinal_ = 0; | 377 active_match_ordinal_ = 0; |
| 353 selection_rect_ = gfx::Rect(); | 378 selection_rect_ = gfx::Rect(); |
| 354 #if defined(OS_ANDROID) | 379 #if defined(OS_ANDROID) |
| 355 activate_ = ActivateNearestFindResultState(); | 380 activate_ = ActivateNearestFindResultState(); |
| 356 match_rects_.pending_replies.clear(); | 381 match_rects_.pending_replies.clear(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 return; | 418 return; |
| 394 } | 419 } |
| 395 | 420 |
| 396 find_request_queue_.pop(); | 421 find_request_queue_.pop(); |
| 397 if (!find_request_queue_.empty()) | 422 if (!find_request_queue_.empty()) |
| 398 FindInternal(find_request_queue_.front()); | 423 FindInternal(find_request_queue_.front()); |
| 399 } | 424 } |
| 400 | 425 |
| 401 void FindRequestManager::SendFindIPC(const FindRequest& request, | 426 void FindRequestManager::SendFindIPC(const FindRequest& request, |
| 402 RenderFrameHost* rfh) { | 427 RenderFrameHost* rfh) { |
| 403 pending_replies_.insert(rfh); | 428 DCHECK(CheckFrame(rfh)); |
| 429 DCHECK(rfh->IsRenderFrameLive()); | |
| 430 | |
| 431 if (request.options.findNext) | |
| 432 pending_find_next_reply_ = rfh; | |
| 433 else | |
| 434 pending_initial_replies_.insert(rfh); | |
| 435 | |
| 404 rfh->Send(new FrameMsg_Find(rfh->GetRoutingID(), request.id, | 436 rfh->Send(new FrameMsg_Find(rfh->GetRoutingID(), request.id, |
| 405 request.search_text, request.options)); | 437 request.search_text, request.options)); |
| 406 } | 438 } |
| 407 | 439 |
| 408 void FindRequestManager::NotifyFindReply(int request_id, | 440 void FindRequestManager::NotifyFindReply(int request_id, |
| 409 bool final_update) const { | 441 bool final_update) const { |
| 410 if (request_id == kInvalidId) { | 442 if (request_id == kInvalidId) { |
| 411 NOTREACHED(); | 443 NOTREACHED(); |
| 412 return; | 444 return; |
| 413 } | 445 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 430 bool matches_only, | 462 bool matches_only, |
| 431 bool wrap) const { | 463 bool wrap) const { |
| 432 FrameTreeNode* node = | 464 FrameTreeNode* node = |
| 433 static_cast<RenderFrameHostImpl*>(from_rfh)->frame_tree_node(); | 465 static_cast<RenderFrameHostImpl*>(from_rfh)->frame_tree_node(); |
| 434 | 466 |
| 435 while ((node = TraverseNode(node, forward, wrap)) != nullptr) { | 467 while ((node = TraverseNode(node, forward, wrap)) != nullptr) { |
| 436 if (!CheckFrame(node->current_frame_host())) | 468 if (!CheckFrame(node->current_frame_host())) |
| 437 continue; | 469 continue; |
| 438 RenderFrameHost* current_rfh = node->current_frame_host(); | 470 RenderFrameHost* current_rfh = node->current_frame_host(); |
| 439 if (!matches_only || matches_per_frame_.find(current_rfh)->second || | 471 if (!matches_only || matches_per_frame_.find(current_rfh)->second || |
| 440 pending_replies_.count(current_rfh)) { | 472 pending_initial_replies_.count(current_rfh)) { |
| 441 // Note that if there is still a pending reply expected for this frame, | 473 // Note that if there is still a pending reply expected for this frame, |
| 442 // then it may have unaccounted matches and will not be skipped via | 474 // then it may have unaccounted matches and will not be skipped via |
| 443 // |matches_only|. | 475 // |matches_only|. |
| 444 return node->current_frame_host(); | 476 return node->current_frame_host(); |
| 445 } | 477 } |
| 446 if (wrap && node->current_frame_host() == from_rfh) | 478 if (wrap && node->current_frame_host() == from_rfh) |
| 447 return nullptr; | 479 return nullptr; |
| 448 } | 480 } |
| 449 | 481 |
| 450 return nullptr; | 482 return nullptr; |
| 451 } | 483 } |
| 452 | 484 |
| 453 void FindRequestManager::AddFrame(RenderFrameHost* rfh) { | 485 void FindRequestManager::AddFrame(RenderFrameHost* rfh) { |
| 454 if (!rfh || !rfh->IsRenderFrameLive()) | 486 if (!rfh || !rfh->IsRenderFrameLive()) |
| 455 return; | 487 return; |
| 456 | 488 |
| 457 // A frame that is already being searched should not be added again. | 489 // A frame that is already being searched should not be added again. |
| 458 DCHECK(!CheckFrame(rfh)); | 490 DCHECK(!CheckFrame(rfh)); |
| 459 | 491 |
| 460 matches_per_frame_[rfh] = 0; | 492 matches_per_frame_[rfh] = 0; |
| 461 | 493 |
| 462 FindRequest request = current_request_; | 494 FindRequest request = current_request_; |
| 463 request.id = current_session_id_; | 495 request.id = current_session_id_; |
| 464 request.options.findNext = false; | 496 request.options.findNext = false; |
| 465 SendFindIPC(request, rfh); | 497 SendFindIPC(request, rfh); |
| 466 } | 498 } |
| 467 | 499 |
| 468 bool FindRequestManager::CheckFrame(RenderFrameHost* rfh) const { | 500 bool FindRequestManager::CheckFrame(RenderFrameHost* rfh) const { |
| 469 return rfh && rfh->IsRenderFrameLive() && matches_per_frame_.count(rfh); | 501 return rfh && matches_per_frame_.count(rfh); |
|
lfg
2016/08/18 18:50:42
I don't understand the reason for this change.
paulmeyer
2016/08/29 22:27:41
I discovered that I don't actually want to check I
lfg
2016/08/30 14:57:38
Can you add add a comment in the places that this
paulmeyer
2016/08/30 15:40:12
I don't think that is necessary. If you look at th
lfg
2016/08/30 15:43:23
Acknowledged.
| |
| 470 } | 502 } |
| 471 | 503 |
| 472 void FindRequestManager::UpdateActiveMatchOrdinal() { | 504 void FindRequestManager::UpdateActiveMatchOrdinal() { |
| 473 active_match_ordinal_ = 0; | 505 active_match_ordinal_ = 0; |
| 474 | 506 |
| 475 if (!active_frame_ || !relative_active_match_ordinal_) { | 507 if (!active_frame_ || !relative_active_match_ordinal_) { |
| 476 DCHECK(!active_frame_ && !relative_active_match_ordinal_); | 508 DCHECK(!active_frame_ && !relative_active_match_ordinal_); |
| 477 return; | 509 return; |
| 478 } | 510 } |
| 479 | 511 |
| 480 // Traverse the frame tree backwards (in search order) and count all of the | 512 // Traverse the frame tree backwards (in search order) and count all of the |
| 481 // matches in frames before the frame with the active match, in order to | 513 // matches in frames before the frame with the active match, in order to |
| 482 // determine the overall active match ordinal. | 514 // determine the overall active match ordinal. |
| 483 RenderFrameHost* frame = active_frame_; | 515 RenderFrameHost* frame = active_frame_; |
| 484 while ((frame = Traverse(frame, | 516 while ((frame = Traverse(frame, |
| 485 false /* forward */, | 517 false /* forward */, |
| 486 true /* matches_only */, | 518 true /* matches_only */, |
| 487 false /* wrap */)) != nullptr) { | 519 false /* wrap */)) != nullptr) { |
| 488 active_match_ordinal_ += matches_per_frame_[frame]; | 520 active_match_ordinal_ += matches_per_frame_[frame]; |
| 489 } | 521 } |
| 490 active_match_ordinal_ += relative_active_match_ordinal_; | 522 active_match_ordinal_ += relative_active_match_ordinal_; |
| 491 } | 523 } |
| 492 | 524 |
| 493 void FindRequestManager::FinalUpdate(int request_id, RenderFrameHost* rfh) { | 525 void FindRequestManager::FinalUpdate(int request_id, RenderFrameHost* rfh) { |
| 494 if (!number_of_matches_ || | 526 if (!number_of_matches_ || |
| 495 !pending_active_match_ordinal_ || | 527 (active_match_ordinal_ && !pending_active_match_ordinal_) || |
| 496 request_id != current_request_.id) { | 528 request_id != current_request_.id) { |
| 497 NotifyFindReply(request_id, true /* final_update */); | 529 // All the find results for |request_id| are in and ready to report. Note |
| 530 // that |final_update| will be set to false if there are still pending | |
| 531 // replies expected from the initial find request. | |
| 532 NotifyFindReply(request_id, | |
| 533 pending_initial_replies_.empty() /* final_update */); | |
|
lfg
2016/08/18 18:50:42
The fact that FinalUpdate() doesn't always send a
paulmeyer
2016/08/29 22:27:41
FinalUpdate() is called once all the replies have
lfg
2016/08/30 14:57:38
Can you update the comment on the header to reflec
paulmeyer
2016/08/30 15:40:12
Done. I also renamed FinalUpdate() to FinalUpdateR
| |
| 498 AdvanceQueue(request_id); | 534 AdvanceQueue(request_id); |
| 499 return; | 535 return; |
| 500 } | 536 } |
| 501 | 537 |
| 502 // There are matches, but no active match was returned, so another find next | 538 // There are matches, but no active match was returned, so another find next |
| 503 // request must be sent. | 539 // request must be sent. |
| 504 | 540 |
| 505 RenderFrameHost* target_rfh; | 541 RenderFrameHost* target_rfh; |
| 506 if (current_request_.options.findNext) { | 542 if (current_request_.options.findNext) { |
| 507 // If this was a find next operation, then the active match will be in the | 543 // If this was a find next operation, then the active match will be in the |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 aggregate_rects.end(), frame_rects.begin(), frame_rects.end()); | 616 aggregate_rects.end(), frame_rects.begin(), frame_rects.end()); |
| 581 } | 617 } |
| 582 } | 618 } |
| 583 contents_->NotifyFindMatchRectsReply( | 619 contents_->NotifyFindMatchRectsReply( |
| 584 match_rects_.known_version, aggregate_rects, match_rects_.active_rect); | 620 match_rects_.known_version, aggregate_rects, match_rects_.active_rect); |
| 585 } | 621 } |
| 586 } | 622 } |
| 587 #endif | 623 #endif |
| 588 | 624 |
| 589 } // namespace content | 625 } // namespace content |
| OLD | NEW |