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

Unified Diff: components/test_runner/spell_check_client.cc

Issue 1852603002: Replacing most of web_task.h with base::Closure + base::WeakPtrFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-mocks-to-test-runner
Patch Set: Rebasing... Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/test_runner/spell_check_client.h ('k') | components/test_runner/test_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/spell_check_client.cc
diff --git a/components/test_runner/spell_check_client.cc b/components/test_runner/spell_check_client.cc
index 32bfd880b33219e9f5a01e355b52a689172e890c..68c663aa0a4c5763b5188bd66a62cccca9e0bf6d 100644
--- a/components/test_runner/spell_check_client.cc
+++ b/components/test_runner/spell_check_client.cc
@@ -6,39 +6,23 @@
#include <stddef.h>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/macros.h"
#include "components/test_runner/mock_grammar_check.h"
#include "components/test_runner/test_runner.h"
+#include "components/test_runner/web_task.h"
#include "components/test_runner/web_test_delegate.h"
#include "third_party/WebKit/public/web/WebTextCheckingCompletion.h"
#include "third_party/WebKit/public/web/WebTextCheckingResult.h"
namespace test_runner {
-namespace {
-
-class HostMethodTask : public WebMethodTask<SpellCheckClient> {
- public:
- typedef void (SpellCheckClient::*CallbackMethodType)();
- HostMethodTask(SpellCheckClient* object, CallbackMethodType callback)
- : WebMethodTask<SpellCheckClient>(object), callback_(callback) {}
-
- ~HostMethodTask() override {}
-
- void RunIfValid() override { (object_->*callback_)(); }
-
- private:
- CallbackMethodType callback_;
-
- DISALLOW_COPY_AND_ASSIGN(HostMethodTask);
-};
-
-} // namespace
-
SpellCheckClient::SpellCheckClient(TestRunner* test_runner)
: last_requested_text_checking_completion_(nullptr),
- test_runner_(test_runner) {
+ test_runner_(test_runner),
+ weak_factory_(this) {
DCHECK(test_runner);
}
@@ -107,7 +91,9 @@ void SpellCheckClient::requestCheckingOfText(
FinishLastTextCheck();
else
delegate_->PostDelayedTask(
- new HostMethodTask(this, &SpellCheckClient::FinishLastTextCheck), 0);
+ new WebCallbackTask(base::Bind(&SpellCheckClient::FinishLastTextCheck,
+ weak_factory_.GetWeakPtr())),
+ 0);
}
void SpellCheckClient::FinishLastTextCheck() {
« no previous file with comments | « components/test_runner/spell_check_client.h ('k') | components/test_runner/test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698