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

Unified Diff: components/test_runner/mock_color_chooser.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/mock_color_chooser.h ('k') | components/test_runner/mock_web_media_stream_center.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/mock_color_chooser.cc
diff --git a/components/test_runner/mock_color_chooser.cc b/components/test_runner/mock_color_chooser.cc
index cccdf0d0e90a66815c081aec12a0a8901f814584..aa150e98c1b9032fed855614ef21bceafc85a20f 100644
--- a/components/test_runner/mock_color_chooser.cc
+++ b/components/test_runner/mock_color_chooser.cc
@@ -4,31 +4,20 @@
#include "components/test_runner/mock_color_chooser.h"
+#include "base/bind.h"
#include "components/test_runner/test_runner.h"
+#include "components/test_runner/web_task.h"
#include "components/test_runner/web_test_delegate.h"
namespace test_runner {
-namespace {
-class HostMethodTask : public WebMethodTask<MockColorChooser> {
- public:
- typedef void (MockColorChooser::*CallbackMethodType)();
- HostMethodTask(MockColorChooser* object, CallbackMethodType callback)
- : WebMethodTask<MockColorChooser>(object),
- callback_(callback) {}
-
- void RunIfValid() override { (object_->*callback_)(); }
-
- private:
- CallbackMethodType callback_;
-};
-
-} // namespace
-
MockColorChooser::MockColorChooser(blink::WebColorChooserClient* client,
WebTestDelegate* delegate,
TestRunner* test_runner)
- : client_(client), delegate_(delegate), test_runner_(test_runner) {
+ : client_(client),
+ delegate_(delegate),
+ test_runner_(test_runner),
+ weak_factory_(this) {
test_runner_->DidOpenChooser();
}
@@ -40,7 +29,9 @@ void MockColorChooser::setSelectedColor(const blink::WebColor color) {}
void MockColorChooser::endChooser() {
delegate_->PostDelayedTask(
- new HostMethodTask(this, &MockColorChooser::InvokeDidEndChooser), 0);
+ new WebCallbackTask(base::Bind(&MockColorChooser::InvokeDidEndChooser,
+ weak_factory_.GetWeakPtr())),
+ 0);
}
void MockColorChooser::InvokeDidEndChooser() {
« no previous file with comments | « components/test_runner/mock_color_chooser.h ('k') | components/test_runner/mock_web_media_stream_center.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698