mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 531151 - Increase Annotation Service robustness, r=dietrich
This commit is contained in:
parent
a8b2d6888e
commit
47e2f806ca
@ -548,6 +548,10 @@ function run_test() {
|
||||
flags: 0,
|
||||
value: 123,
|
||||
expires: Ci.nsIAnnotationService.EXPIRE_NEVER };
|
||||
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
hs.addVisit(uri("http://www.mozilla.org/"), Date.now() * 1000, null,
|
||||
hs.TRANSITION_TYPED, false, 0);
|
||||
var genPageAnnoTxn = ptSvc.setPageAnnotation(uri("http://www.mozilla.org/"), pageAnnoObj);
|
||||
genPageAnnoTxn.doTransaction();
|
||||
do_check_true(annosvc.pageHasAnnotation(uri("http://www.mozilla.org/"), "testAnno/testInt"));
|
||||
|
@ -48,16 +48,20 @@ interface nsIAnnotationObserver : nsISupports
|
||||
* Called when an annotation value is set. It could be a new annotation,
|
||||
* or it could be a new value for an existing annotation.
|
||||
*/
|
||||
void onPageAnnotationSet(in nsIURI aPage, in AUTF8String aName);
|
||||
void onItemAnnotationSet(in long long aItemId, in AUTF8String aName);
|
||||
void onPageAnnotationSet(in nsIURI aPage,
|
||||
in AUTF8String aName);
|
||||
void onItemAnnotationSet(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* Called when an annotation is deleted. If aName is empty, then ALL
|
||||
* annotations for the given URI have been deleted. This is not called when
|
||||
* annotations are expired (normally happens when the app exits).
|
||||
*/
|
||||
void onPageAnnotationRemoved(in nsIURI aURI, in AUTF8String aName);
|
||||
void onItemAnnotationRemoved(in long long aItemId, in AUTF8String aName);
|
||||
void onPageAnnotationRemoved(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
void onItemAnnotationRemoved(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
};
|
||||
|
||||
[scriptable, uuid(ba249b58-346f-42a9-a393-203ae34ec6c4)]
|
||||
@ -143,56 +147,89 @@ interface nsIAnnotationService : nsISupports
|
||||
* Binary annotations should be set using
|
||||
* setItemAnnotationBinary/setPageAnnotationBinary. For other types, only
|
||||
* C++ consumers may use the type-specific methods.
|
||||
*
|
||||
* @throws NS_ERROR_ILLEGAL_VALUE if the page or the bookmark doesn't exist.
|
||||
*/
|
||||
void setPageAnnotation(in nsIURI aURI, in AUTF8String aName,
|
||||
in nsIVariant aValue, in long aFlags,
|
||||
void setPageAnnotation(in nsIURI aURI,
|
||||
in AUTF8String aName,
|
||||
in nsIVariant aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
void setItemAnnotation(in long long aItemId, in AUTF8String aName,
|
||||
in nsIVariant aValue, in long aFlags,
|
||||
void setItemAnnotation(in long long aItemId,
|
||||
in AUTF8String aName,
|
||||
in nsIVariant aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
|
||||
[noscript] void setPageAnnotationString(in nsIURI aURI, in AUTF8String aName,
|
||||
in AString aValue, in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
[noscript] void setItemAnnotationString(in long long aItemId, in AUTF8String aName,
|
||||
in AString aValue, in long aFlags,
|
||||
/**
|
||||
* @throws NS_ERROR_ILLEGAL_VALUE if the page or the bookmark doesn't exist.
|
||||
*/
|
||||
[noscript] void setPageAnnotationString(in nsIURI aURI,
|
||||
in AUTF8String aName,
|
||||
in AString aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
[noscript] void setItemAnnotationString(in long long aItemId,
|
||||
in AUTF8String aName,
|
||||
in AString aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
|
||||
/**
|
||||
* Sets an annotation just like setAnnotationString, but takes an Int32 as
|
||||
* input.
|
||||
*
|
||||
* @throws NS_ERROR_ILLEGAL_VALUE if the page or the bookmark doesn't exist.
|
||||
*/
|
||||
[noscript] void setPageAnnotationInt32(in nsIURI aURI, in AUTF8String aName,
|
||||
in long aValue, in long aFlags,
|
||||
[noscript] void setPageAnnotationInt32(in nsIURI aURI,
|
||||
in AUTF8String aName,
|
||||
in long aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
[noscript] void setItemAnnotationInt32(in long long aItemId, in AUTF8String aName,
|
||||
in long aValue, in long aFlags,
|
||||
[noscript] void setItemAnnotationInt32(in long long aItemId,
|
||||
in AUTF8String aName,
|
||||
in long aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
|
||||
/**
|
||||
* Sets an annotation just like setAnnotationString, but takes an Int64 as
|
||||
* input.
|
||||
*
|
||||
* @throws NS_ERROR_ILLEGAL_VALUE if the page or the bookmark doesn't exist.
|
||||
*/
|
||||
[noscript] void setPageAnnotationInt64(in nsIURI aURI, in AUTF8String aName,
|
||||
in long long aValue, in long aFlags,
|
||||
[noscript] void setPageAnnotationInt64(in nsIURI aURI,
|
||||
in AUTF8String aName,
|
||||
in long long aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
[noscript] void setItemAnnotationInt64(in long long aItemId, in AUTF8String aName,
|
||||
in long long aValue, in long aFlags,
|
||||
[noscript] void setItemAnnotationInt64(in long long aItemId,
|
||||
in AUTF8String aName,
|
||||
in long long aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
|
||||
/**
|
||||
* Sets an annotation just like setAnnotationString, but takes a double as
|
||||
* input.
|
||||
*
|
||||
* @throws NS_ERROR_ILLEGAL_VALUE if the page or the bookmark doesn't exist.
|
||||
*/
|
||||
[noscript] void setPageAnnotationDouble(in nsIURI aURI, in AUTF8String aName,
|
||||
in double aValue, in long aFlags,
|
||||
[noscript] void setPageAnnotationDouble(in nsIURI aURI,
|
||||
in AUTF8String aName,
|
||||
in double aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
[noscript] void setItemAnnotationDouble(in long long aItemId, in AUTF8String aName,
|
||||
in double aValue, in long aFlags,
|
||||
[noscript] void setItemAnnotationDouble(in long long aItemId,
|
||||
in AUTF8String aName,
|
||||
in double aValue,
|
||||
in long aFlags,
|
||||
in unsigned short aExpiration);
|
||||
/*
|
||||
/**
|
||||
* Sets an annotation just like setAnnotationString, but takes binary data
|
||||
* as input. You MUST supply a valid MIME type.
|
||||
*
|
||||
* @throws NS_ERROR_ILLEGAL_VALUE if the page or the bookmark doesn't exist.
|
||||
*/
|
||||
void setPageAnnotationBinary(in nsIURI aURI, in AUTF8String aName,
|
||||
[const,array,size_is(aDataLen)] in octet aData,
|
||||
@ -216,42 +253,54 @@ interface nsIAnnotationService : nsISupports
|
||||
* The type-specific methods throw if the given annotation is set in
|
||||
* a different type.
|
||||
*/
|
||||
nsIVariant getPageAnnotation(in nsIURI aURI, in AUTF8String aName);
|
||||
nsIVariant getItemAnnotation(in long long aItemId, in AUTF8String aName);
|
||||
nsIVariant getPageAnnotation(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
nsIVariant getItemAnnotation(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* @see getPageAnnotation
|
||||
*/
|
||||
[noscript] AString getPageAnnotationString(in nsIURI aURI, in AUTF8String aName);
|
||||
[noscript] AString getItemAnnotationString(in long long aItemId, in AUTF8String aName);
|
||||
[noscript] AString getPageAnnotationString(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
[noscript] AString getItemAnnotationString(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* @see getPageAnnotation
|
||||
*/
|
||||
[noscript] long getPageAnnotationInt32(in nsIURI aURI, in AUTF8String aName);
|
||||
[noscript] long getItemAnnotationInt32(in long long aItemId, in AUTF8String aName);
|
||||
[noscript] long getPageAnnotationInt32(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
[noscript] long getItemAnnotationInt32(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* @see getPageAnnotation
|
||||
*/
|
||||
[noscript] long long getPageAnnotationInt64(in nsIURI aURI, in AUTF8String aName);
|
||||
[noscript] long long getItemAnnotationInt64(in long long aItemId, in AUTF8String aName);
|
||||
[noscript] long long getPageAnnotationInt64(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
[noscript] long long getItemAnnotationInt64(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* @see getPageAnnotation
|
||||
*/
|
||||
[noscript] double getPageAnnotationDouble(in nsIURI aURI, in AUTF8String aName);
|
||||
[noscript] double getItemAnnotationDouble(in long long aItemId, in AUTF8String aName);
|
||||
[noscript] double getPageAnnotationDouble(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
[noscript] double getItemAnnotationDouble(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* @see getPageAnnotation. This also returns the
|
||||
* MIME type.
|
||||
*/
|
||||
void getPageAnnotationBinary(in nsIURI aURI, in AUTF8String aName,
|
||||
void getPageAnnotationBinary(in nsIURI aURI,
|
||||
in AUTF8String aName,
|
||||
[array,size_is(aDataLen)] out octet aData,
|
||||
out unsigned long aDataLen,
|
||||
out AUTF8String aMimeType);
|
||||
void getItemAnnotationBinary(in long long aItemId, in AUTF8String aName,
|
||||
void getItemAnnotationBinary(in long long aItemId,
|
||||
in AUTF8String aName,
|
||||
[array,size_is(aDataLen)] out octet aData,
|
||||
out unsigned long aDataLen,
|
||||
out AUTF8String aMimeType);
|
||||
@ -273,8 +322,10 @@ interface nsIAnnotationService : nsISupports
|
||||
out unsigned short aExpiration,
|
||||
out AUTF8String aMimeType,
|
||||
out unsigned short aType);
|
||||
void getItemAnnotationInfo(in long long aItemId, in AUTF8String aName,
|
||||
out long aFlags, out unsigned short aExpiration,
|
||||
void getItemAnnotationInfo(in long long aItemId,
|
||||
in AUTF8String aName,
|
||||
out long aFlags,
|
||||
out unsigned short aExpiration,
|
||||
out AUTF8String aMimeType,
|
||||
out unsigned short aType);
|
||||
|
||||
@ -289,16 +340,20 @@ interface nsIAnnotationService : nsISupports
|
||||
* @return one of the TYPE_* constants above
|
||||
* @throws if the annotation is not set
|
||||
*/
|
||||
PRUint16 getPageAnnotationType(in nsIURI aURI, in AUTF8String aName);
|
||||
PRUint16 getItemAnnotationType(in long long aItemId, in AUTF8String aName);
|
||||
PRUint16 getPageAnnotationType(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
PRUint16 getItemAnnotationType(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* Returns a list of all URIs having a given annotation.
|
||||
*/
|
||||
void getPagesWithAnnotation(in AUTF8String name,
|
||||
void getPagesWithAnnotation(
|
||||
in AUTF8String name,
|
||||
[optional] out unsigned long resultCount,
|
||||
[retval, array, size_is(resultCount)] out nsIURI results);
|
||||
void getItemsWithAnnotation(in AUTF8String name,
|
||||
void getItemsWithAnnotation(
|
||||
in AUTF8String name,
|
||||
[optional] out unsigned long resultCount,
|
||||
[retval, array, size_is(resultCount)] out long long results);
|
||||
|
||||
@ -308,25 +363,31 @@ interface nsIAnnotationService : nsISupports
|
||||
* example JS:
|
||||
* var annotations = annotator.getPageAnnotations(myURI, {});
|
||||
*/
|
||||
void getPageAnnotationNames(in nsIURI aURI,
|
||||
void getPageAnnotationNames(
|
||||
in nsIURI aURI,
|
||||
[optional] out unsigned long count,
|
||||
[retval, array, size_is(count)] out nsIVariant result);
|
||||
void getItemAnnotationNames(in long long aItemId,
|
||||
void getItemAnnotationNames(
|
||||
in long long aItemId,
|
||||
[optional] out unsigned long count,
|
||||
[retval, array, size_is(count)] out nsIVariant result);
|
||||
|
||||
/**
|
||||
* Test for annotation existance.
|
||||
* Test for annotation existence.
|
||||
*/
|
||||
boolean pageHasAnnotation(in nsIURI aURI, in AUTF8String aName);
|
||||
boolean itemHasAnnotation(in long long aItemId, in AUTF8String aName);
|
||||
boolean pageHasAnnotation(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
boolean itemHasAnnotation(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* Removes a specific annotation. Succeeds even if the annotation is
|
||||
* not found.
|
||||
*/
|
||||
void removePageAnnotation(in nsIURI aURI, in AUTF8String aName);
|
||||
void removeItemAnnotation(in long long aItemId, in AUTF8String aName);
|
||||
void removePageAnnotation(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
void removeItemAnnotation(in long long aItemId,
|
||||
in AUTF8String aName);
|
||||
|
||||
/**
|
||||
* Removes all annotations for the given page/item.
|
||||
@ -340,12 +401,13 @@ interface nsIAnnotationService : nsISupports
|
||||
* Copies all annotations from the source to the destination URI/item. If
|
||||
* the destination already has an annotation with the same name as one on
|
||||
* the source, it will be overwritten if aOverwriteDest is set. Otherwise,
|
||||
* the destination URIs will be preferred.
|
||||
* the original annotation will be preferred.
|
||||
*
|
||||
* All the source annotations will stay as-is. If you don't want them
|
||||
* any more, use removePageAnnotations on that URI.
|
||||
*/
|
||||
void copyPageAnnotations(in nsIURI aSourceURI, in nsIURI aDestURI,
|
||||
void copyPageAnnotations(in nsIURI aSourceURI,
|
||||
in nsIURI aDestURI,
|
||||
in boolean aOverwriteDest);
|
||||
void copyItemAnnotations(in long long aSourceItemId,
|
||||
in long long aDestItemId,
|
||||
@ -370,5 +432,6 @@ interface nsIAnnotationService : nsISupports
|
||||
* set by setAnnotationBinary. No non-URI valid chars in name, especially
|
||||
* colon, which will mess up parsing.
|
||||
*/
|
||||
nsIURI getAnnotationURI(in nsIURI aURI, in AUTF8String aName);
|
||||
nsIURI getAnnotationURI(in nsIURI aURI,
|
||||
in AUTF8String aName);
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brett Wilson <brettw@gmail.com> (original author)
|
||||
* Marco Bonardo <mak77@bonardo.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -56,7 +57,7 @@ public:
|
||||
/**
|
||||
* Obtains the service's object.
|
||||
*/
|
||||
static nsAnnotationService *GetSingleton();
|
||||
static nsAnnotationService* GetSingleton();
|
||||
|
||||
/**
|
||||
* Initializes the service's object. This should only be called once.
|
||||
@ -69,7 +70,7 @@ public:
|
||||
* Returns a cached pointer to the annotation service for consumers in the
|
||||
* places directory.
|
||||
*/
|
||||
static nsAnnotationService * GetAnnotationService()
|
||||
static nsAnnotationService* GetAnnotationService()
|
||||
{
|
||||
if (!gAnnotationService) {
|
||||
nsCOMPtr<nsIAnnotationService> serv =
|
||||
@ -96,29 +97,27 @@ protected:
|
||||
nsCOMPtr<mozIStorageService> mDBService;
|
||||
nsCOMPtr<mozIStorageConnection> mDBConn;
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> mDBSetAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBSetItemAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetItemAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetAnnotationNames;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetItemAnnotationNames;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetAnnotationFromURI;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetAnnotationFromItemId;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetAnnotationNameID;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetAnnotationsForPage;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetAnnotationsForItem;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetPageAnnotationValue;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetItemAnnotationValue;
|
||||
nsCOMPtr<mozIStorageStatement> mDBAddAnnotationName;
|
||||
nsCOMPtr<mozIStorageStatement> mDBAddAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBAddPageAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBAddItemAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBRemoveAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBRemovePageAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBRemoveItemAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetPagesWithAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBGetItemsWithAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBCheckPageAnnotation;
|
||||
nsCOMPtr<mozIStorageStatement> mDBCheckItemAnnotation;
|
||||
|
||||
nsCOMArray<nsIAnnotationObserver> mObservers;
|
||||
|
||||
static nsAnnotationService *gAnnotationService;
|
||||
static nsAnnotationService* gAnnotationService;
|
||||
|
||||
static const int kAnnoIndex_ID;
|
||||
static const int kAnnoIndex_PageOrItem;
|
||||
static const int kAnnoIndex_Name;
|
||||
static const int kAnnoIndex_NameID;
|
||||
static const int kAnnoIndex_MimeType;
|
||||
static const int kAnnoIndex_Content;
|
||||
static const int kAnnoIndex_Flags;
|
||||
@ -127,70 +126,71 @@ protected:
|
||||
static const int kAnnoIndex_DateAdded;
|
||||
static const int kAnnoIndex_LastModified;
|
||||
|
||||
nsresult HasAnnotationInternal(PRInt64 aFkId, PRBool aIsBookmarkId,
|
||||
const nsACString& aName, PRBool* hasAnnotation,
|
||||
PRInt64* annotationID);
|
||||
nsresult StartGetAnnotationFromURI(nsIURI* aURI,
|
||||
const nsACString& aName);
|
||||
nsresult StartGetAnnotationFromItemId(PRInt64 aItemId,
|
||||
const nsACString& aName);
|
||||
nsresult StartSetAnnotation(PRInt64 aFkId,
|
||||
PRBool aIsItemAnnotation,
|
||||
nsresult HasAnnotationInternal(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName,
|
||||
PRBool* _hasAnno);
|
||||
|
||||
nsresult StartGetAnnotation(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName,
|
||||
mozIStorageStatement** _statement);
|
||||
|
||||
nsresult StartSetAnnotation(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName,
|
||||
PRInt32 aFlags,
|
||||
PRUint16 aExpiration,
|
||||
PRUint16 aType,
|
||||
mozIStorageStatement** aStatement);
|
||||
nsresult SetAnnotationStringInternal(PRInt64 aItemId,
|
||||
PRBool aIsItemAnnotation,
|
||||
mozIStorageStatement** _statement);
|
||||
|
||||
nsresult SetAnnotationStringInternal(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName,
|
||||
const nsAString& aValue,
|
||||
PRInt32 aFlags,
|
||||
PRUint16 aExpiration);
|
||||
nsresult SetAnnotationInt32Internal(PRInt64 aFkId,
|
||||
PRBool aIsItemAnnotation,
|
||||
nsresult SetAnnotationInt32Internal(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName,
|
||||
PRInt32 aValue,
|
||||
PRInt32 aFlags,
|
||||
PRUint16 aExpiration);
|
||||
nsresult SetAnnotationInt64Internal(PRInt64 aFkId,
|
||||
PRBool aIsItemAnnotation,
|
||||
nsresult SetAnnotationInt64Internal(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName,
|
||||
PRInt64 aValue,
|
||||
PRInt32 aFlags,
|
||||
PRUint16 aExpiration);
|
||||
nsresult SetAnnotationDoubleInternal(PRInt64 aFkId,
|
||||
PRBool aIsItemAnnotation,
|
||||
nsresult SetAnnotationDoubleInternal(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName,
|
||||
double aValue,
|
||||
PRInt32 aFlags,
|
||||
PRUint16 aExpiration);
|
||||
nsresult SetAnnotationBinaryInternal(PRInt64 aFkId,
|
||||
PRBool aIsItemAnnotation,
|
||||
nsresult SetAnnotationBinaryInternal(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName,
|
||||
const PRUint8 *aData,
|
||||
const PRUint8* aData,
|
||||
PRUint32 aDataLen,
|
||||
const nsACString& aMimeType,
|
||||
PRInt32 aFlags,
|
||||
PRUint16 aExpiration);
|
||||
nsresult RemoveAnnotationInternal(PRInt64 aFkId,
|
||||
PRBool aIsItemAnnotation,
|
||||
|
||||
nsresult RemoveAnnotationInternal(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
const nsACString& aName);
|
||||
static nsresult GetPlaceIdForURI(nsIURI* aURI, PRInt64* _retval,
|
||||
PRBool aAutoCreate = PR_TRUE);
|
||||
|
||||
PRBool InPrivateBrowsingMode() const;
|
||||
|
||||
void CallSetForPageObservers(nsIURI* aURI, const nsACString& aName);
|
||||
void CallSetForItemObservers(PRInt64 aItemId, const nsACString& aName);
|
||||
|
||||
public:
|
||||
nsresult GetPagesWithAnnotationCOMArray(const nsACString& aName,
|
||||
nsCOMArray<nsIURI>* aResults);
|
||||
nsCOMArray<nsIURI>* _results);
|
||||
nsresult GetItemsWithAnnotationTArray(const nsACString& aName,
|
||||
nsTArray<PRInt64>* aResult);
|
||||
nsresult GetAnnotationNamesTArray(PRInt64 aFkId, nsTArray<nsCString>* aResult,
|
||||
PRBool aIsFkItemId);
|
||||
nsTArray<PRInt64>* _result);
|
||||
nsresult GetAnnotationNamesTArray(nsIURI* aURI,
|
||||
PRInt64 aItemId,
|
||||
nsTArray<nsCString>* _result);
|
||||
};
|
||||
|
||||
#endif /* nsAnnotationService_h___ */
|
||||
|
@ -4925,7 +4925,12 @@ nsNavHistory::SetCharsetForURI(nsIURI* aURI,
|
||||
nsresult rv = annosvc->SetPageAnnotationString(aURI, CHARSET_ANNO,
|
||||
aCharset, 0,
|
||||
nsAnnotationService::EXPIRE_NEVER);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (rv == NS_ERROR_INVALID_ARG) {
|
||||
// We don't have this page. Silently fail.
|
||||
return NS_OK;
|
||||
}
|
||||
else if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -291,8 +291,6 @@ function populateDB(aArray) {
|
||||
bmsvc.setItemDateAdded(itemId, qdata.dateAdded);
|
||||
if (qdata.lastModified)
|
||||
bmsvc.setItemLastModified(itemId, qdata.lastModified);
|
||||
|
||||
LOG("added bookmark");
|
||||
}
|
||||
|
||||
if (qdata.isTag) {
|
||||
@ -402,14 +400,18 @@ function compareArrayToResult(aArray, aRoot) {
|
||||
LOG("testing testData[" + i + "] vs result[" + inQueryIndex + "]");
|
||||
if(!aArray[i].isFolder) {
|
||||
LOG("testing testData[" + aArray[i].uri + "] vs result[" + child.uri + "]");
|
||||
do_check_eq(aArray[i].uri, child.uri);
|
||||
if (aArray[i].uri != child.uri)
|
||||
do_throw("Expected " + aArray[i].uri + " found " + child.uri);
|
||||
}
|
||||
do_check_eq(aArray[i].title, child.title);
|
||||
if (aArray[i].hasOwnProperty("lastVisit"))
|
||||
do_check_eq(aArray[i].lastVisit, child.time);
|
||||
if (aArray[i].title != child.title)
|
||||
do_throw("Expected " + aArray[i].title + " found " + child.title);
|
||||
if (aArray[i].hasOwnProperty("lastVisit") &&
|
||||
aArray[i].lastVisit != child.time)
|
||||
do_throw("Expected " + aArray[i].lastVisit + " found " + child.time);
|
||||
if (aArray[i].hasOwnProperty("index") &&
|
||||
aArray[i].index != bmsvc.DEFAULT_INDEX)
|
||||
do_check_eq(aArray[i].index, child.bookmarkIndex);
|
||||
aArray[i].index != bmsvc.DEFAULT_INDEX &&
|
||||
aArray[i].index != child.bookmarkIndex)
|
||||
do_throw("Expected " + aArray[i].index + " found " + child.bookmarkIndex);
|
||||
|
||||
inQueryIndex++;
|
||||
}
|
||||
|
@ -101,7 +101,6 @@ function buildTestDatabase() {
|
||||
0);
|
||||
|
||||
testURI = uri("http://foo.com/youdontseeme.html");
|
||||
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, 0);
|
||||
for (var i=0; i < 12; ++i)
|
||||
add_visit(testURI,
|
||||
today,
|
||||
@ -109,6 +108,7 @@ function buildTestDatabase() {
|
||||
modHistoryTypes(i), // will work with different values, for ex: histsvc.TRANSITION_TYPED,
|
||||
false,
|
||||
0);
|
||||
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,7 +239,8 @@ function run_test() {
|
||||
runBatched: function (aUserData) {
|
||||
var batchChange = [{isDetails: true, uri: "http://foo.com/changeme2",
|
||||
title: "moz", lastVisit: jan7_800},
|
||||
{isPageAnnotation: true, uri: "http://foo.com/begin.html",
|
||||
{isDetails: true, uri: "http://foo.com/begin.html",
|
||||
isPageAnnotation: true,
|
||||
annoName: badAnnoName, annoVal: val}];
|
||||
populateDB(batchChange);
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ function run_test() {
|
||||
|
||||
// test getPagesWithAnnotation
|
||||
var uri2 = uri("http://www.tests.tld");
|
||||
histsvc.addVisit(uri2, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||
annosvc.setPageAnnotation(uri2, testAnnoName, testAnnoVal, 0, 0);
|
||||
var pages = annosvc.getPagesWithAnnotation(testAnnoName);
|
||||
do_check_eq(pages.length, 2);
|
||||
@ -191,13 +192,58 @@ function run_test() {
|
||||
do_check_eq(annoNames.length, 1);
|
||||
do_check_eq(annoNames[0], "moz-test-places/annotations");
|
||||
|
||||
/* copy annotations to another uri
|
||||
// copy annotations to another uri
|
||||
var newURI = uri("http://mozilla.org");
|
||||
histsvc.addVisit(newURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||
annosvc.setPageAnnotation(testURI, "oldAnno", "new", 0, 0);
|
||||
annosvc.setPageAnnotation(newURI, "oldAnno", "old", 0, 0);
|
||||
var annoNames = annosvc.getPageAnnotationNames(newURI);
|
||||
do_check_eq(annoNames.length, 1);
|
||||
do_check_eq(annoNames[0], "oldAnno");
|
||||
var oldAnnoNames = annosvc.getPageAnnotationNames(testURI);
|
||||
annosvc.copyAnnotations(testURI, newURI, false);
|
||||
do_check_eq(oldAnnoNames.length, 2);
|
||||
var copiedAnno = oldAnnoNames[0];
|
||||
annosvc.copyPageAnnotations(testURI, newURI, false);
|
||||
var newAnnoNames = annosvc.getPageAnnotationNames(newURI);
|
||||
do_check_eq(oldAnnoNames.length, newAnnoNames.length);
|
||||
*/
|
||||
do_check_eq(newAnnoNames.length, 2);
|
||||
do_check_true(annosvc.pageHasAnnotation(newURI, "oldAnno"));
|
||||
do_check_true(annosvc.pageHasAnnotation(newURI, copiedAnno));
|
||||
do_check_eq(annosvc.getPageAnnotation(newURI, "oldAnno"), "old");
|
||||
annosvc.setPageAnnotation(newURI, "oldAnno", "new", 0, 0);
|
||||
annosvc.copyPageAnnotations(testURI, newURI, true);
|
||||
newAnnoNames = annosvc.getPageAnnotationNames(newURI);
|
||||
do_check_eq(newAnnoNames.length, 2);
|
||||
do_check_true(annosvc.pageHasAnnotation(newURI, "oldAnno"));
|
||||
do_check_true(annosvc.pageHasAnnotation(newURI, copiedAnno));
|
||||
do_check_eq(annosvc.getPageAnnotation(newURI, "oldAnno"), "new");
|
||||
|
||||
|
||||
// copy annotations to another item
|
||||
var newURI = uri("http://mozilla.org");
|
||||
var newItemId = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, newURI, -1, "");
|
||||
var itemId = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, testURI, -1, "");
|
||||
annosvc.setItemAnnotation(itemId, "oldAnno", "new", 0, 0);
|
||||
annosvc.setItemAnnotation(itemId, "testAnno", "test", 0, 0);
|
||||
annosvc.setItemAnnotation(newItemId, "oldAnno", "old", 0, 0);
|
||||
var annoNames = annosvc.getItemAnnotationNames(newItemId);
|
||||
do_check_eq(annoNames.length, 1);
|
||||
do_check_eq(annoNames[0], "oldAnno");
|
||||
var oldAnnoNames = annosvc.getItemAnnotationNames(itemId);
|
||||
do_check_eq(oldAnnoNames.length, 2);
|
||||
var copiedAnno = oldAnnoNames[0];
|
||||
annosvc.copyItemAnnotations(itemId, newItemId, false);
|
||||
var newAnnoNames = annosvc.getItemAnnotationNames(newItemId);
|
||||
do_check_eq(newAnnoNames.length, 2);
|
||||
do_check_true(annosvc.itemHasAnnotation(newItemId, "oldAnno"));
|
||||
do_check_true(annosvc.itemHasAnnotation(newItemId, copiedAnno));
|
||||
do_check_eq(annosvc.getItemAnnotation(newItemId, "oldAnno"), "old");
|
||||
annosvc.setItemAnnotation(newItemId, "oldAnno", "new", 0, 0);
|
||||
annosvc.copyItemAnnotations(itemId, newItemId, true);
|
||||
newAnnoNames = annosvc.getItemAnnotationNames(newItemId);
|
||||
do_check_eq(newAnnoNames.length, 2);
|
||||
do_check_true(annosvc.itemHasAnnotation(newItemId, "oldAnno"));
|
||||
do_check_true(annosvc.itemHasAnnotation(newItemId, copiedAnno));
|
||||
do_check_eq(annosvc.getItemAnnotation(newItemId, "oldAnno"), "new");
|
||||
|
||||
// test int32 anno type
|
||||
var int32Key = testAnnoName + "/types/Int32";
|
||||
|
@ -128,6 +128,7 @@ function run_test() {
|
||||
var removeAllTestURI = uri("http://removeallpages.com");
|
||||
var removeAllTestURINever = uri("http://removeallpagesnever.com");
|
||||
histsvc.addVisit(removeAllTestURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||
histsvc.addVisit(removeAllTestURINever, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||
var bmURI = uri("http://bookmarked");
|
||||
var bookmark2 = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, bmURI, bmsvc.DEFAULT_INDEX, "foo");
|
||||
var placeURI = uri("place:folder=23");
|
||||
@ -229,8 +230,8 @@ function run_test() {
|
||||
|
||||
// set dateAdded to 8 days ago
|
||||
var expirationDate = (Date.now() - (8 * 86400 * 1000)) * 1000;
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
|
||||
// these annotations should remain
|
||||
annosvc.setPageAnnotation(testURI, testAnnoName + "NotExpired", testAnnoVal, 0, annosvc.EXPIRE_DAYS);
|
||||
@ -270,8 +271,8 @@ function run_test() {
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_DAYS);
|
||||
// these annotations should remain as they are only 6 days old
|
||||
var expirationDate = (Date.now() - (6 * 86400 * 1000)) * 1000;
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
|
||||
// add a uri and then remove it, to trigger expiration
|
||||
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||
@ -298,8 +299,8 @@ function run_test() {
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WEEKS);
|
||||
// these annotations should not remain as they are 31 days old
|
||||
var expirationDate = (Date.now() - (31 * 86400 * 1000)) * 1000;
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
// these annotations should remain
|
||||
annosvc.setPageAnnotation(testURI, testAnnoName + "NotExpired", testAnnoVal, 0, annosvc.EXPIRE_WEEKS);
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName + "NotExpired", testAnnoVal, 0, annosvc.EXPIRE_WEEKS);
|
||||
@ -337,8 +338,8 @@ function run_test() {
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_WEEKS);
|
||||
// these annotations should remain as they are only 29 days old
|
||||
var expirationDate = (Date.now() - (29 * 86400 * 1000)) * 1000;
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
|
||||
// add a uri and then remove it, to trigger expiration
|
||||
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||
@ -362,8 +363,8 @@ function run_test() {
|
||||
annosvc.setPageAnnotation(testURI, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_MONTHS);
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_MONTHS);
|
||||
var expirationDate = (Date.now() - (181 * 86400 * 1000)) * 1000;
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
// these annotations should remain
|
||||
annosvc.setPageAnnotation(testURI, testAnnoName + "NotExpired", testAnnoVal, 0, annosvc.EXPIRE_MONTHS);
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName + "NotExpired", testAnnoVal, 0, annosvc.EXPIRE_MONTHS);
|
||||
@ -401,8 +402,8 @@ function run_test() {
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_MONTHS);
|
||||
// these annotations should remain as they are only 179 days old
|
||||
var expirationDate = (Date.now() - (179 * 86400 * 1000)) * 1000;
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
|
||||
// add a uri and then remove it, to trigger expiration
|
||||
histsvc.addVisit(triggerURI, Date.now() * 1000, null, histsvc.TRANSITION_TYPED, false, 0);
|
||||
@ -431,8 +432,8 @@ function run_test() {
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName, testAnnoVal, 0, annosvc.EXPIRE_DAYS);
|
||||
// make it 8 days old
|
||||
var expirationDate = (Date.now() - (8 * 86400 * 1000)) * 1000;
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
dbConnection.executeSimpleSQL("UPDATE moz_items_annos SET dateAdded = " + expirationDate + ", lastModified = " + expirationDate);
|
||||
// modify its value
|
||||
annosvc.setPageAnnotation(testURI, testAnnoName, "mod", 0, annosvc.EXPIRE_DAYS);
|
||||
annosvc.setItemAnnotation(bookmark, testAnnoName, "mod", 0, annosvc.EXPIRE_DAYS);
|
||||
|
Loading…
Reference in New Issue
Block a user