toolkit/components/url-classifier/nsIUrlClassifierDBService.idl

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 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #include "nsISupports.idl"
michael@0 6
michael@0 7 %{C++
michael@0 8 #include "Entries.h"
michael@0 9 #include "LookupCache.h"
michael@0 10 class nsUrlClassifierLookupResult;
michael@0 11 %}
michael@0 12 [ptr] native ResultArray(nsTArray<mozilla::safebrowsing::LookupResult>);
michael@0 13 [ptr] native CacheCompletionArray(nsTArray<mozilla::safebrowsing::CacheResult>);
michael@0 14 [ptr] native PrefixArray(mozilla::safebrowsing::PrefixArray);
michael@0 15
michael@0 16 interface nsIUrlClassifierHashCompleter;
michael@0 17 interface nsIPrincipal;
michael@0 18
michael@0 19 // Interface for JS function callbacks
michael@0 20 [scriptable, function, uuid(4ca27b6b-a674-4b3d-ab30-d21e2da2dffb)]
michael@0 21 interface nsIUrlClassifierCallback : nsISupports {
michael@0 22 void handleEvent(in ACString value);
michael@0 23 };
michael@0 24
michael@0 25 /**
michael@0 26 * The nsIUrlClassifierUpdateObserver interface is implemented by
michael@0 27 * clients streaming updates to the url-classifier (usually
michael@0 28 * nsUrlClassifierStreamUpdater.
michael@0 29 */
michael@0 30 [scriptable, uuid(9fa11561-5816-4e1b-bcc9-b629ca05cce6)]
michael@0 31 interface nsIUrlClassifierUpdateObserver : nsISupports {
michael@0 32 /**
michael@0 33 * The update requested a new URL whose contents should be downloaded
michael@0 34 * and sent to the classifier as a new stream.
michael@0 35 *
michael@0 36 * @param url The url that was requested.
michael@0 37 * @param table The table name that this URL's contents will be associated
michael@0 38 * with. This should be passed back to beginStream().
michael@0 39 */
michael@0 40 void updateUrlRequested(in ACString url,
michael@0 41 in ACString table);
michael@0 42
michael@0 43 /**
michael@0 44 * A stream update has completed.
michael@0 45 *
michael@0 46 * @param status The state of the update process.
michael@0 47 * @param delay The amount of time the updater should wait to fetch the
michael@0 48 * next URL in ms.
michael@0 49 */
michael@0 50 void streamFinished(in nsresult status, in unsigned long delay);
michael@0 51
michael@0 52 /* The update has encountered an error and should be cancelled */
michael@0 53 void updateError(in nsresult error);
michael@0 54
michael@0 55 /**
michael@0 56 * The update has completed successfully.
michael@0 57 *
michael@0 58 * @param requestedTimeout The number of seconds that the caller should
michael@0 59 * wait before trying to update again.
michael@0 60 **/
michael@0 61 void updateSuccess(in unsigned long requestedTimeout);
michael@0 62 };
michael@0 63
michael@0 64 /**
michael@0 65 * This is a proxy class that is instantiated and called from the JS thread.
michael@0 66 * It provides async methods for querying and updating the database. As the
michael@0 67 * methods complete, they call the callback function.
michael@0 68 */
michael@0 69 [scriptable, uuid(3f9e61e5-01bd-45d0-8dd2-f1abcd20dbb7)]
michael@0 70 interface nsIUrlClassifierDBService : nsISupports
michael@0 71 {
michael@0 72 /**
michael@0 73 * Looks up a URI in the specified tables.
michael@0 74 *
michael@0 75 * @param principal: The principal containing the URI to search.
michael@0 76 * @param c: The callback will be called with a comma-separated list
michael@0 77 * of tables to which the key belongs.
michael@0 78 */
michael@0 79 void lookup(in nsIPrincipal principal,
michael@0 80 in ACString tables,
michael@0 81 in nsIUrlClassifierCallback c);
michael@0 82
michael@0 83 /**
michael@0 84 * Lists the tables along with which chunks are available in each table.
michael@0 85 * This list is in the format of the request body:
michael@0 86 * tablename;chunkdata\n
michael@0 87 * tablename2;chunkdata2\n
michael@0 88 *
michael@0 89 * For example:
michael@0 90 * goog-phish-regexp;a:10,14,30-40s:56,67
michael@0 91 * goog-white-regexp;a:1-3,5
michael@0 92 */
michael@0 93 void getTables(in nsIUrlClassifierCallback c);
michael@0 94
michael@0 95 /**
michael@0 96 * Set the nsIUrlClassifierCompleter object for a given table. This
michael@0 97 * object will be used to request complete versions of partial
michael@0 98 * hashes.
michael@0 99 */
michael@0 100 void setHashCompleter(in ACString tableName,
michael@0 101 in nsIUrlClassifierHashCompleter completer);
michael@0 102
michael@0 103 ////////////////////////////////////////////////////////////////////////////
michael@0 104 // Incremental update methods.
michael@0 105 //
michael@0 106 // An update to the database has the following steps:
michael@0 107 //
michael@0 108 // 1) The update process is started with beginUpdate(). The client
michael@0 109 // passes an nsIUrlClassifierUpdateObserver object which will be
michael@0 110 // notified as the update is processed by the dbservice.
michael@0 111 // 2) The client sends an initial update stream to the dbservice,
michael@0 112 // using beginStream/updateStream/finishStream.
michael@0 113 // 3) While reading this initial update stream, the dbservice may
michael@0 114 // request additional streams from the client as requested by the
michael@0 115 // update stream.
michael@0 116 // 4) For each additional update stream, the client feeds the
michael@0 117 // contents to the dbservice using beginStream/updateStream/endStream.
michael@0 118 // 5) Once all streams have been processed, the client calls
michael@0 119 // finishUpdate. When the dbservice has finished processing
michael@0 120 // all streams, it will notify the observer that the update process
michael@0 121 // is complete.
michael@0 122
michael@0 123 /**
michael@0 124 * Begin an update process. Will throw NS_ERROR_NOT_AVAILABLE if there
michael@0 125 * is already an update in progress.
michael@0 126 *
michael@0 127 * @param updater The update observer tied to this update.
michael@0 128 * @param tables A comma-separated list of tables included in this update.
michael@0 129 */
michael@0 130 void beginUpdate(in nsIUrlClassifierUpdateObserver updater,
michael@0 131 in ACString tables);
michael@0 132
michael@0 133 /**
michael@0 134 * Begin a stream update. This should be called once per url being
michael@0 135 * fetched.
michael@0 136 *
michael@0 137 * @param table The table the contents of this stream will be associated
michael@0 138 * with, or empty for the initial stream.
michael@0 139 */
michael@0 140 void beginStream(in ACString table);
michael@0 141
michael@0 142 /**
michael@0 143 * Update the table incrementally.
michael@0 144 */
michael@0 145 void updateStream(in ACString updateChunk);
michael@0 146
michael@0 147 // It would be nice to have an updateFromStream method to round out the
michael@0 148 // interface, but it's tricky because of XPCOM proxies.
michael@0 149
michael@0 150 /**
michael@0 151 * Finish an individual stream update. Must be called for every
michael@0 152 * beginStream() call, before the next beginStream() or finishUpdate().
michael@0 153 *
michael@0 154 * The update observer's streamFinished will be called once the
michael@0 155 * stream has been processed.
michael@0 156 */
michael@0 157 void finishStream();
michael@0 158
michael@0 159 /**
michael@0 160 * Finish an incremental update. This will attempt to commit any
michael@0 161 * pending changes and resets the update interface.
michael@0 162 *
michael@0 163 * The update observer's updateSucceeded or updateError methods
michael@0 164 * will be called when the update has been processed.
michael@0 165 */
michael@0 166 void finishUpdate();
michael@0 167
michael@0 168 /**
michael@0 169 * Cancel an incremental update. This rolls back any pending changes.
michael@0 170 * and resets the update interface.
michael@0 171 *
michael@0 172 * The update observer's updateError method will be called when the
michael@0 173 * update has been rolled back.
michael@0 174 */
michael@0 175 void cancelUpdate();
michael@0 176
michael@0 177 /**
michael@0 178 * Reset the url-classifier database. This call will delete the existing
michael@0 179 * database, emptying all tables. Mostly intended for use in unit tests.
michael@0 180 */
michael@0 181 void resetDatabase();
michael@0 182 };
michael@0 183
michael@0 184 /**
michael@0 185 * Interface for the actual worker thread. Implementations of this need not
michael@0 186 * be thread aware and just work on the database.
michael@0 187 */
michael@0 188 [scriptable, uuid(abcd7978-c304-4a7d-a44c-33c2ed5441e7)]
michael@0 189 interface nsIUrlClassifierDBServiceWorker : nsIUrlClassifierDBService
michael@0 190 {
michael@0 191 // Provide a way to forcibly close the db connection.
michael@0 192 void closeDb();
michael@0 193
michael@0 194 [noscript]void cacheCompletions(in CacheCompletionArray completions);
michael@0 195 [noscript]void cacheMisses(in PrefixArray misses);
michael@0 196 };
michael@0 197
michael@0 198 /**
michael@0 199 * This is an internal helper interface for communication between the
michael@0 200 * main thread and the dbservice worker thread. It is called for each
michael@0 201 * lookup to provide a set of possible results, which the main thread
michael@0 202 * may need to expand using an nsIUrlClassifierCompleter.
michael@0 203 */
michael@0 204 [uuid(b903dc8f-dff1-42fe-894b-36e7a59bb801)]
michael@0 205 interface nsIUrlClassifierLookupCallback : nsISupports
michael@0 206 {
michael@0 207 /**
michael@0 208 * The lookup process is complete.
michael@0 209 *
michael@0 210 * @param results
michael@0 211 * If this parameter is null, there were no results found.
michael@0 212 * If not, it contains an array of nsUrlClassifierEntry objects
michael@0 213 * with possible matches. The callee is responsible for freeing
michael@0 214 * this array.
michael@0 215 */
michael@0 216 void lookupComplete(in ResultArray results);
michael@0 217 };

mercurial