Closed Bug 910808 Opened 6 years ago Closed 6 years ago

DeviceStorage uses preferences off the main thread

Categories

(Core :: DOM: Device Interfaces, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: khuey, Assigned: dhylands)

References

Details

Attachments

(2 files)

http://hg.mozilla.org/mozilla-central/annotate/21b5af569ca2/dom/devicestorage/nsDeviceStorage.cpp#l768

Preferences can only be safely used from the main thread.  We need to get the value on the main thread and store it somewhere.
So I guess the question is who is calling this off the main thread?
Assignee: nobody → dhylands
Comment on attachment 797578 [details] [diff] [review]
Remove call to request preference.

Added asserts to the places which call GetBool
Removed call to GetBool, since it can be infered from the sDirs->temp which is calculated in InitDirs, which does run on the main thread (there is an assert at the top).
Attachment #797578 - Flags: review?(khuey)
Comment on attachment 797578 [details] [diff] [review]
Remove call to request preference.

Review of attachment 797578 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/devicestorage/nsDeviceStorage.cpp
@@ +1342,5 @@
>  void
>  nsDOMDeviceStorage::SetRootDirectoryForType(const nsAString& aStorageType,
>                                              const nsAString& aStorageName)
>  {
> +  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

MOZ_ASSERT.

@@ +2143,5 @@
>    NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(DeviceStorageRequest,
>                                             nsIContentPermissionRequest)
>  
>    NS_IMETHOD Run() {
> +    NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

MOZ_ASSERT.

@@ +3141,5 @@
>  nsDOMDeviceStorage::EnumerateInternal(const nsAString& aPath,
>                                        const EnumerationParameters& aOptions,
>                                        bool aEditable, ErrorResult& aRv)
>  {
> +  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

MOZ_ASSERT.
Attachment #797578 - Flags: review?(khuey) → review+
Looks good.  Can you land this?
Oh - thanks for the reminder. I had tried to a few times but the tree was closed.
https://hg.mozilla.org/mozilla-central/rev/667cca919303
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.