Fix DTLS packet boundary handling in SSLStreamAdapterTests.

The tests were not honoring packet boundaries, thus causing failures
in tests with dropped/broken packets. This CL fixes this and also
re-enables the tests.

R=torbjorng@webrtc.org,pthatcher@webrtc.org,tommi@webrtc.org,juberti@webrtc.org
BUG=webrtc:5005,webrtc:5188

Review URL: https://codereview.webrtc.org/1440193002

Cr-Commit-Position: refs/heads/master@{#10709}
diff --git a/webrtc/base/bufferqueue.h b/webrtc/base/bufferqueue.h
index 4941fcc..458f018 100644
--- a/webrtc/base/bufferqueue.h
+++ b/webrtc/base/bufferqueue.h
@@ -21,26 +21,33 @@
 
 class BufferQueue {
  public:
-  // Creates a buffer queue queue with a given capacity and default buffer size.
+  // Creates a buffer queue with a given capacity and default buffer size.
   BufferQueue(size_t capacity, size_t default_size);
-  ~BufferQueue();
+  virtual ~BufferQueue();
 
   // Return number of queued buffers.
   size_t size() const;
 
   // ReadFront will only read one buffer at a time and will truncate buffers
   // that don't fit in the passed memory.
+  // Returns true unless no data could be returned.
   bool ReadFront(void* data, size_t bytes, size_t* bytes_read);
 
   // WriteBack always writes either the complete memory or nothing.
+  // Returns true unless no data could be written.
   bool WriteBack(const void* data, size_t bytes, size_t* bytes_written);
 
+ protected:
+  // These methods are called when the state of the queue changes.
+  virtual void NotifyReadableForTest() {}
+  virtual void NotifyWritableForTest() {}
+
  private:
   size_t capacity_;
   size_t default_size_;
-  std::deque<Buffer*> queue_;
-  std::vector<Buffer*> free_list_;
-  mutable CriticalSection crit_;  // object lock
+  mutable CriticalSection crit_;
+  std::deque<Buffer*> queue_ GUARDED_BY(crit_);
+  std::vector<Buffer*> free_list_ GUARDED_BY(crit_);
 
   RTC_DISALLOW_COPY_AND_ASSIGN(BufferQueue);
 };