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

Unified Diff: components/test_runner/mock_web_midi_accessor.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
Index: components/test_runner/mock_web_midi_accessor.cc
diff --git a/components/test_runner/mock_web_midi_accessor.cc b/components/test_runner/mock_web_midi_accessor.cc
index f5920bd530e5f215c1241f8efdf832b38f8a96d3..b53915b4b37d9ee8e51312874e5a1bc84004a25f 100644
--- a/components/test_runner/mock_web_midi_accessor.cc
+++ b/components/test_runner/mock_web_midi_accessor.cc
@@ -4,43 +4,22 @@
#include "components/test_runner/mock_web_midi_accessor.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/macros.h"
#include "components/test_runner/test_interfaces.h"
#include "components/test_runner/test_runner.h"
+#include "components/test_runner/web_task.h"
#include "components/test_runner/web_test_delegate.h"
#include "components/test_runner/web_test_runner.h"
+#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/modules/webmidi/WebMIDIAccessorClient.h"
namespace test_runner {
-namespace {
-
-class DidStartSessionTask : public WebMethodTask<MockWebMIDIAccessor> {
- public:
- DidStartSessionTask(MockWebMIDIAccessor* object,
- blink::WebMIDIAccessorClient* client,
- bool result)
- : WebMethodTask<MockWebMIDIAccessor>(object),
- client_(client),
- result_(result) {}
-
- void RunIfValid() override {
- client_->didStartSession(result_, "InvalidStateError", "");
- }
-
- private:
- blink::WebMIDIAccessorClient* client_;
- bool result_;
-
- DISALLOW_COPY_AND_ASSIGN(DidStartSessionTask);
-};
-
-} // namespace
-
MockWebMIDIAccessor::MockWebMIDIAccessor(blink::WebMIDIAccessorClient* client,
TestInterfaces* interfaces)
- : client_(client), interfaces_(interfaces) {
-}
+ : client_(client), interfaces_(interfaces), weak_factory_(this) {}
MockWebMIDIAccessor::~MockWebMIDIAccessor() {
}
@@ -59,8 +38,13 @@ void MockWebMIDIAccessor::startSession() {
"MockOutputName",
"MockOutputVersion",
state);
- interfaces_->GetDelegate()->PostTask(new DidStartSessionTask(
- this, client_, interfaces_->GetTestRunner()->midiAccessorResult()));
+ interfaces_->GetDelegate()->PostTask(new WebCallbackTask(base::Bind(
+ &MockWebMIDIAccessor::ReportStartedSession, weak_factory_.GetWeakPtr(),
+ interfaces_->GetTestRunner()->midiAccessorResult())));
+}
+
+void MockWebMIDIAccessor::ReportStartedSession(bool success) {
+ client_->didStartSession(success, "InvalidStateError", "");
}
void MockWebMIDIAccessor::sendMIDIData(unsigned port_index,
« no previous file with comments | « components/test_runner/mock_web_midi_accessor.h ('k') | components/test_runner/mock_web_speech_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698