| Index: content/test/test_find_request_manager.cc
|
| diff --git a/content/test/test_find_request_manager.cc b/content/test/test_find_request_manager.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..06576e23f17351b20f938f86e72a6ff65ce62d0e
|
| --- /dev/null
|
| +++ b/content/test/test_find_request_manager.cc
|
| @@ -0,0 +1,57 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/test/test_find_request_manager.h"
|
| +
|
| +#include "content/browser/web_contents/web_contents_impl.h"
|
| +
|
| +namespace content {
|
| +
|
| +TestFindRequestManager::TestFindRequestManager(WebContentsImpl* web_contents)
|
| + : FindRequestManager(web_contents),
|
| + last_request_id_(kInvalidId),
|
| + last_finished_request_id_(kInvalidId),
|
| + waiting_request_id_(kInvalidId) {}
|
| +
|
| +TestFindRequestManager::~TestFindRequestManager() {}
|
| +
|
| +void TestFindRequestManager::Find(int request_id,
|
| + const base::string16& search_text,
|
| + const blink::WebFindOptions& options) {
|
| + last_request_id_ = request_id;
|
| + FindRequestManager::Find(request_id, search_text, options);
|
| +}
|
| +
|
| +void TestFindRequestManager::WaitForFinalReply() {
|
| + if (last_finished_request_id_ == last_request_id_)
|
| + return;
|
| +
|
| + waiting_request_id_ = last_request_id_;
|
| + find_message_loop_runner_ = new content::MessageLoopRunner;
|
| + find_message_loop_runner_->Run();
|
| +}
|
| +
|
| +TestFindRequestManager::FindResults TestFindRequestManager::GetFindResults() {
|
| + FindResults results;
|
| + results.request_id = last_finished_request_id_;
|
| + results.number_of_matches = number_of_matches_;
|
| + results.active_match_ordinal = active_match_ordinal_;
|
| + return results;
|
| +}
|
| +
|
| +void TestFindRequestManager::NotifyFindReply(int request_id,
|
| + bool final_update) const {
|
| + if (final_update)
|
| + last_finished_request_id_ = request_id;
|
| +
|
| + // If we are waiting for a final reply and this is it, stop waiting.
|
| + if (find_message_loop_runner_.get() &&
|
| + last_finished_request_id_ >= waiting_request_id_) {
|
| + find_message_loop_runner_->Quit();
|
| + }
|
| +
|
| + FindRequestManager::NotifyFindReply(request_id, final_update);
|
| +}
|
| +
|
| +} // namespace content
|
|
|