Bug 1006207 - Remove unused mode_ code. r=ekr
authorMartin Thomson <martin.thomson@gmail.com>
Mon, 04 Aug 2014 15:34:00 -0400
changeset 198633 302936c0978c66ac6f538911a554b4693e35d8e8
parent 198632 e27972249203b517ffd5b76b046108ea0f417abe
child 198634 fd811aaf5a90b391737aa14b4c450fa9a6dab047
push id27278
push userkwierso@gmail.com
push dateFri, 08 Aug 2014 21:34:41 +0000
treeherdermozilla-central@a6424bfa8f39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersekr
bugs1006207
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1006207 - Remove unused mode_ code. r=ekr
media/mtransport/transportlayer.h
media/mtransport/transportlayerdtls.cpp
media/mtransport/transportlayerdtls.h
--- a/media/mtransport/transportlayer.h
+++ b/media/mtransport/transportlayer.h
@@ -33,21 +33,19 @@ enum {
   static std::string ID() { return name; }
 
 // Abstract base class for network transport layers.
 class TransportLayer : public sigslot::has_slots<> {
  public:
   // The state of the transport flow
   // We can't use "ERROR" because Windows has a macro named "ERROR"
   enum State { TS_NONE, TS_INIT, TS_CONNECTING, TS_OPEN, TS_CLOSED, TS_ERROR };
-  enum Mode { STREAM, DGRAM };
 
   // Is this a stream or datagram flow
-  TransportLayer(Mode mode = STREAM) :
-    mode_(mode),
+  TransportLayer() :
     state_(TS_NONE),
     flow_id_(),
     downward_(nullptr) {}
 
   virtual ~TransportLayer() {}
 
   // Called to initialize
   nsresult Init();  // Called by Insert() to set up -- do not override
@@ -91,17 +89,16 @@ class TransportLayer : public sigslot::h
  protected:
   virtual void WasInserted() {}
   virtual void SetState(State state, const char *file, unsigned line);
   // Check if we are on the right thread
   void CheckThread() const {
     NS_ABORT_IF_FALSE(CheckThreadInt(), "Wrong thread");
   }
 
-  Mode mode_;
   State state_;
   std::string flow_id_;
   TransportLayer *downward_; // The next layer in the stack
   nsCOMPtr<nsIEventTarget> target_;
 
  private:
   DISALLOW_COPY_ASSIGN(TransportLayer);
 
--- a/media/mtransport/transportlayerdtls.cpp
+++ b/media/mtransport/transportlayerdtls.cpp
@@ -448,23 +448,17 @@ bool TransportLayerDtls::Setup() {
 
   ScopedPRFileDesc pr_fd(PR_CreateIOLayerStub(transport_layer_identity,
                                               &TransportLayerMethods));
   MOZ_ASSERT(pr_fd != nullptr);
   if (!pr_fd)
     return false;
   pr_fd->secret = reinterpret_cast<PRFilePrivate *>(nspr_io_adapter_.get());
 
-  ScopedPRFileDesc ssl_fd;
-  if (mode_ == DGRAM) {
-    ssl_fd = DTLS_ImportFD(nullptr, pr_fd);
-  } else {
-    ssl_fd = SSL_ImportFD(nullptr, pr_fd);
-  }
-
+  ScopedPRFileDesc ssl_fd(DTLS_ImportFD(nullptr, pr_fd));
   MOZ_ASSERT(ssl_fd != nullptr);  // This should never happen
   if (!ssl_fd) {
     return false;
   }
 
   pr_fd.forget(); // ownership transfered to ssl_fd;
 
   if (role_ == CLIENT) {
@@ -772,38 +766,32 @@ void TransportLayerDtls::Handshake() {
       TL_SET_STATE(TS_ERROR);
       return;
     }
     TL_SET_STATE(TS_OPEN);
   } else {
     int32_t err = PR_GetError();
     switch(err) {
       case SSL_ERROR_RX_MALFORMED_HANDSHAKE:
-        if (mode_ != DGRAM) {
-          MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Malformed TLS message");
-          TL_SET_STATE(TS_ERROR);
-        } else {
-          MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Malformed DTLS message; ignoring");
-        }
-        // Fall through
+        MOZ_MTLOG(ML_ERROR, LAYER_INFO << "Malformed DTLS message; ignoring");
+        // If this were TLS (and not DTLS), this would be fatal, but
+        // here we're required to ignore bad messages, so fall through
       case PR_WOULD_BLOCK_ERROR:
         MOZ_MTLOG(ML_NOTICE, LAYER_INFO << "Handshake would have blocked");
-        if (mode_ == DGRAM) {
-          PRIntervalTime timeout;
-          rv = DTLS_GetHandshakeTimeout(ssl_fd_, &timeout);
-          if (rv == SECSuccess) {
-            uint32_t timeout_ms = PR_IntervalToMilliseconds(timeout);
+        PRIntervalTime timeout;
+        rv = DTLS_GetHandshakeTimeout(ssl_fd_, &timeout);
+        if (rv == SECSuccess) {
+          uint32_t timeout_ms = PR_IntervalToMilliseconds(timeout);
 
-            MOZ_MTLOG(ML_DEBUG, LAYER_INFO << "Setting DTLS timeout to " <<
-                 timeout_ms);
-            timer_->SetTarget(target_);
-            timer_->InitWithFuncCallback(TimerCallback,
-                                         this, timeout_ms,
-                                         nsITimer::TYPE_ONE_SHOT);
-          }
+          MOZ_MTLOG(ML_DEBUG,
+                    LAYER_INFO << "Setting DTLS timeout to " << timeout_ms);
+          timer_->SetTarget(target_);
+          timer_->InitWithFuncCallback(TimerCallback,
+                                       this, timeout_ms,
+                                       nsITimer::TYPE_ONE_SHOT);
         }
         break;
       default:
         MOZ_MTLOG(ML_ERROR, LAYER_INFO << "SSL handshake error "<< err);
         TL_SET_STATE(TS_ERROR);
         break;
     }
   }
--- a/media/mtransport/transportlayerdtls.h
+++ b/media/mtransport/transportlayerdtls.h
@@ -43,17 +43,16 @@ class TransportLayerNSPRAdapter {
 
   TransportLayer *output_;
   std::queue<Packet *> input_;
 };
 
 class TransportLayerDtls : public TransportLayer {
  public:
   TransportLayerDtls() :
-      TransportLayer(DGRAM),
       role_(CLIENT),
       verification_mode_(VERIFY_UNSET),
       ssl_fd_(nullptr),
       auth_hook_called_(false),
       cert_ok_(false) {}
 
   virtual ~TransportLayerDtls();