#include <sbMetadataCrashTracker.h>
Public Member Functions | |
NS_DECL_ISUPPORTS | sbMetadataCrashTracker () |
virtual | ~sbMetadataCrashTracker () |
nsresult | Init () |
nsresult | StartLog () |
nsresult | ResetLog () |
nsresult | LogURLBegin (const nsACString &aURL) |
nsresult | LogURLEnd (const nsACString &aURL) |
nsresult | IsURLBlacklisted (const nsACString &aURL, PRBool *aIsBlackListed) |
nsresult | AddBlacklistURL (const nsACString &aURL) |
Used by sbFileMetadataService to keep a persistent log of all file activity, and avoid processing files that may have caused the app to crash in the past. This is necessary because we don't completely trust the sbIMetadataHandler implementations, and could otherwise repeatedly crash trying to read/write the same file.
To improve performance we don't bother flushing the log on write. Instead we trust the OS to flush and close on app crash.
The unit test framework can't handle crashes, so to verify this functionality, set a "songbird.metadata.simulate.crash.url" preference to a partial filename, then run a media import.
Definition at line 70 of file sbMetadataCrashTracker.h.
sbMetadataCrashTracker::sbMetadataCrashTracker | ( | ) |
Definition at line 72 of file sbMetadataCrashTracker.cpp.
|
virtual |
nsresult sbMetadataCrashTracker::AddBlacklistURL | ( | const nsACString & | aURL | ) |
Adds a URL to the blacklist
NOTE This method is not threadsafe by design; it only exists to be used in the unit test. This should not be called by production code.
Definition at line 284 of file sbMetadataCrashTracker.cpp.
nsresult sbMetadataCrashTracker::Init | ( | ) |
Initialize the tracker. Must be called once at startup before first use.
Definition at line 95 of file sbMetadataCrashTracker.cpp.
nsresult sbMetadataCrashTracker::IsURLBlacklisted | ( | const nsACString & | aURL, |
PRBool * | aIsBlackListed | ||
) |
Sets aIsBlackListed true if the given URL is suspected of causing a crash on a previous run.
Definition at line 274 of file sbMetadataCrashTracker.cpp.
nsresult sbMetadataCrashTracker::LogURLBegin | ( | const nsACString & | aURL | ) |
Record that the given URL is about to be processed. If we crash, this URL may be the cause.
Definition at line 197 of file sbMetadataCrashTracker.cpp.
nsresult sbMetadataCrashTracker::LogURLEnd | ( | const nsACString & | aURL | ) |
Record that the given URL has been successfully processed. If we crash, this URL is not to blame.
Definition at line 245 of file sbMetadataCrashTracker.cpp.
nsresult sbMetadataCrashTracker::ResetLog | ( | ) |
Close and destroy the log file. To be called when all jobs have completed successfully.
Note that this does not finalize the class, and tracking can be started again by calling StartLog or LogURLBegin
Definition at line 178 of file sbMetadataCrashTracker.cpp.
nsresult sbMetadataCrashTracker::StartLog | ( | ) |
Opens a new log file. Called implicitly by LogURLBegin.
Definition at line 152 of file sbMetadataCrashTracker.cpp.