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

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: Review comments 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
« no previous file with comments | « content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ed7221a15741dbea84c137fda87466e449b78875
--- /dev/null
+++ b/content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.cc
@@ -0,0 +1,69 @@
+// 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 "base/logging.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() {
+ DCHECK(client_ && !track_.isNull());
+ 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) {
+ DCHECK(client_);
+ if (!canInsertDTMF())
+ return false;
+
+ tone_buffer_ = tones;
+ delegate_->postTask(new DTMFSenderToneTask(this, client_));
+ delegate_->postTask(new DTMFSenderToneTask(this, client_));
+ return true;
+}
+
+} // namespace content
« no previous file with comments | « content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698