toolkit/components/places/nsAnnotationService.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 //* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsAnnotationService_h___
michael@0 7 #define nsAnnotationService_h___
michael@0 8
michael@0 9 #include "nsIAnnotationService.h"
michael@0 10 #include "nsTArray.h"
michael@0 11 #include "nsCOMArray.h"
michael@0 12 #include "nsCOMPtr.h"
michael@0 13 #include "nsServiceManagerUtils.h"
michael@0 14 #include "nsWeakReference.h"
michael@0 15 #include "nsToolkitCompsCID.h"
michael@0 16 #include "Database.h"
michael@0 17 #include "nsString.h"
michael@0 18 #include "mozilla/Attributes.h"
michael@0 19
michael@0 20 namespace mozilla {
michael@0 21 namespace places {
michael@0 22
michael@0 23 class AnnotatedResult MOZ_FINAL : public mozIAnnotatedResult
michael@0 24 {
michael@0 25 public:
michael@0 26 NS_DECL_ISUPPORTS
michael@0 27 NS_DECL_MOZIANNOTATEDRESULT
michael@0 28
michael@0 29 AnnotatedResult(const nsCString& aGUID, nsIURI* aURI, int64_t aItemd,
michael@0 30 const nsACString& aAnnotationName,
michael@0 31 nsIVariant* aAnnotationValue);
michael@0 32
michael@0 33 private:
michael@0 34 const nsCString mGUID;
michael@0 35 nsCOMPtr<nsIURI> mURI;
michael@0 36 const int64_t mItemId;
michael@0 37 const nsCString mAnnotationName;
michael@0 38 nsCOMPtr<nsIVariant> mAnnotationValue;
michael@0 39 };
michael@0 40
michael@0 41 } // namespace places
michael@0 42 } // namespace mozilla
michael@0 43
michael@0 44 class nsAnnotationService MOZ_FINAL : public nsIAnnotationService
michael@0 45 , public nsIObserver
michael@0 46 , public nsSupportsWeakReference
michael@0 47 {
michael@0 48 public:
michael@0 49 NS_DECL_ISUPPORTS
michael@0 50 NS_DECL_NSIANNOTATIONSERVICE
michael@0 51 NS_DECL_NSIOBSERVER
michael@0 52
michael@0 53 nsAnnotationService();
michael@0 54
michael@0 55 /**
michael@0 56 * Obtains the service's object.
michael@0 57 */
michael@0 58 static already_AddRefed<nsAnnotationService> GetSingleton();
michael@0 59
michael@0 60 /**
michael@0 61 * Initializes the service's object. This should only be called once.
michael@0 62 */
michael@0 63 nsresult Init();
michael@0 64
michael@0 65 /**
michael@0 66 * Returns a cached pointer to the annotation service for consumers in the
michael@0 67 * places directory.
michael@0 68 */
michael@0 69 static nsAnnotationService* GetAnnotationService()
michael@0 70 {
michael@0 71 if (!gAnnotationService) {
michael@0 72 nsCOMPtr<nsIAnnotationService> serv =
michael@0 73 do_GetService(NS_ANNOTATIONSERVICE_CONTRACTID);
michael@0 74 NS_ENSURE_TRUE(serv, nullptr);
michael@0 75 NS_ASSERTION(gAnnotationService,
michael@0 76 "Should have static instance pointer now");
michael@0 77 }
michael@0 78 return gAnnotationService;
michael@0 79 }
michael@0 80
michael@0 81 private:
michael@0 82 ~nsAnnotationService();
michael@0 83
michael@0 84 protected:
michael@0 85 nsRefPtr<mozilla::places::Database> mDB;
michael@0 86
michael@0 87 nsCOMArray<nsIAnnotationObserver> mObservers;
michael@0 88 bool mHasSessionAnnotations;
michael@0 89
michael@0 90 static nsAnnotationService* gAnnotationService;
michael@0 91
michael@0 92 static const int kAnnoIndex_ID;
michael@0 93 static const int kAnnoIndex_PageOrItem;
michael@0 94 static const int kAnnoIndex_NameID;
michael@0 95 static const int kAnnoIndex_Content;
michael@0 96 static const int kAnnoIndex_Flags;
michael@0 97 static const int kAnnoIndex_Expiration;
michael@0 98 static const int kAnnoIndex_Type;
michael@0 99 static const int kAnnoIndex_DateAdded;
michael@0 100 static const int kAnnoIndex_LastModified;
michael@0 101
michael@0 102 nsresult HasAnnotationInternal(nsIURI* aURI,
michael@0 103 int64_t aItemId,
michael@0 104 const nsACString& aName,
michael@0 105 bool* _hasAnno);
michael@0 106
michael@0 107 nsresult StartGetAnnotation(nsIURI* aURI,
michael@0 108 int64_t aItemId,
michael@0 109 const nsACString& aName,
michael@0 110 nsCOMPtr<mozIStorageStatement>& aStatement);
michael@0 111
michael@0 112 nsresult StartSetAnnotation(nsIURI* aURI,
michael@0 113 int64_t aItemId,
michael@0 114 const nsACString& aName,
michael@0 115 int32_t aFlags,
michael@0 116 uint16_t aExpiration,
michael@0 117 uint16_t aType,
michael@0 118 nsCOMPtr<mozIStorageStatement>& aStatement);
michael@0 119
michael@0 120 nsresult SetAnnotationStringInternal(nsIURI* aURI,
michael@0 121 int64_t aItemId,
michael@0 122 const nsACString& aName,
michael@0 123 const nsAString& aValue,
michael@0 124 int32_t aFlags,
michael@0 125 uint16_t aExpiration);
michael@0 126 nsresult SetAnnotationInt32Internal(nsIURI* aURI,
michael@0 127 int64_t aItemId,
michael@0 128 const nsACString& aName,
michael@0 129 int32_t aValue,
michael@0 130 int32_t aFlags,
michael@0 131 uint16_t aExpiration);
michael@0 132 nsresult SetAnnotationInt64Internal(nsIURI* aURI,
michael@0 133 int64_t aItemId,
michael@0 134 const nsACString& aName,
michael@0 135 int64_t aValue,
michael@0 136 int32_t aFlags,
michael@0 137 uint16_t aExpiration);
michael@0 138 nsresult SetAnnotationDoubleInternal(nsIURI* aURI,
michael@0 139 int64_t aItemId,
michael@0 140 const nsACString& aName,
michael@0 141 double aValue,
michael@0 142 int32_t aFlags,
michael@0 143 uint16_t aExpiration);
michael@0 144
michael@0 145 nsresult RemoveAnnotationInternal(nsIURI* aURI,
michael@0 146 int64_t aItemId,
michael@0 147 const nsACString& aName);
michael@0 148
michael@0 149 public:
michael@0 150 nsresult GetPagesWithAnnotationCOMArray(const nsACString& aName,
michael@0 151 nsCOMArray<nsIURI>* _results);
michael@0 152 nsresult GetItemsWithAnnotationTArray(const nsACString& aName,
michael@0 153 nsTArray<int64_t>* _result);
michael@0 154 nsresult GetAnnotationNamesTArray(nsIURI* aURI,
michael@0 155 int64_t aItemId,
michael@0 156 nsTArray<nsCString>* _result);
michael@0 157 };
michael@0 158
michael@0 159 #endif /* nsAnnotationService_h___ */

mercurial