toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

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 nsUrlClassifierStreamUpdater_h_
michael@0 7 #define nsUrlClassifierStreamUpdater_h_
michael@0 8
michael@0 9 #include <nsISupportsUtils.h>
michael@0 10
michael@0 11 #include "nsCOMPtr.h"
michael@0 12 #include "nsIObserver.h"
michael@0 13 #include "nsIUrlClassifierStreamUpdater.h"
michael@0 14 #include "nsIStreamListener.h"
michael@0 15 #include "nsNetUtil.h"
michael@0 16 #include "nsTArray.h"
michael@0 17 #include "nsITimer.h"
michael@0 18 #include "mozilla/Attributes.h"
michael@0 19
michael@0 20 // Forward declare pointers
michael@0 21 class nsIURI;
michael@0 22
michael@0 23 class nsUrlClassifierStreamUpdater MOZ_FINAL : public nsIUrlClassifierStreamUpdater,
michael@0 24 public nsIUrlClassifierUpdateObserver,
michael@0 25 public nsIStreamListener,
michael@0 26 public nsIObserver,
michael@0 27 public nsIInterfaceRequestor,
michael@0 28 public nsITimerCallback
michael@0 29 {
michael@0 30 public:
michael@0 31 nsUrlClassifierStreamUpdater();
michael@0 32
michael@0 33 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 34 NS_DECL_NSIURLCLASSIFIERSTREAMUPDATER
michael@0 35 NS_DECL_NSIURLCLASSIFIERUPDATEOBSERVER
michael@0 36 NS_DECL_NSIINTERFACEREQUESTOR
michael@0 37 NS_DECL_NSIREQUESTOBSERVER
michael@0 38 NS_DECL_NSISTREAMLISTENER
michael@0 39 NS_DECL_NSIOBSERVER
michael@0 40 NS_DECL_NSITIMERCALLBACK
michael@0 41
michael@0 42 private:
michael@0 43 // No subclassing
michael@0 44 ~nsUrlClassifierStreamUpdater() {}
michael@0 45
michael@0 46 // When the dbservice sends an UpdateComplete or UpdateFailure, we call this
michael@0 47 // to reset the stream updater.
michael@0 48 void DownloadDone();
michael@0 49
michael@0 50 // Disallow copy constructor
michael@0 51 nsUrlClassifierStreamUpdater(nsUrlClassifierStreamUpdater&);
michael@0 52
michael@0 53 nsresult AddRequestBody(const nsACString &aRequestBody);
michael@0 54
michael@0 55 // Fetches an update for a single table.
michael@0 56 nsresult FetchUpdate(nsIURI *aURI,
michael@0 57 const nsACString &aRequestBody,
michael@0 58 const nsACString &aTable);
michael@0 59 // Dumb wrapper so we don't have to create URIs.
michael@0 60 nsresult FetchUpdate(const nsACString &aURI,
michael@0 61 const nsACString &aRequestBody,
michael@0 62 const nsACString &aTable);
michael@0 63
michael@0 64 // Fetches the next table, from mPendingUpdates.
michael@0 65 nsresult FetchNext();
michael@0 66
michael@0 67 bool mIsUpdating;
michael@0 68 bool mInitialized;
michael@0 69 bool mDownloadError;
michael@0 70 bool mBeganStream;
michael@0 71 nsCOMPtr<nsIURI> mUpdateUrl;
michael@0 72 nsCString mStreamTable;
michael@0 73 nsCOMPtr<nsIChannel> mChannel;
michael@0 74 nsCOMPtr<nsIUrlClassifierDBService> mDBService;
michael@0 75 nsCOMPtr<nsITimer> mTimer;
michael@0 76
michael@0 77 struct PendingUpdate {
michael@0 78 nsCString mUrl;
michael@0 79 nsCString mTable;
michael@0 80 };
michael@0 81 nsTArray<PendingUpdate> mPendingUpdates;
michael@0 82
michael@0 83 nsCOMPtr<nsIUrlClassifierCallback> mSuccessCallback;
michael@0 84 nsCOMPtr<nsIUrlClassifierCallback> mUpdateErrorCallback;
michael@0 85 nsCOMPtr<nsIUrlClassifierCallback> mDownloadErrorCallback;
michael@0 86 };
michael@0 87
michael@0 88 #endif // nsUrlClassifierStreamUpdater_h_

mercurial