| 516 | } |
| 517 | |
| 518 | void Processor::Search(SearchParams params) |
| 519 | { |
| 520 | /// @DebugNote |
| 521 | // Comment this line to run search in a debugger. |
| 522 | SetDeadline(chrono::steady_clock::now() + params.m_timeout); |
| 523 | |
| 524 | if (params.m_onStarted) |
| 525 | params.m_onStarted(); |
| 526 | |
| 527 | // IsCancelled is not enough here because it depends on PreRanker being initialized. |
| 528 | if (IsCancelled() && CancellationStatus() == base::Cancellable::Status::CancelCalled) |
| 529 | { |
| 530 | Results results; |
| 531 | results.SetEndMarker(true /* isCancelled */); |
| 532 | params.m_onResults(std::move(results)); |
| 533 | return; |
| 534 | } |
| 535 | |
| 536 | m_emitter.Init(std::move(params.m_onResults)); |
| 537 | |
| 538 | bool const viewportSearch = params.m_mode == Mode::Viewport; |
| 539 | |
| 540 | auto const & viewport = params.m_viewport; |
| 541 | ASSERT(viewport.IsValid(), ()); |
| 542 | |
| 543 | m_position = params.m_position; |
| 544 | |
| 545 | SetInputLocale(params.m_inputLocale); |
| 546 | |
| 547 | SetQuery(params.m_query, params.m_categorialRequest); |
| 548 | SetViewport(viewport); |
| 549 | |
| 550 | // Used to store the earliest available cancellation status: |
| 551 | // if the search has been cancelled, we need to pinpoint the reason |
| 552 | // for cancellation and a further call to CancellationStatus() may |
| 553 | // return a different result. |
| 554 | auto cancellationStatus = base::Cancellable::Status::Active; |
| 555 | |
| 556 | switch (params.m_mode) |
| 557 | { |
| 558 | case Mode::Everywhere: // fallthrough |
| 559 | case Mode::Viewport: // fallthrough |
| 560 | case Mode::Downloader: |
| 561 | { |
| 562 | Geocoder::Params geocoderParams; |
| 563 | InitGeocoder(geocoderParams, params); |
| 564 | InitPreRanker(geocoderParams, params); |
| 565 | InitRanker(geocoderParams, params); |
| 566 | |
| 567 | try |
| 568 | { |
| 569 | if (!SearchCoordinates() && !SearchDebug()) |
| 570 | { |
| 571 | SearchPlusCode(); |
| 572 | SearchPostcode(); |
| 573 | if (viewportSearch) |
| 574 | { |
| 575 | m_geocoder.GoInViewport(); |
no test coverage detected