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

Unified Diff: content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.cc

Issue 310783002: test_runner: Migrate MockWebRTCDTMFSenderHandler to Chromium C++ style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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: content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.cc
diff --git a/content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.cc b/content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c17835e7430bbd2cb1d0a4d81cd53a16952f735e
--- /dev/null
+++ b/content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.cc
@@ -0,0 +1,70 @@
+// Copyright 2013 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/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.h"
+
+#include <assert.h>
+
+#include "content/shell/renderer/test_runner/WebTestDelegate.h"
+#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
+#include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandlerClient.h"
+
+using namespace blink;
+
+namespace content {
+
+class DTMFSenderToneTask : public WebMethodTask<MockWebRTCDTMFSenderHandler> {
+ public:
+ DTMFSenderToneTask(MockWebRTCDTMFSenderHandler* object,
+ WebRTCDTMFSenderHandlerClient* client)
+ : WebMethodTask<MockWebRTCDTMFSenderHandler>(object), client_(client) {}
+
+ virtual void runIfValid() OVERRIDE {
+ WebString tones = m_object->currentToneBuffer();
+ m_object->ClearToneBuffer();
+ client_->didPlayTone(tones);
+ }
+
+ private:
+ WebRTCDTMFSenderHandlerClient* client_;
+};
+
+/////////////////////
+
+MockWebRTCDTMFSenderHandler::MockWebRTCDTMFSenderHandler(
+ const WebMediaStreamTrack& track,
+ WebTestDelegate* delegate)
+ : client_(0), track_(track), delegate_(delegate) {
+}
+
+void MockWebRTCDTMFSenderHandler::setClient(
+ WebRTCDTMFSenderHandlerClient* client) {
+ client_ = client;
+}
+
+WebString MockWebRTCDTMFSenderHandler::currentToneBuffer() {
+ return tone_buffer_;
+}
+
+bool MockWebRTCDTMFSenderHandler::canInsertDTMF() {
+ assert(client_ && !track_.isNull());
jochen (gone - plz use gerrit) 2014/06/03 12:55:00 DCHECK
Nikhil 2014/06/04 05:33:55 Done.
+ return track_.source().type() == WebMediaStreamSource::TypeAudio &&
+ track_.isEnabled() &&
+ track_.source().readyState() == WebMediaStreamSource::ReadyStateLive;
+}
+
+bool MockWebRTCDTMFSenderHandler::insertDTMF(const WebString& tones,
+ long duration,
+ long inter_tone_gap) {
+ assert(client_);
+ if (!canInsertDTMF())
+ return false;
+
+ tone_buffer_ = tones;
+ delegate_->postTask(new DTMFSenderToneTask(this, client_));
+ delegate_->postTask(new DTMFSenderToneTask(this, client_));
+ return true;
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698