Commit Graph

63 Commits

Author SHA1 Message Date
Dimi Lee
e05a4185a6 Bug 1481819 - Make Safe Browsing directory-based file copy interruptible. r=francois
A directory-based file copy without checkpoint to abort may take lots
of time to finish. This cause an issue that if firefox is shutting down
and try to close an ongoing update thread, main-thread may be blocked
for a long time.

This patch adds a wrapper for copying an entire directory, within this
wrapper, we use file-based copy and add checkpoints to let update thread
has a chance to abort.

Differential Revision: https://phabricator.services.mozilla.com/D3414

--HG--
extra : moz-landing-system : lando
2018-09-18 14:29:20 +00:00
Gurzau Raul
f4cb8a59ba Backed out changeset 6f6886c89554 (bug 1481819) for failing at url-classifier/tests/mochitest/test_classified_annotations.html 2018-09-14 21:49:04 +03:00
Dimi Lee
9117dcd8f1 Bug 1481819 - Make Safe Browsing directory-based file copy interruptible. r=francois
A directory-based file copy without checkpoint to abort may take lots
of time to finish. This cause an issue that if firefox is shutting down
and try to close an ongoing update thread, main-thread may be blocked
for a long time.

This patch adds a wrapper for copying an entire directory, within this
wrapper, we use file-based copy and add checkpoints to let update thread
has a chance to abort.

Differential Revision: https://phabricator.services.mozilla.com/D3414

--HG--
extra : moz-landing-system : lando
2018-09-14 15:33:24 +00:00
Francois Marier
00afdd238f Bug 1467581 - Do less work in Reset() if Close() has been called. r=gcp
If Reset() is interleaved with a shutdown, there's no point in
finishing up and we may as well bail early.

MozReview-Commit-ID: Lhm6NfAEgSj

--HG--
extra : rebase_source : e74cc22a36d287a59425079a9f7c4676e7351eba
2018-06-07 17:45:46 -07:00
Francois Marier
79f1e9e5a8 Bug 1467581 - Remove the use of default captures in closures. r=gcp
Explicitly specify the arguments to copy to avoid making a copy of
a dangling `this` pointer.

Convert nsUrlClassifierDBService::mClassifier to a RefPtr since
the update closure might need to continue to access its members
after it's been released by the main thread.

MozReview-Commit-ID: CPio3n9MmsK

--HG--
extra : rebase_source : d7a8b207336209ee37441f3429bc608140e404ae
2018-06-07 17:22:32 -07:00
Francois Marier
8f19e9f805 Bug 1434206 - Keep LookupCache objects in smart pointers. r=gcp
The existing mix of UniquePtr and raw pointers is confusing when
trying to figure out the exact lifetime of these objects.

MozReview-Commit-ID: Br4S7BXEFKs

--HG--
extra : rebase_source : ba35d5c2eeda0741eb4c5491a6caf03f20f3d0ce
2018-05-16 19:13:48 -07:00
Francois Marier
84e344038a Bug 1434206 - Replace a pointer with a reference. r=gcp
This will prevent our holding on to this pointer incorrectly in the
future.

MozReview-Commit-ID: H8ueIOK1qAK

--HG--
extra : rebase_source : 937e9c702c5109b6dfc1684392a1204d8a1edc49
2018-05-15 17:18:18 -07:00
Francois Marier
8b98277f9f Bug 1434206 - Make TableUpdate objects const as much as possible. r=gcp
I tried to make TableUpdateArray point to const TableUpdate objects
everywhere but there were two problems:

- HashStore::ApplyUpdate() triggers a few Merge() calls which include
  sorting the underlying TableUpdate object first.

- LookupCacheV4::ApplyUpdate() calls TableUpdateV4::NewChecksum() when the
  checksum is missing and that sets mChecksum.

MozReview-Commit-ID: LIhJcoxo7e7

--HG--
extra : rebase_source : f6ca4bf42d1ddb897a974a0b19c7185b0b6b93af
2018-05-11 16:02:37 -07:00
Francois Marier
214074e8d4 Bug 1434206 - Keep TableUpdate objects in smart pointers. r=gcp
Manually keeping tabs on the lifetime of these objects is a pain
and is the likely source of some of our crashes. I suspect we might
also be leaking memory.

