Closed Bug 1495687 Opened 6 years ago Closed 6 years ago

Have a method in nsIQuotaManagerService to initialize temporary storage

Categories

(Core :: Storage: Quota Manager, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: tt, Assigned: tt)

References

Details

Attachments

(1 file, 5 obsolete files)

Add a new method to nsIQuotaManagerService called initTemporaryStorage() per bug 389378 comment#c24
(In reply to Tom Tung [:tt] from comment #0)
> Add a new method to nsIQuotaManagerService called initTemporaryStorage() per
> bug 389378 comment#c24
bug 1389378 comment#24
Attached patch bug1495678.patch (obsolete) — Splinter Review
Comment on attachment 9013611 [details] [diff] [review]
bug1495678.patch

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

::: dom/quota/ActorsParent.cpp
@@ +7437,5 @@
> +{
> +  AssertIsOnIOThread();
> +
> +  AUTO_PROFILER_LABEL("InitTemporaryStorageOp::DoDirectoryWork", OTHER);
> +

I would also call this:
aQuotaManager->AssertStorageIsInitialized();

::: dom/quota/test/unit/test_initTemporaryStorage.js
@@ +3,5 @@
> + * http://creativecommons.org/publicdomain/zero/1.0/
> + */
> +
> +async function testSteps()
> +{

I have to think about this test a bit.
Attachment #9013611 - Flags: feedback+
Attached patch bug1495687-v2.patch (obsolete) — Splinter Review
Addressed feedback and modifying comments in the test.

Probably need to modifying the test as well. I guess it probably needs to be verified the usage and limits are checked if it's possible or some behaviors in InitializeRepository()?
Attachment #9013611 - Attachment is obsolete: true
Comment on attachment 9013692 [details] [diff] [review]
bug1495687-v2.patch

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

::: dom/quota/ActorsParent.cpp
@@ +7440,5 @@
> +  AUTO_PROFILER_LABEL("InitTemporaryStorageOp::DoDirectoryWork", OTHER);
> +
> +  aQuotaManager->AssertStorageIsInitialized();
> +
> +  aQuotaManager->EnsureTemporaryStorageIsInitialized();

The rv should be checked:
if (NS_WARN_IF(NS_FAILED(rv))) {
  return rv;
}

::: dom/quota/test/unit/test_initTemporaryStorage.js
@@ +5,5 @@
> +
> +async function testSteps()
> +{
> +  const principal = getPrincipal("https://foo.example.com");
> +  const metadataDir = "storage/default/https+++foo.example.com/.metadata-v2";

What about this:
const originDirPath = "storage/default/https+++foo.example.com";
const metadataFileName = ".metadata-v2";

then after the clearing, just create the origin directory:
let originDir = getRelativeFile(originPath);
originDir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0755", 8));

now call initTemporaryStorage() and check the metadata:
let metadataFile = originDir.clone();
metadataFile.append(metadataFileName);
exists = metadataFile.exists();
...
(In reply to Jan Varga [:janv] from comment #5)
Thanks for the feedback!

> > +  aQuotaManager->EnsureTemporaryStorageIsInitialized();
> 
> The rv should be checked:
> if (NS_WARN_IF(NS_FAILED(rv))) {
>   return rv;
> }

Ah, I forgot that. Will do.

> ::: dom/quota/test/unit/test_initTemporaryStorage.js
> @@ +5,5 @@
> > +
> > +async function testSteps()
> > +{
> > +  const principal = getPrincipal("https://foo.example.com");
> > +  const metadataDir = "storage/default/https+++foo.example.com/.metadata-v2";
> 
> What about this:
> const originDirPath = "storage/default/https+++foo.example.com";
> const metadataFileName = ".metadata-v2";
> 
> then after the clearing, just create the origin directory:
> let originDir = getRelativeFile(originPath);
> originDir.create(Ci.nsIFile.DIRECTORY_TYPE, parseInt("0755", 8));
> 
> now call initTemporaryStorage() and check the metadata:
> let metadataFile = originDir.clone();
> metadataFile.append(metadataFileName);
> exists = metadataFile.exists();
> ...

I see. So that it's much faster (reducing IPC round-trip time) and I can remove the quirky code for creating an empty directory.
Comment on attachment 9013692 [details] [diff] [review]
bug1495687-v2.patch

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

::: dom/quota/test/unit/test_initTemporaryStorage.js
@@ +9,5 @@
> +  const metadataDir = "storage/default/https+++foo.example.com/.metadata-v2";
> +
> +  info("Clearing");
> +
> +  let request = clear();

Actually, the clearing is not needed here I think.
Attached patch bug1495687-v3.patch (obsolete) — Splinter Review
Addressed comments and revised the test
Attachment #9013692 - Attachment is obsolete: true
Attached patch bug1495687-v4.patch (obsolete) — Splinter Review
Modified comments in the test
Attachment #9014306 - Attachment is obsolete: true
Attached patch bug1495687-v4.1.patch (obsolete) — Splinter Review
Added an empty line back for the test
Attachment #9014308 - Attachment is obsolete: true
Attachment #9014309 - Flags: review?(jvarga)
Comment on attachment 9014309 [details] [diff] [review]
bug1495687-v4.1.patch

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

Nice, thanks!

::: dom/quota/test/unit/test_initTemporaryStorage.js
@@ +4,5 @@
> + */
> +
> +/**
> + * This test is mainly to verify initTemporaryStorage() does call
> + * QuotaManager::EnsureTemporaryStorageIsInitialized() which restore the

s/restore/restores

Actually, we might want to test other aspects of EnsureTemporaryStorageIsInitialized() in future, so I would rephrase this as:
This test is mainly to verify initTemporaryStorage() does call QuotaManager::EnsureTemporaryStorageIsInitialized() which does various things, for example, it restores the directory metadata if it's broken or missing.
Attachment #9014309 - Flags: review?(jvarga) → review+
Blocks: 1389380
Pushed by shes050117@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/75a2cc138641
Introduce initTemporaryStorage to nsIQuotaManagerService for testing; r=janv
https://hg.mozilla.org/mozilla-central/rev/75a2cc138641
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: