gecko-dev/toolkit/components/url-classifier/public/nsIUrlClassifierDBService.idl

118 строки
4.3 KiB
Plaintext

/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Url Classifier code
*
* The Initial Developer of the Original Code is
* Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tony Chang <tony@ponderer.org> (original author)
* Brett Wilson <brettw@gmail.com>
*
* 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
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
// Interface for JS function callbacks
[scriptable, function, uuid(4ca27b6b-a674-4b3d-ab30-d21e2da2dffb)]
interface nsIUrlClassifierCallback : nsISupports {
void handleEvent(in ACString value);
};
/**
* This is a proxy class that is instantiated and called from the JS thread.
* It provides async methods for querying and updating the database. As the
* methods complete, they call the callback function.
*/
[scriptable, uuid(10928bf5-e18d-4086-854b-6c4006f2b009)]
interface nsIUrlClassifierDBService : nsISupports
{
/**
* Looks up a key in the database.
*
* @param key: The URL to search for. This URL will be canonicalized
* by the service.
* @param c: The callback will be called with a comma-separated list
* of tables to which the key belongs.
* @param needsProxy: Should be true if the callback needs to be called
* in the main thread, false if the callback is threadsafe.
*/
void lookup(in ACString spec,
in nsIUrlClassifierCallback c,
in boolean needsProxy);
/**
* Lists the tables along with which chunks are available in each table.
* This list is in the format of the request body:
* tablename;chunkdata\n
* tablename2;chunkdata2\n
*
* For example:
* goog-phish-regexp;a:10,14,30-40s:56,67
* goog-white-regexp;a:1-3,5
*/
void getTables(in nsIUrlClassifierCallback c);
////////////////////////////////////////////////////////////////////////////
// Incremental update methods. These are named to match similar methods
// in, e.g., nsICryptoHash.
/**
* Update the table incrementally.
*/
void update(in ACString updateChunk);
// It would be nice to have an updateFromStream method to round out the
// interface, but it's tricky because of XPCOM proxies.
/**
* Finish an incremental update. Calls successCallback with the
* requested delay before the next update, or failureCallback with a
* result code.
*/
void finish(in nsIUrlClassifierCallback successCallback,
in nsIUrlClassifierCallback failureCallback);
/**
* Cancel an incremental update. This rolls back and pending changes.
* and resets the stream interface.
*/
void cancelStream();
};
/**
* Interface for the actual worker thread. Implementations of this need not
* be thread aware and just work on the database.
*/
[scriptable, uuid(1e416670-5c89-462c-8a4f-6fd628af2d10)]
interface nsIUrlClassifierDBServiceWorker : nsIUrlClassifierDBService
{
// Provide a way to forcibly close the db connection.
void closeDb();
};