Bug 43874 - Add ThreadableBlobRegistry to support calling BlobRegistry methods in main thread
Summary: Add ThreadableBlobRegistry to support calling BlobRegistry methods in main th...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Jian Li
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-11 13:33 PDT by Jian Li
Modified: 2010-08-12 15:51 PDT (History)
6 users (show)

See Also:


Attachments
Proposed Patch (24.05 KB, patch)
2010-08-11 15:16 PDT, Jian Li
levin: review-
jianli: commit-queue-
Details | Formatted Diff | Diff
Proposed Patch (26.46 KB, patch)
2010-08-12 11:56 PDT, Jian Li
levin: review+
jianli: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jian Li 2010-08-11 13:33:34 PDT
Add ThreadableBlobRegistry to support calling BlobRegistry methods in main thread. This is needed to support blobs in workers.
Comment 1 Jian Li 2010-08-11 15:16:11 PDT
Created attachment 64168 [details]
Proposed Patch
Comment 2 David Levin 2010-08-11 17:50:55 PDT
Comment on attachment 64168 [details]
Proposed Patch

Just a few things.

I think you're missing the Android build file.


> diff --git a/WebCore/dom/ScriptExecutionContext.cpp b/WebCore/dom/ScriptExecutionContext.cpp

I think there are a lot of items in here which should be guarded with if ENABLE(BLOB) (even some which don't have it from the previous checkin).



FUTURE (maybe next checkin): trackBlobURL and revokeBlobURL feel very asymetric. revoke (and ~ScriptExecutionContext) calls unregisterBlobURL but track doesn't call registerBlobURL. (It feels like one class doing the ref and another doing the deref.)

I'd recommend that at least registerBlobURL be moved into trackBlobURL and perhaps the name changed to createPublicURL. (Maybe most of the guts of Blob::createPublicURL should move into the ScriptExecutionContext function.)
 


> diff --git a/WebCore/html/Blob.cpp b/WebCore/html/Blob.cpp
>  Blob::Blob(ScriptExecutionContext*, const PassRefPtr<BlobItem>& item)
> -    : m_size(0)
> +    : m_scriptExecutionContext(0)
> +    , m_size(0)

Why isn't m_type initialized for this constructor?



> diff --git a/WebCore/html/BlobRegistryImpl.cpp b/WebCore/html/BlobRegistryImpl.cpp
 >  void BlobRegistryImpl::registerBlobURL(const KURL& url, PassOwnPtr<BlobData> blobData)
>  {
> +    ASSERT(isMainThread());

I like the assert. Can this assert be added to instance() (even if it needs to move into the cpp file)?


> diff --git a/WebCore/html/ThreadableBlobRegistry.cpp b/WebCore/html/ThreadableBlobRegistry.cpp

> +void postTaskToMainThread(ScriptExecutionContext*, PassOwnPtr<ScriptExecutionContext::Task>);
> +void registerBlobURLTask(ScriptExecutionContext*, const KURL&, PassOwnPtr<BlobData>);
> +void registerBlobURLFromTask(ScriptExecutionContext*, const KURL& url, const KURL& srcURL);
> +void unregisterBlobURLTask(ScriptExecutionContext*, const KURL&);

I think these prototypes should be removed, and the functions declared as "static" instead.



> diff --git a/WebCore/html/ThreadableBlobRegistry.h b/WebCore/html/ThreadableBlobRegistry.h
> +public:
> +    static void registerBlobURL(ScriptExecutionContext*, const KURL&, PassOwnPtr<BlobData>);
> +    static void registerBlobURL(ScriptExecutionContext*, const KURL& url, const KURL& srcURL);

|url| param name.
Comment 3 Jian Li 2010-08-12 11:56:18 PDT
Created attachment 64246 [details]
Proposed Patch
Comment 4 Jian Li 2010-08-12 12:00:36 PDT
All fixed except commented ones.

(In reply to comment #2)
> (From update of attachment 64168 [details])
> Just a few things.
> 
> I think you're missing the Android build file.
> 
> 
> > diff --git a/WebCore/dom/ScriptExecutionContext.cpp b/WebCore/dom/ScriptExecutionContext.cpp
> 
> I think there are a lot of items in here which should be guarded with if ENABLE(BLOB) (even some which don't have it from the previous checkin).
> 
I am trying to figure out the boundary of using guards or not in order to be compatible with the existing file feature. I will fix this in my next checkin altogether.
> 
> 
> FUTURE (maybe next checkin): trackBlobURL and revokeBlobURL feel very asymetric. revoke (and ~ScriptExecutionContext) calls unregisterBlobURL but track doesn't call registerBlobURL. (It feels like one class doing the ref and another doing the deref.)
> 
> I'd recommend that at least registerBlobURL be moved into trackBlobURL and perhaps the name changed to createPublicURL. (Maybe most of the guts of Blob::createPublicURL should move into the ScriptExecutionContext function.)
> 
I fixed this in this patch since your suggestion really makes thing much clear.
> 
> 
> > diff --git a/WebCore/html/Blob.cpp b/WebCore/html/Blob.cpp
> >  Blob::Blob(ScriptExecutionContext*, const PassRefPtr<BlobItem>& item)
> > -    : m_size(0)
> > +    : m_scriptExecutionContext(0)
> > +    , m_size(0)
> 
> Why isn't m_type initialized for this constructor?
> 
This is legacy constructor that is going to be removed when we switch to new BlobData structure. The type string is simply empty for this constructor.
Comment 5 WebKit Review Bot 2010-08-12 15:24:40 PDT
http://trac.webkit.org/changeset/65271 might have broken Qt Linux Release minimal
Comment 6 Jian Li 2010-08-12 15:51:57 PDT
Committed as http://trac.webkit.org/changeset/65271.