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

Side by Side 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, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.h"
6
7 #include <assert.h>
8
9 #include "content/shell/renderer/test_runner/WebTestDelegate.h"
10 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
11 #include "third_party/WebKit/public/platform/WebRTCDTMFSenderHandlerClient.h"
12
13 using namespace blink;
14
15 namespace content {
16
17 class DTMFSenderToneTask : public WebMethodTask<MockWebRTCDTMFSenderHandler> {
18 public:
19 DTMFSenderToneTask(MockWebRTCDTMFSenderHandler* object,
20 WebRTCDTMFSenderHandlerClient* client)
21 : WebMethodTask<MockWebRTCDTMFSenderHandler>(object), client_(client) {}
22
23 virtual void runIfValid() OVERRIDE {
24 WebString tones = m_object->currentToneBuffer();
25 m_object->ClearToneBuffer();
26 client_->didPlayTone(tones);
27 }
28
29 private:
30 WebRTCDTMFSenderHandlerClient* client_;
31 };
32
33 /////////////////////
34
35 MockWebRTCDTMFSenderHandler::MockWebRTCDTMFSenderHandler(
36 const WebMediaStreamTrack& track,
37 WebTestDelegate* delegate)
38 : client_(0), track_(track), delegate_(delegate) {
39 }
40
41 void MockWebRTCDTMFSenderHandler::setClient(
42 WebRTCDTMFSenderHandlerClient* client) {
43 client_ = client;
44 }
45
46 WebString MockWebRTCDTMFSenderHandler::currentToneBuffer() {
47 return tone_buffer_;
48 }
49
50 bool MockWebRTCDTMFSenderHandler::canInsertDTMF() {
51 assert(client_ && !track_.isNull());
jochen (gone - plz use gerrit) 2014/06/03 12:55:00 DCHECK
Nikhil 2014/06/04 05:33:55 Done.
52 return track_.source().type() == WebMediaStreamSource::TypeAudio &&
53 track_.isEnabled() &&
54 track_.source().readyState() == WebMediaStreamSource::ReadyStateLive;
55 }
56
57 bool MockWebRTCDTMFSenderHandler::insertDTMF(const WebString& tones,
58 long duration,
59 long inter_tone_gap) {
60 assert(client_);
61 if (!canInsertDTMF())
62 return false;
63
64 tone_buffer_ = tones;
65 delegate_->postTask(new DTMFSenderToneTask(this, client_));
66 delegate_->postTask(new DTMFSenderToneTask(this, client_));
67 return true;
68 }
69
70 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698