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

Side by Side Diff: components/test_runner/mock_webrtc_peer_connection_handler.cc

Issue 2302873004: Renamed WebRTCStats.h to WebRTCLegacyStats.h and cleaned it up (Closed)
Patch Set: Fixed compile error Created 4 years, 3 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
« no previous file with comments | « no previous file | content/renderer/media/rtc_peer_connection_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/test_runner/mock_webrtc_peer_connection_handler.h" 5 #include "components/test_runner/mock_webrtc_peer_connection_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 17 matching lines...) Expand all
28 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" 28 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h"
29 #include "third_party/WebKit/public/platform/WebString.h" 29 #include "third_party/WebKit/public/platform/WebString.h"
30 #include "third_party/WebKit/public/platform/WebVector.h" 30 #include "third_party/WebKit/public/platform/WebVector.h"
31 31
32 using namespace blink; 32 using namespace blink;
33 33
34 namespace test_runner { 34 namespace test_runner {
35 35
36 namespace { 36 namespace {
37 37
38 class MockWebRTCStats : public blink::WebRTCStats { 38 class MockWebRTCLegacyStats : public blink::WebRTCLegacyStats {
39 public: 39 public:
40 class MemberIterator : public blink::WebRTCStatsMemberIterator { 40 class MemberIterator : public blink::WebRTCLegacyStatsMemberIterator {
41 public: 41 public:
42 MemberIterator( 42 MemberIterator(
43 const std::vector<std::pair<std::string, std::string>>* values) 43 const std::vector<std::pair<std::string, std::string>>* values)
44 : values_(values) {} 44 : values_(values) {}
45 45
46 // blink::WebRTCStatsMemberIterator 46 // blink::WebRTCLegacyStatsMemberIterator
47 bool isEnd() const override { return i >= values_->size(); } 47 bool isEnd() const override { return i >= values_->size(); }
48 void next() override { ++i; } 48 void next() override { ++i; }
49 blink::WebRTCStatsMemberName name() const override { 49 blink::WebString name() const override {
50 return blink::WebRTCStatsMemberNameUnknown;
51 }
52 blink::WebString displayName() const override {
53 return blink::WebString::fromUTF8((*values_)[i].first); 50 return blink::WebString::fromUTF8((*values_)[i].first);
54 } 51 }
55 blink::WebRTCStatsMemberType type() const override { 52 blink::WebRTCLegacyStatsMemberType type() const override {
56 return blink::WebRTCStatsMemberTypeString; 53 return blink::WebRTCLegacyStatsMemberTypeString;
57 } 54 }
58 int valueInt() const override { 55 int valueInt() const override {
59 NOTREACHED(); 56 NOTREACHED();
60 return 0; 57 return 0;
61 } 58 }
62 int64_t valueInt64() const override { 59 int64_t valueInt64() const override {
63 NOTREACHED(); 60 NOTREACHED();
64 return 0; 61 return 0;
65 } 62 }
66 float valueFloat() const override { 63 float valueFloat() const override {
67 NOTREACHED(); 64 NOTREACHED();
68 return 0.0f; 65 return 0.0f;
69 } 66 }
70 blink::WebString valueString() const override { 67 blink::WebString valueString() const override {
71 return blink::WebString::fromUTF8((*values_)[i].second); 68 return blink::WebString::fromUTF8((*values_)[i].second);
72 } 69 }
73 bool valueBool() const override { 70 bool valueBool() const override {
74 NOTREACHED(); 71 NOTREACHED();
75 return false; 72 return false;
76 } 73 }
77 blink::WebString valueToString() const override { 74 blink::WebString valueToString() const override {
78 return valueString(); 75 return valueString();
79 } 76 }
80 77
81 private: 78 private:
82 size_t i = 0; 79 size_t i = 0;
83 const std::vector<std::pair<std::string, std::string>>* values_; 80 const std::vector<std::pair<std::string, std::string>>* values_;
84 }; 81 };
85 82
86 MockWebRTCStats(const char* id, const char* type_name, double timestamp) 83 MockWebRTCLegacyStats(const char* id, const char* type_name, double timestamp)
87 : id_(id), type_name_(type_name), timestamp_(timestamp) {} 84 : id_(id), type_name_(type_name), timestamp_(timestamp) {}
88 85
89 // blink::WebRTCStats 86 // blink::WebRTCLegacyStats
90 blink::WebString id() const override { 87 blink::WebString id() const override {
91 return blink::WebString::fromUTF8(id_); 88 return blink::WebString::fromUTF8(id_);
92 } 89 }
93 blink::WebRTCStatsType type() const override { 90 blink::WebString type() const override {
94 return blink::WebRTCStatsTypeUnknown;
95 }
96 blink::WebString typeToString() const override {
97 return blink::WebString::fromUTF8(type_name_); 91 return blink::WebString::fromUTF8(type_name_);
98 } 92 }
99 double timestamp() const override { 93 double timestamp() const override {
100 return timestamp_; 94 return timestamp_;
101 } 95 }
102 blink::WebRTCStatsMemberIterator* iterator() const override { 96 blink::WebRTCLegacyStatsMemberIterator* iterator() const override {
103 return new MemberIterator(&values_); 97 return new MemberIterator(&values_);
104 } 98 }
105 99
106 void addStatistic(const std::string& name, const std::string& value) { 100 void addStatistic(const std::string& name, const std::string& value) {
107 values_.push_back(std::make_pair(name, value)); 101 values_.push_back(std::make_pair(name, value));
108 } 102 }
109 103
110 private: 104 private:
111 const std::string id_; 105 const std::string id_;
112 const std::string type_name_; 106 const std::string type_name_;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 client_->negotiationNeeded(); 366 client_->negotiationNeeded();
373 } 367 }
374 368
375 void MockWebRTCPeerConnectionHandler::getStats( 369 void MockWebRTCPeerConnectionHandler::getStats(
376 const WebRTCStatsRequest& request) { 370 const WebRTCStatsRequest& request) {
377 WebRTCStatsResponse response = request.createResponse(); 371 WebRTCStatsResponse response = request.createResponse();
378 double current_date = 372 double current_date =
379 interfaces_->GetDelegate()->GetCurrentTimeInMillisecond(); 373 interfaces_->GetDelegate()->GetCurrentTimeInMillisecond();
380 if (request.hasSelector()) { 374 if (request.hasSelector()) {
381 // FIXME: There is no check that the fetched values are valid. 375 // FIXME: There is no check that the fetched values are valid.
382 MockWebRTCStats stats("Mock video", "ssrc", current_date); 376 MockWebRTCLegacyStats stats("Mock video", "ssrc", current_date);
383 stats.addStatistic("type", "video"); 377 stats.addStatistic("type", "video");
384 response.addStats(stats); 378 response.addStats(stats);
385 } else { 379 } else {
386 for (int i = 0; i < stream_count_; ++i) { 380 for (int i = 0; i < stream_count_; ++i) {
387 MockWebRTCStats audio_stats("Mock audio", "ssrc", current_date); 381 MockWebRTCLegacyStats audio_stats("Mock audio", "ssrc", current_date);
388 audio_stats.addStatistic("type", "audio"); 382 audio_stats.addStatistic("type", "audio");
389 response.addStats(audio_stats); 383 response.addStats(audio_stats);
390 384
391 MockWebRTCStats video_stats("Mock video", "ssrc", current_date); 385 MockWebRTCLegacyStats video_stats("Mock video", "ssrc", current_date);
392 video_stats.addStatistic("type", "video"); 386 video_stats.addStatistic("type", "video");
393 response.addStats(video_stats); 387 response.addStats(video_stats);
394 } 388 }
395 } 389 }
396 interfaces_->GetDelegate()->PostTask(new WebCallbackTask( 390 interfaces_->GetDelegate()->PostTask(new WebCallbackTask(
397 base::Bind(&blink::WebRTCStatsRequest::requestSucceeded, 391 base::Bind(&blink::WebRTCStatsRequest::requestSucceeded,
398 base::Owned(new WebRTCStatsRequest(request)), response))); 392 base::Owned(new WebRTCStatsRequest(request)), response)));
399 } 393 }
400 394
401 void MockWebRTCPeerConnectionHandler::ReportCreationOfDataChannel() { 395 void MockWebRTCPeerConnectionHandler::ReportCreationOfDataChannel() {
(...skipping 21 matching lines...) Expand all
423 const WebMediaStreamTrack& track) { 417 const WebMediaStreamTrack& track) {
424 return new MockWebRTCDTMFSenderHandler(track, interfaces_->GetDelegate()); 418 return new MockWebRTCDTMFSenderHandler(track, interfaces_->GetDelegate());
425 } 419 }
426 420
427 void MockWebRTCPeerConnectionHandler::stop() { 421 void MockWebRTCPeerConnectionHandler::stop() {
428 stopped_ = true; 422 stopped_ = true;
429 weak_factory_.InvalidateWeakPtrs(); 423 weak_factory_.InvalidateWeakPtrs();
430 } 424 }
431 425
432 } // namespace test_runner 426 } // namespace test_runner
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/rtc_peer_connection_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698