Closed Bug 596377 Opened 14 years ago Closed 14 years ago

IndexedDB: Move usage and clearing IO off the main thread

Categories

(Core :: Storage: IndexedDB, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- betaN+

People

(Reporter: bent.mozilla, Assigned: bent.mozilla)

References

Details

Attachments

(1 file)

Attached patch Patch, v1Splinter Review
Currently clearing the databases for an origin or getting the total usage for an origin perform all IO on the main thread. Attached patch moves everything off to another thread and makes everything asynchronous without pumping the event loop.
Attachment #475239 - Flags: review?(jonas)
We want this for betaN.
blocking2.0: --- → betaN+
Comment on attachment 475239 [details] [diff] [review]
Patch, v1

All functions, classes, and class members that are declared in headerfiles needs documentation for what they do and what their arguments mean. Also what they return.

>+#define DEFAULT_THREAD_TIMEOUT_MS 30000
>+#define DEFAULT_SHUTDOWN_TIMER_MS 30000

Add comments!

>+IndexedDatabaseManager::FactoryCreate()
> {
>-  return gInstance;
>+  // Returns a raw pointer that carries an owning reference! Lame, but the
>+  // singleton factory macros force this.
>+  nsRefPtr<IndexedDatabaseManager> instance(GetOrCreate());
>+  IndexedDatabaseManager* rawInstance;
>+  instance.forget(&rawInstance);
>+  return rawInstance;
> }

return GetOrCreate().get();

>+IndexedDatabaseManager::CancelGetUsageForURI(
...
>+    if (equals) {
>+      nsCOMPtr<nsISupports> ident1(do_QueryInterface(aCallback));
>+      nsCOMPtr<nsISupports> ident2(do_QueryInterface(runnable->mCallback));
>+      if (ident1 == ident2) {
>+        runnable->Cancel();
>+        break;

Use SameCOMIdentity

>+IndexedDatabaseManager::OriginClearRunnable::OnDatabaseComplete(
>+  if (mDatabasesWaiting.IsEmpty()) {
>+    if (NS_FAILED(mThread->Dispatch(this, NS_DISPATCH_NORMAL))) {
>+      NS_WARNING("Can't dispatch to IO thread!");
>+    }
>+    mThread = nsnull;
>+  }

Add a comment stating what this section does. I.e. that we're dispatching to the thread to do the file ops.


>+NS_IMETHODIMP
>+IndexedDatabaseManager::OriginClearRunnable::Run()
>+{
>+  NS_ASSERTION(!mThread, "Should have been cleared already!");
>+
>+  if (NS_IsMainThread()) {

Nit: I'd reverse this since this since the main-thread code is run after the other code. But up to you.
Attachment #475239 - Flags: review?(jonas) → review+
http://hg.mozilla.org/mozilla-central/rev/6476d61a80d5
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b7
Component: DOM → DOM: IndexedDB
Target Milestone: mozilla2.0b7 → ---
Version: Trunk → unspecified
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: