Commit Graph

120 Commits

Author SHA1 Message Date
Nicholas Nethercote
723f585d9c Bug 1386600 - Change nsIStringBundle methods to return |AString| instead of |wstring|. r=emk,sr=dbaron.
This removes about 2/3 of the occurrences of nsXPIDLString in the tree. The
places where nsXPIDLStrings are null-checked are replaced with |rv| checks.

The patch also removes a couple of unused declarations from
nsIStringBundle.idl.

Note that nsStringBundle::GetStringFromNameHelper() was merged into
GetStringFromName(), because they both would have had the same signature.
2017-08-04 14:40:52 +10:00
Marco Bonardo
6dd1b175e4 Bug 1275878 - Part 2: Replace places-will-close-connection notification with a shutdown blocker. r=adw
MozReview-Commit-ID: A2sn2OreX4K
2016-05-19 23:50:27 +02:00
Mayank Srivastav
1a6c437b24 Bug 1354032 - Remove Places analyze call and use PRAGMA optimize(0x02) for optimizations. r=mak
MozReview-Commit-ID: AOkh3vOKD4E
2017-05-30 19:14:39 +05:30
Sebastian Hengst
a4e3a055dc Backed out changeset 03b8979ccf32 (bug 1354032) for failing database-related mochitests, e.g. browser/components/resistfingerprinting/test/mochitest/test_geolocation.html. r=backout on a CLOSED TREE 2017-07-15 15:51:28 +02:00
Mayank Srivastav
4109f79310 Bug 1354032 - Remove Places analyze call and use PRAGMA optimize(0x02) for optimizations. r=mak
MozReview-Commit-ID: AOkh3vOKD4E
2017-05-30 19:14:39 +05:30
Nicholas Nethercote
8b5bdf0867 Bug 1380227 - Avoid many UTF16toUTF8 and UTF8toUTF16 conversions in nsStringBundle. r=emk.
Most of the names passed to nsIStringBundle::{Get,Format}StringFromUTF8Name
have one of the two following forms:

- a 16-bit C string literal, which is then converted to an 8-bit string in
  order for the lookup to occur;

- an 8-bit C string literal converted to a 16-bit string, which is then
  converted back to an 8-bit string in order for the lookup to occur.

This patch introduces and uses alternative methods that can take an 8-bit C
string literal, which requires changing some signatures in other methods and
functions. It replaces all C++ uses of the old methods.

The patch also changes the existing {Get,Format}StringFromName() methods so
they take an AUTF8String argument for the name instead of a wstring, because
that's nicer for JS code.

Even though there is a method for C++ code and a different one for JS code,
|binaryname| is used so that the existing method names can be used for the
common case in both languages.

The change reduces the number of NS_ConvertUTF8toUTF16 and
NS_ConvertUTF16toUTF8 conversions while running Speedometer v2 from ~270,000 to
~160,000. (Most of these conversions involved the string
"deprecatedReferrerDirective" in nsCSPParser.cpp.)
2017-07-12 15:13:37 +10:00
Marco Bonardo
2e63b9b6bb Bug 1371677 - Delay the database connection in the history service as far as possible. r=adw
Makes initing Places services cheaper, by delaying the connection creation to the first time
it's actually needed.
Same way, delays reading the bookmark roots at the first time they are requested.
Deprecates the concept of lazy observers, since they are no more needed, we can just use addObserver.
Simplifies the startup path: always sends "places-init-complete" (both as a category and a topic) when
the connection starts and adds a "locked" database state when we can't get a working connection.
Makes PlacesCategoriesStarter register for the new category, since it's cheaper than being a bookmarks
observer.
Fixes a couple race conditions in keywords and expiration due to new startup timings.
Removes a test in test_keywords.js that is no more easily feasible, since it'd requires a pre-build
places.sqlite that should be kept up-to-date at every version.

MozReview-Commit-ID: 6ccPUZ651m0
2017-06-09 18:51:09 +02:00
Marco Bonardo
e98198fc81 Bug 1356812 - Use telemetry to report unfixable corrupt Places databases. r=bsmedberg,past
MozReview-Commit-ID: EZKfMlnCKCf
2017-06-23 18:15:46 +02:00
Nan Jiang
ccab846cc2 Bug 1352502 - Part 1. Add description and preview_image_url to Places. r=mak
MozReview-Commit-ID: 4dvVboTm4kf
2017-05-23 14:54:13 -04:00
Marco Bonardo
0dfad3037f Bug 1355561 - Add a new API to spinningly close the database when strictly needed, and ensure Close() does what it's named after. r=asuth
Introduce a new SpinningSynchronousClose API that allows to synchronously close
a connection that executed asynchronous statements, by spinning the events loop.
This is expected to be used rarely in particular cases like database corruption.
It is currently [noscript] since the only consumer is cpp, in the future we can
evaluate removing that, if we find more uses for it.

MozReview-Commit-ID: 7SPqutoF9jJ
2017-04-12 17:44:39 +02:00
Milan Sreckovic
1b0959ac1f Bug 789945: Part 4. Explicitly make some pref save be blocking calls. r=bsmedberg
MozReview-Commit-ID: 1MEp7o65HAV
2017-06-14 13:38:17 -04:00
Marco Bonardo
c0a2287ba5 Bug 1361322 - Don't try to open the favicons database on startup for existing profiles. r=adw
Instead of opening and closing the favicons database at every startup to check whether
it's corrupt, just use the ATTACH DATABASE query result to achieve that.
Also avoid replacing places.sqlite in case of non-fatal errors during the connection
initialization.

MozReview-Commit-ID: 4VW3dtoSH07
2017-05-24 15:19:39 +02:00
Nathan Froyd
3b526b2200 Bug 1359490 - add an event loop spinning abstraction function; r=gerald
This function is arguably nicer than calling NS_ProcessNextEvent
manually, is slightly more efficient, and will enable better auditing
for NS_ProcessNextEvent when we do Quantum DOM scheduling changes.
2017-05-15 09:34:19 -04:00
Marco Bonardo
6b33830513 Bug 1359887 - Potential deadlock when forcing wal checkpoints on Places startup. r=past
Don't enforce wal checkpoints during Places startup, since that can possibly cause a deadlock that would
make some early synchronous API calls bailout. That would indeed cause unexpected intermittent failures
in tests.
Regardless, forcing checkpoints like this in modern filesystems is unlikely to add much value, since
the probabilities to lose the whole contents of the journal are very low.
Additionally we have better startup handling of invalid databases, so we should be able to recover in any case.

MozReview-Commit-ID: G7nISZkd8s2
2017-04-29 16:49:35 +02:00
Marco Bonardo
82c4212b6f Bug 1356220 - Set a journal_size_limit on favicons.sqlite and improve the wal autocheckpoint value. r=adw
journal_size_limit doesn't apply to attached databases, so it must be set apart.
Additionally, the current journal_size_limit setting is wrong it should be bytes.
Finally, increase the wal_autocheckpoint value for performance reasons.
Sqlite by default uses a 4MiB autocheckpoint, but we use synchronous=NORMAL, that is a bit more dataloss risky.
For that reason just use half of the default value.
journal_size_limit is set higher than the autocheckpoint value, so that we won't truncate at
every checkpoint.