This change creates an explicit copy of the main array into the
update thread to avoid using a non-thread-safe shared data
structure. This is a shallow copy. Only the pointers to the
TableUpdates are copied, which means one pointer per list (e.g. 5
in total for google4 in a new profile).

MozReview-Commit-ID: 221d6GkKt0M

--HG--
extra : rebase_source : e1b81f11bb9b41e465571a95845079f455b5868e
2018-06-01 15:48:48 -07:00
Francois Marier
30207d91aa Bug 1434206 - Add const to members and functions that can take it. r=gcp
MozReview-Commit-ID: B2aaQTttPAV

--HG--
extra : rebase_source : bbd8d9c734660a4380922ed9b76f1af1de427f3f
2018-05-16 15:26:14 -07:00
Francois Marier
deb19204a3 Bug 1434206 - Remove unused and undefined functions. r=gcp
mProtocolV2 is still used to skip the caching of misses on V4:

https://searchfox.org/mozilla-central/rev/d4b9e50875ad7e5d20f2fee6a53418315f6dfcc0/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp#1353-1357

MozReview-Commit-ID: 2cHh9JiZuHh

--HG--
extra : rebase_source : 8c571faf246da2666c6ce1e14d4a701e17d88f89
2018-05-28 14:39:32 -07:00
Thomas Nguyen
e70d76485c Bug 1394031 - Remove mCryptoHash members of nsUrlClassifierDBServiceWorker and ProtocolParser
The usage of cryptoHash consists of a complete set of Init, Update, and Finish, there's
no reason to keep it around

MozReview-Commit-ID: 7bT9IsWEM5m
2017-09-14 10:51:55 +08:00
DimiL
e4d42d14a2 Bug 1359299 - V4 caches in LookupCache need to be copied around in copy constructor. r=hchang
MozReview-Commit-ID: AjzUUmQKiPW

--HG--
extra : rebase_source : 1c30ee5aa3548dce9b861a70660b1e60410f3654
2017-06-06 14:16:57 +08:00
Ryan VanderMeulen
35b3731614 Backed out changeset c0b940487708 (bug 1359299) for causing intermittent Windows safebrowsing crashes. 2017-05-24 09:11:04 -04:00
DimiL
81b83a1f76 Bug 1359299 - Copy fullhash cache when update. r=hchang
After adopting the new thread model for safebrowsing, we will create a new
lookup cache for update so we can still check lookup cache at the same time.

Prefix set, completions will be generated when we open the new lookup cache
but it won't include cache, so we will loss cache after that.

This patch will copy cache data from old lookup cache to new lookup
cache while update.

MozReview-Commit-ID: L0WpiHOGIGm

--HG--
extra : rebase_source : ebaf249535561b87a983a3f24dacb8fbab7c096e
2017-05-23 09:19:06 +08:00
DimiL
c632a44157 Bug 1360480 - about:url-classifier: Cache information. r=francois
MozReview-Commit-ID: 4YXtb2KPgwL

--HG--
extra : rebase_source : ad9f897aa5772d6001a757e189730d427713f915
2017-05-17 10:32:33 +08:00
DimiL
0170f8b6dc Bug 1333328 - Remove mTableFreshness and gFreshnessGuarantee. r=francois
Functions and Preference related to mTableFreshness and gFreshnessGuarantee
could be removed since we will no longer require them.

MozReview-Commit-ID: IAa0UHLSQ56

--HG--
extra : rebase_source : daa959340c92cfcb751fe8d0548d30762db3783e
2017-05-04 11:13:21 +08:00
DimiL
5aef415cc6 Bug 1333328 - Refactor cache miss handling mechanism for V2. r=francois
In this patch, we will make Safebrowsing V2 caching use the same algorithm as V4.
So we remove "mMissCache" for negative caching and TableFresness check for
positive caching.

But Safebrowsing V2 doesn't contain negative/positive cache duration information in
gethash response. So we hard-code a fixed value, 15 minutes, as cache duration.
In this way, we can sync the mechanism we handle caching for V2 and V4.

