Closed Bug 872800 Opened 11 years ago Closed 11 years ago

DeviceStorage incorrectly reports volume status changes on composite devices

Categories

(Core :: DOM: Device Interfaces, defect)

19 Branch
ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24
blocking-b2g leo+
Tracking Status
firefox22 --- wontfix
firefox23 --- wontfix
firefox24 --- fixed
b2g18 --- fixed
b2g18-v1.0.0 --- wontfix
b2g18-v1.0.1 --- wontfix

People

(Reporter: dhylands, Assigned: dhylands)

References

Details

(Whiteboard: [fixed-in-birch])

Attachments

(2 files, 2 obsolete files)

When you call addEventListener on a composite device, you'd get available/unavailable/shared notifications for the underlying non-composite storage areas rather then getting the composite status that you'd get by using the available() method. Nominating as leo? since this should have been part of bug 858416 (which is leo+)
Blocking required 1.1 feature.
blocking-b2g: leo? → leo+
This patch applies cleanly to both trunk and b2g18
This patch is rebased to apply on master.
This patch is rebased to apply on mozilla-b2g18.
Patch for the master branch (mozilla-b2g18 will need a branch specific patch)
Attachment #750154 - Attachment is obsolete: true
Attachment #750156 - Attachment is obsolete: true
Attachment #750152 - Flags: review?(mchen)
Comment on attachment 750170 [details] [diff] [review] Pt 2 - master - Fix volume availability notifications for composite storage areas. Review of attachment 750170 [details] [diff] [review]: ----------------------------------------------------------------- Hey Marco, Do you want to review this? And perhaps test it out to see if it fixes the problem in bug 862784. The way this is coded, if you have a listener on a composite device, then the change message should have e.path == '' and e.reason will be the composite status (i.e. available if any volume is available, etc as per DeviceStorageFile::GetStatus). For non-composite storage areas, then e.path will contain the volume name, and the e.reason should reflect the availabily of that particular volume.
Attachment #750170 - Flags: review?(mchen)
Hi Dave, Yes, I can do it on today or tomorrow morning.
Comment on attachment 750170 [details] [diff] [review] Pt 2 - master - Fix volume availability notifications for composite storage areas. Review of attachment 750170 [details] [diff] [review]: ----------------------------------------------------------------- Hi Dave, It looks great. I also tested it on Leo device and it works. About the review comments. There are few for asking the comment for easy to understanding. And only one about user cache is what I have a question there. Please help to clarify that then the rest is good to me. Thanks. ::: dom/devicestorage/DeviceStorage.h @@ +203,3 @@ > > bool IsComposite() { return mStores.Length() > 0; } > + bool IsCompositeComponent() { return mCompositeComponent; } Maybe to add comment for what is difference between IsCompostie & IsCompositeCompoent will be good for other people to understand well. That caused me sometime to get it's function. ::: dom/devicestorage/nsDeviceStorage.cpp @@ +3121,5 @@ > } > > #ifdef MOZ_WIDGET_GONK > else if (!strcmp(aTopic, NS_VOLUME_STATE_CHANGED)) { > + // We only invalidate the used space cache for the volume that actually changed state. This seems to be not related to this bug. Right? By the way, this comment seems to indicate that here should do some check about real state change but I don't see related code section here. May I loss something? @@ +3135,5 @@ > usedSpaceCache->Invalidate(volName); > > + // But if we're a composite storage area, we want to report a composite availability, > + // so we use mStorageName here instead of volName. > + DeviceStorageFile dsf(mStorageType, mStorageName); Could you add a comment into declare of mStorageType for showing that the empty string means it is a composite device? That will be easy for understanding by others.
(In reply to Marco Chen [:mchen] from comment #8) > Comment on attachment 750170 [details] [diff] [review] > Pt 2 - master - Fix volume availability notifications for composite storage > areas. > > Review of attachment 750170 [details] [diff] [review]: > ----------------------------------------------------------------- > > Hi Dave, > > It looks great. > I also tested it on Leo device and it works. > > About the review comments. There are few for asking the comment for easy to > understanding. > And only one about user cache is what I have a question there. > Please help to clarify that then the rest is good to me. Thanks. > > ::: dom/devicestorage/DeviceStorage.h > @@ +203,3 @@ > > > > bool IsComposite() { return mStores.Length() > 0; } > > + bool IsCompositeComponent() { return mCompositeComponent; } > > Maybe to add comment for what is difference between IsCompostie & > IsCompositeCompoent will be good for other people to understand well. That > caused me sometime to get it's function. Sounds reasonable. A composite storage area is made up of the composite device itself (so IsComposite would return true for this device), and real storage areas (for which IsCompositeComponent would return true). For a composite device, mStorageName is empty, and there is no root directory. > ::: dom/devicestorage/nsDeviceStorage.cpp > @@ +3121,5 @@ > > } > > > > #ifdef MOZ_WIDGET_GONK > > else if (!strcmp(aTopic, NS_VOLUME_STATE_CHANGED)) { > > + // We only invalidate the used space cache for the volume that actually changed state. > > This seems to be not related to this bug. Right? Right. We calculate used space for pictures/videos/music in one pass and cache the results. If the volume status changes, or a file is modified then we need to invalidate the cache. This was being done in this function previously, so it still needed to be there. It just got shuffled around a bit. > By the way, this comment seems to indicate that here should do some check > about real state change but I don't see related code section here. May I > loss something? I don't understand your question. > @@ +3135,5 @@ > > usedSpaceCache->Invalidate(volName); > > > > + // But if we're a composite storage area, we want to report a composite availability, > > + // so we use mStorageName here instead of volName. > > + DeviceStorageFile dsf(mStorageType, mStorageName); > > Could you add a comment into declare of mStorageType for showing that the > empty string means it is a composite device? That will be easy for > understanding by others. Sure - yeah for composite storage devices, mStorageName will be the empty string.
>>> + // We only invalidate the used space cache for the volume that actually changed state. >> By the way, this comment seems to indicate that here should do some check >> about real state change but I don't see related code section here. May I >> loss something? > I don't understand your question. You comment said that cache should be invalidated when the volume state is actually changed. But I didn't see any code for checking whether the volume state is really changed or not. Ex: cache shouldn't be invalidated when state change is the same ex: sdcard::available -> sdcard::available
(In reply to Marco Chen [:mchen] from comment #10) > >>> + // We only invalidate the used space cache for the volume that actually changed state. > > >> By the way, this comment seems to indicate that here should do some check > >> about real state change but I don't see related code section here. May I > >> loss something? > > > I don't understand your question. > > You comment said that cache should be invalidated when the volume state is > actually changed. But I didn't see any code for checking whether the volume > state is really changed or not. Ex: cache shouldn't be invalidated when > state change is the same ex: sdcard::available -> sdcard::available Yeah - that's correct. we could maintain that state, but currently don't which means that the cache may get invalidated more frequently than it should. The way the volume manager works though, you get a burst of state changes all at once and then you typically don't get any more until a real state change happens. The only place that would benefit from this particular optimization (not invalidating the cache too frequently) would be if you trying to view the used space in the settings app while you were unplugging the USB cable. In any case, this would all be covered under a separate bug and isn't related to this particular bug.
Attachment #750152 - Flags: review?(mchen) → review+
Comment on attachment 750170 [details] [diff] [review] Pt 2 - master - Fix volume availability notifications for composite storage areas. Review of attachment 750170 [details] [diff] [review]: ----------------------------------------------------------------- Ok, since Dave will fire a follow up bug for my question about invalidating user cache then for this bug I am willing to give r+. By the way, please help to add the comment to what I mentioned at previous review comment. Thanks Dave's quickly support on this issue.
Attachment #750170 - Flags: review?(mchen) → review+
Whiteboard: [fixed-in-birch]
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
Needs a branch-specific patch for uplift.
Depends on: 873391
Flags: in-moztrap-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: