Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / renderer / media / webrtc / mock_peer_connection_dependency_factory.cc
index d059fc9..ca3f298 100644 (file)
@@ -131,8 +131,7 @@ class MockRtcVideoCapturer : public WebRtcVideoCapturerAdapter {
         height_(0) {
   }
 
-  virtual void OnFrameCaptured(
-      const scoped_refptr<media::VideoFrame>& frame) OVERRIDE {
+  void OnFrameCaptured(const scoped_refptr<media::VideoFrame>& frame) override {
     ++number_of_capturered_frames_;
     width_ = frame->visible_rect().width();
     height_ = frame->visible_rect().height();
@@ -176,8 +175,7 @@ bool MockVideoRenderer::RenderFrame(const cricket::VideoFrame* frame) {
 
 MockAudioSource::MockAudioSource(
     const webrtc::MediaConstraintsInterface* constraints)
-    : observer_(NULL),
-      state_(MediaSourceInterface::kLive),
+    : state_(MediaSourceInterface::kLive),
       optional_constraints_(constraints->GetOptional()),
       mandatory_constraints_(constraints->GetMandatory()) {
 }
@@ -185,12 +183,13 @@ MockAudioSource::MockAudioSource(
 MockAudioSource::~MockAudioSource() {}
 
 void MockAudioSource::RegisterObserver(webrtc::ObserverInterface* observer) {
-  observer_ = observer;
+  DCHECK(observers_.find(observer) == observers_.end());
+  observers_.insert(observer);
 }
 
 void MockAudioSource::UnregisterObserver(webrtc::ObserverInterface* observer) {
-  DCHECK(observer_ == observer);
-  observer_ = NULL;
+  DCHECK(observers_.find(observer) != observers_.end());
+  observers_.erase(observer);
 }
 
 webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const {
@@ -291,7 +290,6 @@ MockWebRtcVideoTrack::MockWebRtcVideoTrack(
       id_(id),
       state_(MediaStreamTrackInterface::kLive),
       source_(source),
-      observer_(NULL),
       renderer_(NULL) {
 }
 
@@ -327,18 +325,19 @@ bool MockWebRtcVideoTrack::set_enabled(bool enable) {
 
 bool MockWebRtcVideoTrack::set_state(TrackState new_state) {
   state_ = new_state;
-  if (observer_)
-    observer_->OnChanged();
+  for (auto& o : observers_)
+    o->OnChanged();
   return true;
 }
 
 void MockWebRtcVideoTrack::RegisterObserver(ObserverInterface* observer) {
-  observer_ = observer;
+  DCHECK(observers_.find(observer) == observers_.end());
+  observers_.insert(observer);
 }
 
 void MockWebRtcVideoTrack::UnregisterObserver(ObserverInterface* observer) {
-  DCHECK(observer_ == observer);
-  observer_ = NULL;
+  DCHECK(observers_.find(observer) != observers_.end());
+  observers_.erase(observer);
 }
 
 VideoSourceInterface* MockWebRtcVideoTrack::GetSource() const {
@@ -352,41 +351,39 @@ class MockSessionDescription : public SessionDescriptionInterface {
       : type_(type),
         sdp_(sdp) {
   }
-  virtual ~MockSessionDescription() {}
-  virtual cricket::SessionDescription* description() OVERRIDE {
+  ~MockSessionDescription() override {}
+  cricket::SessionDescription* description() override {
     NOTIMPLEMENTED();
     return NULL;
   }
-  virtual const cricket::SessionDescription* description() const OVERRIDE {
+  const cricket::SessionDescription* description() const override {
     NOTIMPLEMENTED();
     return NULL;
   }
-  virtual std::string session_id() const OVERRIDE {
+  std::string session_id() const override {
     NOTIMPLEMENTED();
     return std::string();
   }
-  virtual std::string session_version() const OVERRIDE {
+  std::string session_version() const override {
     NOTIMPLEMENTED();
     return std::string();
   }
-  virtual std::string type() const OVERRIDE {
-    return type_;
-  }
-  virtual bool AddCandidate(const IceCandidateInterface* candidate) OVERRIDE {
+  std::string type() const override { return type_; }
+  bool AddCandidate(const IceCandidateInterface* candidate) override {
     NOTIMPLEMENTED();
     return false;
   }
-  virtual size_t number_of_mediasections() const OVERRIDE {
+  size_t number_of_mediasections() const override {
     NOTIMPLEMENTED();
     return 0;
   }
-  virtual const IceCandidateCollection* candidates(
-      size_t mediasection_index) const OVERRIDE {
+  const IceCandidateCollection* candidates(
+      size_t mediasection_index) const override {
     NOTIMPLEMENTED();
     return NULL;
   }
 
-  virtual bool ToString(std::string* out) const OVERRIDE {
+  bool ToString(std::string* out) const override {
     *out = sdp_;
     return true;
   }
@@ -407,17 +404,11 @@ class MockIceCandidate : public IceCandidateInterface {
     // Assign an valid address to |candidate_| to pass assert in code.
     candidate_.set_address(rtc::SocketAddress("127.0.0.1", 5000));
   }
-  virtual ~MockIceCandidate() {}
-  virtual std::string sdp_mid() const OVERRIDE {
-    return sdp_mid_;
-  }
-  virtual int sdp_mline_index() const OVERRIDE {
-    return sdp_mline_index_;
-  }
-  virtual const cricket::Candidate& candidate() const OVERRIDE {
-    return candidate_;
-  }
-  virtual bool ToString(std::string* out) const OVERRIDE {
+  ~MockIceCandidate() override {}
+  std::string sdp_mid() const override { return sdp_mid_; }
+  int sdp_mline_index() const override { return sdp_mline_index_; }
+  const cricket::Candidate& candidate() const override { return candidate_; }
+  bool ToString(std::string* out) const override {
     *out = sdp_;
     return true;
   }
@@ -442,7 +433,7 @@ MockPeerConnectionDependencyFactory::CreatePeerConnection(
     const webrtc::MediaConstraintsInterface* constraints,
     blink::WebFrame* frame,
     webrtc::PeerConnectionObserver* observer) {
-  return new rtc::RefCountedObject<MockPeerConnectionImpl>(this);
+  return new rtc::RefCountedObject<MockPeerConnectionImpl>(this, observer);
 }
 
 scoped_refptr<webrtc::AudioSourceInterface>