An extra effort for V2 here is that we need to manually record prefixes misses
because we won't get any response for those prefixes(implemented in
nsUrlClassifierLookupCallback::CacheMisses).

--HG--
extra : rebase_source : 0fb7938464ad24a01a51493ecb1b5c0197c16123
2017-05-04 09:38:14 +08:00
Michael Layzell
8b7ba021a4 Bug 1339537 - Part 6: Pass std::function values tree by const reference instead of by value, r=ehsan
MozReview-Commit-ID: PVAqU2DPs2
2017-04-27 12:44:57 -04:00
Thomas Nguyen
ae9e3b7638 Bug 1353853 - Cache preferences when doing channel classify r=francois
We will cache all preferences which will be read during classifing channel
- Store them into static variables nsUrlClassifierDBService
- Use a singleton class to manage/update preferrences in nsChannelClassifier

MozReview-Commit-ID: GvyBI3rVpYh

--HG--
extra : rebase_source : 0cec0724bd47f55c7b1666e700d172698a708efb
2017-04-18 17:00:27 +08:00
Henry Chang
a1d114de50 Bug 1354968 - Avoid concurrent access of mTableRefreshness. r=francois
mTableRefreshness, a non-thread-safe object, might be accessed on worker thread
and update thread cocurrently. To solve this issue, on update thread we only
insert data to mNewTableRefreshness and merge to mTableRefreshness on
the worker thread later.

MozReview-Commit-ID: 9WgoeYfWVfK

--HG--
extra : rebase_source : b7a8b4cd9d0fb1471cb81ee239f8343ff9a7b38a
2017-04-11 01:02:42 +08:00
DimiL
b4f6db923f Bug 1311935 - P1. Make ActiveTables() work for safebrowsing v4. r=francois
This patch fixes that Classifier::ActiveTables doesn't return v4 tables.

Classifier::mActiveTablesCache is generated by scanning safebrowsing directory.
We use Classifier::ScanStoreDir to do the work, but it will ignore subdirectory.
Since v4 tables are stored in subdirectory 'google4', mActiveTablesCache doesn't
include v4 tables.

Fix this issue by checking subdirectory recursively in ScanStoreDir.

MozReview-Commit-ID: I6pa6e4bFND

--HG--
extra : rebase_source : 49d19101bec780e21db668b2daff3c46bbdb3fd2
2017-04-07 14:30:11 +08:00
Iris Hsiao
3d85c0330d Backed out 4 changesets (bug 1311935) for causing assertion crash by developer's request
Backed out changeset 27e624cd9479 (bug 1311935)
Backed out changeset 4c0381ab0990 (bug 1311935)
Backed out changeset 73587838ef16 (bug 1311935)
Backed out changeset a5a6c0f79733 (bug 1311935)
2017-04-11 11:04:54 +08:00
DimiL
516a287f2b Bug 1311935 - P1. Make ActiveTables() work for safebrowsing v4. r=francois
This patch fixes that Classifier::ActiveTables doesn't return v4 tables.

Classifier::mActiveTablesCache is generated by scanning safebrowsing directory.
We use Classifier::ScanStoreDir to do the work, but it will ignore subdirectory.
Since v4 tables are stored in subdirectory 'google4', mActiveTablesCache doesn't
include v4 tables.

Fix this issue by checking subdirectory recursively in ScanStoreDir.

MozReview-Commit-ID: I6pa6e4bFND

--HG--
extra : rebase_source : 49d19101bec780e21db668b2daff3c46bbdb3fd2
2017-04-07 14:30:11 +08:00
Henry Chang
f3be63826d Bug 1339050 - Asynchronously apply safebrowsing DB update. r=francois,gcp
A new function Classifier::AsyncApplyUpdates() is implemented for async update.
Besides, all public Classifier interfaces become "worker thread only" and
we remove DBServiceWorker::ApplyUpdatesBackground/Foreground.

In DBServiceWorker::FinishUpdate, instead of calling Classifier::ApplyUpdates,
we call Classifier::AsyncApplyUpdates and install a callback for notifying
the update observer when update is finished. The callback will occur on the
caller thread (i.e. worker thread.)