MozReview-Commit-ID: 2ZUy2Iwkjjc
2017-04-21 18:43:29 +02:00
Marco Bonardo
8650b05a53 Bug 1357366 - Avoid a possible crash loop in Places Database corruption handling. r=past
MozReview-Commit-ID: BIN3ji68nAY
2017-04-18 14:02:43 +02:00
Marco Bonardo
5799c4aefd Bug 1355414 - places.sqlite schema migration fails if an application has never used the bookmarks service. r=past
MozReview-Commit-ID: 13YXf2On75J
2017-04-11 16:04:23 +02:00
Marco Bonardo
fbfba8faf2 Bug 977177 - Move favicons to a separate store. r=adw
This patch moves favicons blobs to a separate database names favicons.sqlite.
The dabatase is then ATTACHED to the main Places connection, so that its tables
can be used as if they were all part of the same database.
The favicons.database contains 3 tables:
  1. moz_pages_w_icons
     This is the way to join with moz_places, through page_url_hash and page_url.
     We are not using the place id to avoid possible mismatches between places.sqlite
     and favicons.sqlite. This way the database is "portable" and reusable even
     if places.sqlite changes.
  2. moz_icons
     Contains icons payloads, each payload can either be an SVG or a PNG. These
     are the only stored formats, any other format is rescaled and converted to
     PNG. ICO files are split into single frames and stored as multiple PNGs.
     SVG are distinguishable through width == UINT16_MAX
     In future the table will also contain mask-icon color for SVG and average
     color for PNGs.
     The fixed_icon_url_hash is "fixed" to allow quickly fetch root icons, that
     means icons like "domain/favicon.ico" that can also be reused for any page
     under that domain.
  3. moz_icons_to_pages
     This is the relation table between icons and pages.
     Each page can have multiple icons, each icon can be used by multiple pages.
     There is a FOREIGN_KEY constraint between this (child) table and icons
     or pages (parents), so that it's not possible to insert non-existing ids
     in this table, and if an entry is removed from a parent table, the relation
     will be automatically removed from here.
     Note though that removing from the relation table won't remove from the
     parent tables.
Since the relations are now many-many, it's no more possible to simply join
places with the icons table and obtain a single icon, thus it's suggested that
consumers go through the "page-icon" protocol.
The migration process from the old favicons table is async and interruptible,
it will be restarted along with the favicons service until the temp preference
places.favicons.convertPayloads is set to true.


MozReview-Commit-ID: CUCoL9smRyt
2016-11-14 16:22:46 +01:00
Ehsan Akhgari
a2d8e5bd05 Bug 1343863 - Make sure that places Database object doesn't get leaked if the profile folder doesn't exist or is locked; r=mak 2017-03-06 09:42:51 -05:00
Marco Bonardo
19183aa4a6 Bug 1342946 - Fix wrong MOZ_ASSERT(true) in places/Database.cpp. r=standard8
MozReview-Commit-ID: 1gkIRqN1yYE
2017-02-28 13:53:16 +01:00
Kit Cambridge
10499d8361 Bug 1258127 - Update the Places schema to track bookmark sync changes. r=mak,rnewman
MozReview-Commit-ID: K27JzgU4KnB
2016-11-20 08:22:02 -08:00
Kit Cambridge
1958c8a7ec Bug 1312494 - Fix up queries that point to the wrong folder in _ensureMobileQuery. r=tcsc
This patch also reports validation errors for left pane queries on the
server, and removes incorrect mobile query migration code.

MozReview-Commit-ID: FT7kAZJapqE
2016-10-24 12:06:00 -07:00
Kit Cambridge
7a889a2eee Bug 1302901 - Create a Places mobile bookmarks root. r=mak
MozReview-Commit-ID: IESvIHCM2fK
2016-09-29 13:44:08 -07:00
Marco Bonardo
3c8be8a7e0 Bug 1150678 - Changing url of a bookmark with a keyword breaks the keyword forever. r=adw
MozReview-Commit-ID: 89Od4PKpQse
2016-08-30 11:04:22 +02:00
Kan-Ru Chen
a9b19d0584 Bug 1297276 - Rename mfbt/unused.h to mfbt/Unused.h for consistency. r=froydnj
The patch is generated from following command:

  rgrep -l unused.h|xargs sed -i -e s,mozilla/unused.h,mozilla/Unused.h,

