summaryrefslogtreecommitdiffstats
path: root/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h')
-rw-r--r--toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h
new file mode 100644
index 000000000..b24df61d2
--- /dev/null
+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.h
@@ -0,0 +1,103 @@
+//* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-/
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef nsUrlClassifierStreamUpdater_h_
+#define nsUrlClassifierStreamUpdater_h_
+
+#include <nsISupportsUtils.h>
+
+#include "nsCOMPtr.h"
+#include "nsIObserver.h"
+#include "nsIUrlClassifierStreamUpdater.h"
+#include "nsIStreamListener.h"
+#include "nsIChannel.h"
+#include "nsTArray.h"
+#include "nsITimer.h"
+#include "mozilla/Attributes.h"
+
+// Forward declare pointers
+class nsIURI;
+
+class nsUrlClassifierStreamUpdater final : public nsIUrlClassifierStreamUpdater,
+ public nsIUrlClassifierUpdateObserver,
+ public nsIStreamListener,
+ public nsIObserver,
+ public nsIInterfaceRequestor,
+ public nsITimerCallback
+{
+public:
+ nsUrlClassifierStreamUpdater();
+
+ NS_DECL_THREADSAFE_ISUPPORTS
+ NS_DECL_NSIURLCLASSIFIERSTREAMUPDATER
+ NS_DECL_NSIURLCLASSIFIERUPDATEOBSERVER
+ NS_DECL_NSIINTERFACEREQUESTOR
+ NS_DECL_NSIREQUESTOBSERVER
+ NS_DECL_NSISTREAMLISTENER
+ NS_DECL_NSIOBSERVER
+ NS_DECL_NSITIMERCALLBACK
+
+private:
+ // No subclassing
+ ~nsUrlClassifierStreamUpdater() {}
+
+ // When the dbservice sends an UpdateComplete or UpdateFailure, we call this
+ // to reset the stream updater.
+ void DownloadDone();
+
+ // Disallow copy constructor
+ nsUrlClassifierStreamUpdater(nsUrlClassifierStreamUpdater&);
+
+ nsresult AddRequestBody(const nsACString &aRequestBody);
+
+ // Fetches an update for a single table.
+ nsresult FetchUpdate(nsIURI *aURI,
+ const nsACString &aRequest,
+ bool aIsPostRequest,
+ const nsACString &aTable);
+ // Dumb wrapper so we don't have to create URIs.
+ nsresult FetchUpdate(const nsACString &aURI,
+ const nsACString &aRequest,
+ bool aIsPostRequest,
+ const nsACString &aTable);
+
+ // Fetches the next table, from mPendingUpdates.
+ nsresult FetchNext();
+ // Fetches the next request, from mPendingRequests
+ nsresult FetchNextRequest();
+
+
+ bool mIsUpdating;
+ bool mInitialized;
+ bool mDownloadError;
+ bool mBeganStream;
+ nsCString mStreamTable;
+ nsCOMPtr<nsIChannel> mChannel;
+ nsCOMPtr<nsIUrlClassifierDBService> mDBService;
+ nsCOMPtr<nsITimer> mTimer;
+
+ struct PendingRequest {
+ nsCString mTables;
+ nsCString mRequestPayload;
+ bool mIsPostRequest;
+ nsCString mUrl;
+ nsCOMPtr<nsIUrlClassifierCallback> mSuccessCallback;
+ nsCOMPtr<nsIUrlClassifierCallback> mUpdateErrorCallback;
+ nsCOMPtr<nsIUrlClassifierCallback> mDownloadErrorCallback;
+ };
+ nsTArray<PendingRequest> mPendingRequests;
+
+ struct PendingUpdate {
+ nsCString mUrl;
+ nsCString mTable;
+ };
+ nsTArray<PendingUpdate> mPendingUpdates;
+
+ nsCOMPtr<nsIUrlClassifierCallback> mSuccessCallback;
+ nsCOMPtr<nsIUrlClassifierCallback> mUpdateErrorCallback;
+ nsCOMPtr<nsIUrlClassifierCallback> mDownloadErrorCallback;
+};
+
+#endif // nsUrlClassifierStreamUpdater_h_