As for the shutdown issue, when the main thread is notified to shut down,
we at first *synchronously* dispatch an event to the worker thread to
shut down the update thread. After getting synchronized with all other
threads, we send last two events "CancelUpdate" and "CloseDb" to notify
dangling update (i.e. BeginUpdate is called but FinishUpdate isn't)
and do cleanup work.

MozReview-Commit-ID: DXZvA2eFKlc

--HG--
extra : rebase_source : cd2e27a6b679d2c96e769854d1582ed2dcda12bb
2017-04-06 07:07:56 +08:00
Henry Chang
0b68cc7689 Bug 1339760 - Split update process to background/foreground and run background on update thread **synchronously**. r=francois,gcp
MozReview-Commit-ID: J0phPC1nWsf

--HG--
extra : rebase_source : c212bd9fba1ef5951d238967a9b32e4fde0d718b
extra : source : 3daedf653e989c2d91deea785ed9598f2254e609
2017-02-22 17:25:26 +08:00
Henry Chang
6b96dcfdab Bug 1342397 - Properly reset stuff when failing to create LookupCache for update. r=gcp
MozReview-Commit-ID: 1ecI2lFIj2U

--HG--
extra : rebase_source : 49c5e460a1178253ce2afc1cdfd71dd66e370284
2017-02-25 00:22:39 +08:00
Thomas Nguyen
3f7a3e400f Bug 1297962 - Add noise data when sending v4 gethash request r=francois
MozReview-Commit-ID: GbyvX7wcg8c
* * *
[mq]: 1297962_review

MozReview-Commit-ID: 1U2T0wq778R

--HG--
extra : rebase_source : 55f852204aa29b135360e461b8c152e45fecc7b6
2017-02-24 10:22:12 +08:00
Henry Chang
2b62e1dabf Bug 1338970 - Introduce 2-step DB update scheme. (background update then swap in) r=francois,gcp
MozReview-Commit-ID: 4C9N0tuSso0

--HG--
extra : rebase_source : 80561fb0beec7fc9f6e852d81984b239ae62700e
2017-02-21 14:18:29 +08:00
dimi
4f2ec370e6 Bug 1328821 - hash completion request for v4 should not depend on table freshness. r=francois,henry
MozReview-Commit-ID: EIjDrnj1I4S

--HG--
extra : rebase_source : 83be77637f14753a8baf008af65c44e83b93508c
2017-01-17 08:33:08 +08:00
Henry Chang
a5327a4bbb Bug 1319286 - Cache nsIUrlClassifierDBService.getTables result until next update. r=francois.
MozReview-Commit-ID: ItjTQNzCVED
2016-11-22 10:39:58 +08:00
Henry Chang
1a53231595 Bug 1315097 - Build the provider dictionary on the main thread to be used everywhere. r=francois,gcp
MozReview-Commit-ID: Ft1deSNKuVB

--HG--
extra : rebase_source : 0cf746b1d2def35606f012c994ddbda0857ccf2d
2016-11-04 17:54:05 +08:00
Henry Chang
6cde2e6e52 Bug 1310142 - Preserve backup databases and raw table updates for diagnostic. r=francois
MozReview-Commit-ID: GeJoBrhuTgA

--HG--
extra : rebase_source : 02585bca9853a00bc041874a999b39e6fd7246ea
2016-10-14 17:58:18 +08:00
DimiL
48ddedb04e Bug 1305780 - P1. Implement the update fail scheme for v4. r=gcp
MozReview-Commit-ID: LeVpVIUdmjc

--HG--
extra : rebase_source : bfc189b5a3f1cfc17bd269bcb7e7edad826769a3
2016-10-19 12:52:05 +08:00
Henry Chang
dc3bbda5bd Bug 1305484 - Save/load state and checksum to/from disk rather than prefs. r=dimi,francois
MozReview-Commit-ID: 4gmmrI9wY4c

--HG--
extra : rebase_source : f7f4462b7325bce9a92f747c54b448e2693e40ac
2016-10-13 15:22:08 +08:00
Dimi Lee
3ef7d52f53 Bug 1305801 - Part 4: Store variable-length prefix to disk. r=francois, r=gcp
MozReview-Commit-ID: BMTGtgMuQdg

--HG--
extra : rebase_source : dc4975d9ac8d14ecfabf6fc1229fdb8e863cde46
2016-09-19 11:51:01 +08:00
Phil Ringnalda
35869db574 Backed out 5 changesets (bug 1305801) for ASan gtest bustage
Backed out changeset 0c95d5dec6d9 (bug 1305801)
Backed out changeset bca0e706dbc5 (bug 1305801)
Backed out changeset def8da367beb (bug 1305801)
Backed out changeset 56ceae52d847 (bug 1305801)
Backed out changeset 14457cc4c325 (bug 1305801)
2016-10-03 22:14:49 -07:00
Dimi Lee
f0aab4a2ce Bug 1305801 - Part 4: Store variable-length prefix to disk. r=francois, r=gcp
MozReview-Commit-ID: BMTGtgMuQdg

--HG--
extra : rebase_source : 6f613883071de209f53596060b637e928f458978
2016-09-19 11:51:01 +08:00
Henry Chang
6e64c9ee89 Bug 1254763 - Part 1: Use per-provider directory for V4 databases. r=dimi,gcp
MozReview-Commit-ID: KZGWIcKAQyW

--HG--
extra : rebase_source : f153e87ce132f0066d6c8e21398e7abaaaff6375
2016-09-02 12:00:00 +08:00
dimi
2fa583dc0b Bug 1037560 - P1. Safebrowsing pleasereset resets all tables. r=gcp
MozReview-Commit-ID: C5GkBBDAhn3

--HG--
extra : rebase_source : d51e94749549db975651e4bc2e4bde2f38b1a9d0
2016-08-23 08:24:07 +08:00
dimi
365c242c26 Bug 1254766 - Stop caching Safe Browsing completions to disk. r=gcp
MozReview-Commit-ID: 8Qnc8yymgDL
2016-08-11 08:17:39 +08:00
dimi
0faebe8b52 Bug 1287024 - Remove unused mHashStores variable in Classifier.cpp. r=francois
MozReview-Commit-ID: 2EIDaRHKW8Q

--HG--
extra : rebase_source : e1a4a8c578ec8e5c2f5869cbd775bfbba0c977bf
2016-07-15 12:16:26 +08:00
Gian-Carlo Pascutto
31cf95e1cd Bug 1175562 - Persist last update time for SafeBrowsing. r=francois 2015-10-06 13:53:07 +02:00
Birunthan Mohanathas
a8939590de Bug 1182996 - Fix and add missing namespace comments. rs=ehsan
The bulk of this commit was generated by running:

  run-clang-tidy.py \
    -checks='-*,llvm-namespace-comment' \
    -header-filter=^/.../mozilla-central/.* \
    -fix
2015-07-13 08:25:42 -07:00
Monica Chew
c283b146cd Bug 1120499: Proxy DoLocalLookup to the worker thread (r=gcp) 2015-01-13 17:09:13 -08:00
Monica Chew
55a8118ad1 Bug 1108009 - Make synchronous interface nsIURIClassifier.ClassifyLocal. r=gcp 2014-12-18 10:18:09 -08:00
Monica Chew
9b092b1051 Bug 985623: Force url classifier clients to specify which tables to lookup, add a pref to skip hash completion checks (r=gcp) 2014-03-20 14:25:35 -07:00
Gian-Carlo Pascutto
0da033e962 Bug 825891 - Remove the code for per-client randomization in the url-classifier. r=dcamp 2013-01-08 16:43:33 +01:00
Daniel Holbert
5f7e7fca0d Bug 825627, part 1: Make nsUrlClassifierDBService.cpp's "gethashNoise" & "aCount" variables as unsigned, since counts are unsigned by definition. r=gcp 2013-01-02 09:05:19 -08:00
Saurabh Anand
6de7befa37 Bug 818817 - Fix some compiler warnings, r=Ms2ger 2012-12-09 22:53:19 +05:30