sbFileMetadataService Class Reference

Manages reading and writing metadata to and from sbIMediaItem objects and media files. More...

#include <sbFileMetadataService.h>

Inheritance diagram for sbFileMetadataService:
[legend]
Collaboration diagram for sbFileMetadataService:
[legend]

Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_SBIFILEMETADATASERVICE
NS_DECL_SBPIFILEMETADATASERVICE
NS_DECL_NSIOBSERVER 
sbFileMetadataService ()
 
virtual ~sbFileMetadataService ()
 
nsresult Init ()
 
nsresult GetQueuedJobItem (PRBool aMainThreadOnly, sbMetadataJobItem **aJobItem)
 
nsresult PutProcessedJobItem (sbMetadataJobItem *aJobItem)
 
nsresult GetJobItemIsBlocked (sbMetadataJobItem *aJobItem, PRBool *aJobItemIsBlocked)
 

Protected Member Functions

nsresult ProxiedRestartProcessors (PRUint16 aProcessorsToRestart)
 Proxied version of RestartProcessors present on the sbIFileMetadataService interface. More...
 
nsresult ProxiedStartJob (nsIArray *aMediaItemsArray, nsIStringEnumerator *aRequiredProperties, sbMetadataJob::JobType aJobType, sbIJobProgress **_retval)
 
nsresult StartJob (nsIArray *aMediaItemsArray, nsIStringEnumerator *aRequiredProperties, sbMetadataJob::JobType aJobType, sbIJobProgress **_retval)
 
nsresult Shutdown ()
 
nsresult EnsureWritePermitted ()
 
nsresult UpdateDataRemotes (PRInt64 aJobCount)
 

Protected Attributes

nsCOMPtr< sbIDataRemotemDataCurrentMetadataJobs
 
nsRefPtr
< sbMainThreadMetadataProcessor
mMainThreadProcessor
 
nsRefPtr
< sbBackgroundThreadMetadataProcessor
mBackgroundThreadProcessor
 
PRBool mInitialized
 
PRBool mRunning
 
nsCOMPtr< nsITimer > mNotificationTimer
 
PRLock * mJobLock
 
nsTArray< nsRefPtr
< sbMetadataJob > > 
mJobArray
 
PRUint32 mNextJobIndex
 
nsRefPtr< sbMetadataCrashTrackermCrashTracker
 
nsCOMPtr< sbIMediacoreManagermMediacoreManager
 

Additional Inherited Members

Detailed Description

Manages reading and writing metadata to and from sbIMediaItem objects and media files.

