bug 1137076 mark some methods as private r=edwin
authorKarl Tomlinson <karlt+@karlt.net>
Sat, 28 Feb 2015 14:44:07 +1300
changeset 246916 1f48676c718889b31117532849869ac0b2b7bb08
parent 246915 b9735dd934a234677e04e702821d2faa06b630f8
child 246917 3fa2c597f2876bd85eee8717a8b5f09250f0309e
push id884
push userdburns@mozilla.com
push dateTue, 03 Mar 2015 15:29:12 +0000
reviewersedwin
bugs1137076
milestone39.0a1
bug 1137076 mark some methods as private r=edwin
dom/media/omx/MediaOmxReader.cpp
dom/media/omx/MediaOmxReader.h
--- a/dom/media/omx/MediaOmxReader.cpp
+++ b/dom/media/omx/MediaOmxReader.cpp
@@ -30,20 +30,20 @@ namespace mozilla {
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gMediaDecoderLog;
 #define DECODER_LOG(type, msg) PR_LOG(gMediaDecoderLog, type, msg)
 #else
 #define DECODER_LOG(type, msg)
 #endif
 
-class OmxReaderProcessCachedDataTask : public Task
+class MediaOmxReader::ProcessCachedDataTask : public Task
 {
 public:
-  OmxReaderProcessCachedDataTask(MediaOmxReader* aOmxReader, int64_t aOffset)
+  ProcessCachedDataTask(MediaOmxReader* aOmxReader, int64_t aOffset)
   : mOmxReader(aOmxReader),
     mOffset(aOffset)
   { }
 
   void Run()
   {
     MOZ_ASSERT(!NS_IsMainThread());
     MOZ_ASSERT(mOmxReader.get());
@@ -65,20 +65,20 @@ private:
 // thread, an instance of this class is scheduled to the main thread for
 // parsing the MP3 stream. The decode thread waits until it has finished.
 //
 // If there is more data available from the file, the runnable dispatches
 // a task to the IO thread for retrieving the next chunk of data, and
 // the IO task dispatches a runnable to the main thread for parsing the
 // data. This goes on until all of the MP3 file has been parsed.
 
-class OmxReaderNotifyDataArrivedRunnable : public nsRunnable
+class MediaOmxReader::NotifyDataArrivedRunnable : public nsRunnable
 {
 public:
-  OmxReaderNotifyDataArrivedRunnable(MediaOmxReader* aOmxReader,
+  NotifyDataArrivedRunnable(MediaOmxReader* aOmxReader,
                                      const char* aBuffer, uint64_t aLength,
                                      int64_t aOffset, uint64_t aFullLength)
   : mOmxReader(aOmxReader),
     mBuffer(aBuffer),
     mLength(aLength),
     mOffset(aOffset),
     mFullLength(aFullLength)
   {
@@ -112,17 +112,17 @@ private:
       mOffset += length;
     }
 
     if (static_cast<uint64_t>(mOffset) < mFullLength) {
       // We cannot read data in the main thread because it
       // might block for too long. Instead we post an IO task
       // to the IO thread if there is more data available.
       XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
-          new OmxReaderProcessCachedDataTask(mOmxReader.get(), mOffset));
+          new ProcessCachedDataTask(mOmxReader.get(), mOffset));
     }
   }
 
   nsRefPtr<MediaOmxReader>         mOmxReader;
   nsAutoArrayPtr<const char>       mBuffer;
   uint64_t                         mLength;
   int64_t                          mOffset;
   uint64_t                         mFullLength;
@@ -613,22 +613,19 @@ int64_t MediaOmxReader::ProcessCachedDat
   int64_t bufferLength = std::min<int64_t>(resourceLength-aOffset, sReadSize);
 
   nsAutoArrayPtr<char> buffer(new char[bufferLength]);
 
   nsresult rv = decoder->GetResource()->ReadFromCache(buffer.get(),
                                                        aOffset, bufferLength);
   NS_ENSURE_SUCCESS(rv, -1);
 
-  nsRefPtr<OmxReaderNotifyDataArrivedRunnable> runnable(
-    new OmxReaderNotifyDataArrivedRunnable(this,
-                                           buffer.forget(),
-                                           bufferLength,
-                                           aOffset,
-                                           resourceLength));
+  nsRefPtr<NotifyDataArrivedRunnable> runnable(
+    new NotifyDataArrivedRunnable(this, buffer.forget(), bufferLength,
+                                  aOffset, resourceLength));
   if (aWaitForCompletion) {
     rv = NS_DispatchToMainThread(runnable.get(), NS_DISPATCH_SYNC);
   } else {
     rv = NS_DispatchToMainThread(runnable.get());
   }
   NS_ENSURE_SUCCESS(rv, -1);
 
   return resourceLength - aOffset - bufferLength;
--- a/dom/media/omx/MediaOmxReader.h
+++ b/dom/media/omx/MediaOmxReader.h
@@ -105,26 +105,31 @@ public:
   Seek(int64_t aTime, int64_t aEndTime) MOZ_OVERRIDE;
 
   virtual bool IsMediaSeekable() MOZ_OVERRIDE;
 
   virtual void SetIdle() MOZ_OVERRIDE;
 
   virtual nsRefPtr<ShutdownPromise> Shutdown() MOZ_OVERRIDE;
 
+  android::sp<android::MediaSource> GetAudioOffloadTrack();
+
+  // This method is intended only for private use but public only for
+  // MediaPromise::InvokeCallbackMethod().
+  void ReleaseDecoder();
+
+private:
+  class ProcessCachedDataTask;
+  class NotifyDataArrivedRunnable;
+
   bool IsShutdown() {
     MutexAutoLock lock(mShutdownMutex);
     return mIsShutdown;
   }
 
-  void ReleaseDecoder();
-
   int64_t ProcessCachedData(int64_t aOffset, bool aWaitForCompletion);
 
-  android::sp<android::MediaSource> GetAudioOffloadTrack();
-
-private:
   already_AddRefed<AbstractMediaDecoder> SafeGetDecoder();
 };
 
 } // namespace mozilla
 
 #endif