MozReview-Commit-ID: AtLcWApZfES
2016-08-24 14:47:04 +08:00
Chris Peterson
6c0f810682 Bug 1277106 - Part 2: Expand MOZ_UTF16() strings to u"" string literals. r=Waldo 2016-07-20 22:03:25 -07:00
Marco Bonardo
8c84a82cf7 Bug 889561 - Reduce the size of places.sqlite by removing the url unique index from moz_places. r=adw
MozReview-Commit-ID: 2kxaXnUYIwT
2016-06-29 14:47:36 +02:00
Carsten "Tomcat" Book
7817a7f352 Backed out changeset ceff61c9fc5a (bug 889561) for frequent testfailures on pgo in /bookmarks/test_ 2016-06-29 13:54:51 +02:00
Marco Bonardo
81cc21d652 Bug 889561 - Reduce the size of places.sqlite by removing the url unique index from moz_places. r=adw
MozReview-Commit-ID: 2kxaXnUYIwT
2016-06-20 13:22:10 +02:00
Marco Bonardo
58865a2fc2 Bug 1209027 - Reduce queries load on visits addition. r=adw
MozReview-Commit-ID: AvW7WB2LXZE
2016-05-31 15:19:16 +02:00
Gregory Szorc
c86f93dab9 Bug 1272025 - Add preference to use volatile storage with Places database; r=mak
We have data showing that the Places SQLite database can consume
gigabytes of I/O during Firefox test automation jobs. This is
because a number of tests load pages as rapdily as possible,
effectively stress testing Places and SQLite. As the SQLite
database is committed to, we incur I/O for the WAL journal
and when flushing/synchronizing commits. This can add up to a
lot of overhead, especially on spinning disks.

It is important for Places to run during many tests. But it
isn't necessarily important to run with robust I/O guarantees:
SQLite itself has tests that ensure different journal and
synchronizing modes work as advertised.

This commit introduces a preference that changes the SQLite
journal and synchronization modes to be less robust. We use
an in-memory journal so no I/O is incurred for journal writing.
We disable synchronization during commit so no expensive
file(system) flushing is performed. Because setting this
preference would be dangerous for end users, we only honor the
pref if a scary sounding environment variable is set. Hopefully
that's enough of an obstacle to prevent people from footgunning
themselves.

A preliminary Try run reveals this has the potential to shave
hundreds of megabytes of I/O from various jobs. Although this
commit stops short of changing the configuration in automation
to use the new volatile storage preference.

MozReview-Commit-ID: KCoDVzwkSbg
2016-05-11 11:00:37 -07:00
Marco Bonardo
90b42d97cf Bug 1262887 - Long URLs stored in history cause slow address bar. r=adw
MozReview-Commit-ID: 8h2nVKBe6tP
2016-04-22 11:47:31 +02:00
Katie Broida
97002f7ec6 Bug 1257599 - Rename 'Unsorted Bookmarks' into 'Other Bookmarks'. r=jaws a=kwierso
MozReview-Commit-ID: 7iMM0vg9rUo
2016-03-31 16:17:30 -07:00
Cedric Desgranges
d5c104e0cd Bug 1143712 - Remove moz_bookmarks_roots table. r=mak
MozReview-Commit-ID: JXs86bRffyo
2016-03-16 11:56:25 +01:00
Marco Bonardo
2ce7866435 Bug 1250363 - Speed up history removals through a simulated per-statement trigger. r=yoric
This aims at speeding up DELETE FROM moz_places like queries.
The primary reason of slowness is the FOR EACH ROW trigger that takes care of updating the moz_hosts table when places are removed.
Unfortunately Sqlite doesn't support FOR EACH STATEMENT triggers, that means the trigger will hit multiple times for pages in the same host.
The patch introduces an additional temp table to accumulate hosts during a delete, then a trigger takes care of updating moz_hosts only once per touched host, rather than once per removed place.

MozReview-Commit-ID: BlJRLQZoC07
2016-02-23 02:21:03 +01:00
Marco Bonardo
8876034697 Bug 1244650 - Failure to clear Forms and Search Data on exit. r=yoric
The problem is due to sanitization happening too late in the shutdown cycle.
The Sanitizer depends on Places shutdown, that recently moved to async shutdown.
That change caused shutdown to happen completely at profile-before-change, unfortunately
during that phase it's impossible to predict which services are already shutdown.
The patch restores the previous Places shutdown procedure, thus clients are notified
earlier, during profile-change-teardown.

Additional meaningful changes:
* Fixes FX_SANITIZE_TOTAL telemetry to properly count total time taken by sanitize.
* Makes each cleanup operation isolated from other errors to try cleaning up as most as possible.
* In case of multiple sanitization sub steps, each step is isolated by a try/catch, the last seen exception is reported upstream.
* Makes FX_SANITIZE_HISTORY actually measure history, not other random stuff.
* Removes TOPIC_SIMULATE_PLACES_MUST_CLOSE_1 since we can now just use profile-change-teardown for shutdown phase 1.

MozReview-Commit-ID: HroLvbi25IC
2016-02-04 13:51:34 +01:00
Aidin Gharibnavaz
bb0750ec60 Bug 1164581 - Adding an overload for NS_ProxyRelease that accepts already_AddRefed, and removing all the others. r=bobbyholley 2016-02-10 08:23:00 +01:00
Carsten "Tomcat" Book
498dd069da Backed out changeset c18e29c1b369 (bug 1164581) for cpp unit tests test failures 2016-02-08 11:17:38 +01:00
Aidin Gharibnavaz
d9bbb0c446 Bug 1164581 - Adding an overload for NS_ProxyRelease that accepts already_AddRefed, and removing all the others. r=bobbyholley 2016-02-07 10:56:00 +01:00
Chris Peterson
58c673cb52 Bug 1236324 - Annotate intentional switch fallthroughs to suppress -Wimplicit-fallthrough warnings in toolkit/components/places/. r=mak
toolkit/components/places/Database.cpp:182:5: [-Wimplicit-fallthrough] unannotated fall-through between switch labels
toolkit/components/places/nsAnnotationService.cpp:215:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
toolkit/components/places/nsAnnotationService.cpp:227:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
toolkit/components/places/nsAnnotationService.cpp:297:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
toolkit/components/places/nsAnnotationService.cpp:309:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
toolkit/components/places/nsNavHistoryResult.cpp:2420:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
toolkit/components/places/nsNavHistoryResult.cpp:2446:5 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
toolkit/components/places/nsNavHistoryResult.cpp:2878:7 [-Wimplicit-fallthrough] unannotated fall-through between switch labels
2015-11-22 13:59:54 -08:00
Nathan Froyd
4e6d8f6705 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi
2015-10-18 01:24:48 -04:00
Andrew McCreight
222ce9e7f0 Bug 1210517 - Create nsVariant directly rather than via do_CreateInstance(). r=froydnj
The goal here is to leave creation stuff mostly for JS, so we can
convert it entirely over to a non-threadsafe cycle-collected version
without breaking any existing C++ users.

I didn't do this for a remaining use in nsGlobalWindow.h to avoid
including nsVariant.h all over the place.
2015-10-07 08:17:42 -07:00
Marco Bonardo
82e7620380 Bug 1170719 - OMT crash in nsXPCWrappedJS::AddRef() due to re-creating database after shutdown. r=Yoric 2015-07-25 11:07:24 +02:00
Birunthan Mohanathas
a29151dc87 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
Dragana Damjanovic
f5e3e71a6d Bug 905127 - Part 2 - remove unnecessary nsNetUtil.h includes r=jduell 2015-07-06 07:55:00 +02:00
Phil Ringnalda
7abbd03226 Merge m-c to m-i 2015-07-03 19:15:06 -07:00
Juan Gomez
89035d527e Bug 1171931 - Refactor duplicated code using XRE_IsParent/ContentProcess. r=froydnj 2015-07-03 18:29:00 -07:00
Timur Valeev
f7fe659a3a Bug 1169753 - Remove favicons GUIDs. r=mak 2015-07-01 11:50:34 +03:00
Ryan VanderMeulen
889a1d90cd Merge inbound to m-c. a=merge 2015-05-29 09:32:46 -04:00
Timur Valeev
b0f59422a7 Bug 1127763 - Some database might be missing the favicons guid index. r=mak 2015-05-27 15:52:34 +03:00