Supports the creation of threaded read/write jobs for local media (URIs beginning with file://), and timer driven read jobs for remote media.

Simplified Architecture:

[ Processor ] [ Service ] | |-Create-----—>[ Job ]-Create—>[ Handler ]

<---------—Start–
–GetQueuedItem-—>-GetQueuedItem-—>

|–Read/Write--------------------------------------------—>| | | | |–PutProcessedItem->|-PutProcessedItem->|

The complexity results from the fact that much of the work can only be done on the main thread (due to limitations of sbIMetadataHandlers and Mozilla APIs).

In theory we could do everything on the main thread, but since some handlers do blocking IO this is very undesirable. Instead we run some safe sbIMetadataHandlers on a background thread, and use timers to do all other work on the main thread.

Additional Notes:

All interactions other than GetQueuedJobItem and PutProcessedJobItem must be performed on the main thread.

See Also
sbIJobProgress, sbIFileMetadataService

Definition at line 127 of file sbFileMetadataService.h.

Constructor & Destructor Documentation

NS_DECL_ISUPPORTS NS_DECL_SBIFILEMETADATASERVICE NS_DECL_SBPIFILEMETADATASERVICE NS_DECL_NSIOBSERVER sbFileMetadataService::sbFileMetadataService ( )
sbFileMetadataService::~sbFileMetadataService ( )
virtual

Definition at line 97 of file sbFileMetadataService.cpp.

Member Function Documentation

nsresult sbFileMetadataService::EnsureWritePermitted ( )
protected

Return NS_OK if write jobs are permitted, or NS_ERROR_NOT_AVAILABLE if not.

May prompt the user to permit write jobs.

Definition at line 690 of file sbFileMetadataService.cpp.

Here is the caller graph for this function:

nsresult sbFileMetadataService::GetJobItemIsBlocked ( sbMetadataJobItem aJobItem,
PRBool *  aJobItemIsBlocked 
)

If completion of the job item specified by aJobItem is blocked (e.g., writing to a playing file), return true in aJobItemIsBlocked; otherwise, return false.

Parameters
aJobItemJob item to check.
aJobItemIsBlockedIf true, job item is blocked.

Definition at line 524 of file sbFileMetadataService.cpp.

Here is the call graph for this function:

nsresult sbFileMetadataService::GetQueuedJobItem ( PRBool  aMainThreadOnly,
sbMetadataJobItem **  aJobItem 
)

Take a waiting job item for processing from the next active job.

Rotates through available jobs so that they are processed in parallel.

May be called off of the main thread.

Parameters
aMainThreadOnlyIf true, will return a job item that needs to be run on the main thread due to implementation details.
aJobItemThe job item to be processed
Returns
NS_ERROR_NOT_AVAILABLE if there are no more items

Definition at line 421 of file sbFileMetadataService.cpp.

Here is the call graph for this function:

nsresult sbFileMetadataService::Init ( )

Called automatically on first GetService()

Definition at line 107 of file sbFileMetadataService.cpp.

Here is the call graph for this function:

nsresult sbFileMetadataService::ProxiedRestartProcessors ( PRUint16  aProcessorsToRestart)
protected

Proxied version of RestartProcessors present on the sbIFileMetadataService interface.

Definition at line 238 of file sbFileMetadataService.cpp.

Here is the call graph for this function:

nsresult sbFileMetadataService::ProxiedStartJob ( nsIArray *  aMediaItemsArray,
nsIStringEnumerator aRequiredProperties,
sbMetadataJob::JobType  aJobType,
sbIJobProgress **  _retval 
)
protected

Calls StartJob on the main thread, proxying if necessary.

Parameters
aMediaItemsArrayArray of sbIMediaItems
aRequiredPropertiesString Enumerator of the properties to be written, null for read.
aJobTypeOperation to perform (TYPE_READ or TYPE_WRITE)
Returns
An sbIJobProgress interface used to track the work.

Definition at line 283 of file sbFileMetadataService.cpp.

Here is the call graph for this function:

nsresult sbFileMetadataService::PutProcessedJobItem ( sbMetadataJobItem aJobItem)

Give back a job item after processing has been attempted.

May be called off of the main thread.

Parameters
aJobItemThe job item that has been processed

Definition at line 498 of file sbFileMetadataService.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbFileMetadataService::Shutdown ( )
protected

Called automatically on library manager shutdown

Definition at line 145 of file sbFileMetadataService.cpp.

Here is the call graph for this function:

nsresult sbFileMetadataService::StartJob ( nsIArray *  aMediaItemsArray,
nsIStringEnumerator aRequiredProperties,
sbMetadataJob::JobType  aJobType,
sbIJobProgress **  _retval 
)
protected

Create and begin a new job to process the given media items

Notes:

  • *** MAIN THREAD ONLY ***
  • All media items must be from the same library
Parameters
aMediaItemsArrayArray of sbIMediaItems
aRequiredPropertiesString Enumerator of the properties to be written, null for read.
aJobTypeOperation to perform (TYPE_READ or TYPE_WRITE)
Returns
An sbIJobProgress interface used to track the work.

Definition at line 320 of file sbFileMetadataService.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbFileMetadataService::UpdateDataRemotes ( PRInt64  aJobCount)
protected

Update the legacy dataremote flags based on the job count. Note that job count is passed as a param because UpdateDataRemotes is to be called while mJobArray is locked.

Definition at line 755 of file sbFileMetadataService.cpp.

Here is the caller graph for this function:

Member Data Documentation

nsRefPtr<sbBackgroundThreadMetadataProcessor> sbFileMetadataService::mBackgroundThreadProcessor
protected

Definition at line 249 of file sbFileMetadataService.h.

nsRefPtr<sbMetadataCrashTracker> sbFileMetadataService::mCrashTracker
protected

Definition at line 269 of file sbFileMetadataService.h.

nsCOMPtr<sbIDataRemote> sbFileMetadataService::mDataCurrentMetadataJobs
protected

Definition at line 244 of file sbFileMetadataService.h.

PRBool sbFileMetadataService::mInitialized
protected

Definition at line 251 of file sbFileMetadataService.h.

nsTArray<nsRefPtr<sbMetadataJob> > sbFileMetadataService::mJobArray
protected

Definition at line 261 of file sbFileMetadataService.h.

PRLock* sbFileMetadataService::mJobLock
protected

Definition at line 258 of file sbFileMetadataService.h.

nsRefPtr<sbMainThreadMetadataProcessor> sbFileMetadataService::mMainThreadProcessor
protected

Definition at line 247 of file sbFileMetadataService.h.

nsCOMPtr<sbIMediacoreManager> sbFileMetadataService::mMediacoreManager
protected

Definition at line 272 of file sbFileMetadataService.h.

PRUint32 sbFileMetadataService::mNextJobIndex
protected

Definition at line 265 of file sbFileMetadataService.h.

nsCOMPtr<nsITimer> sbFileMetadataService::mNotificationTimer
protected

Definition at line 255 of file sbFileMetadataService.h.

PRBool sbFileMetadataService::mRunning
protected

Definition at line 252 of file sbFileMetadataService.h.


The documentation for this class was generated from the following files: