Closed Bug 1332568 Opened 7 years ago Closed 3 years ago

Make nsContentTypeParser use nsMIMEHeaderParamImpl::DoGetParameter directly

Categories

(Core :: Networking, defect, P5)

49 Branch
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: mozbugz, Assigned: mozbugz)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-would-take])

Attachments

(3 files, 3 obsolete files)

Currently nsContentTypeParser uses the nsIMIMEHeaderParam/"@mozilla.org/network/mime-hdrparam;1" service, meaning it can only be called on the main thread.
To make nsContentTypeParser thread-safe, it could use the (one and only) implementation directly, which is nsMIMEHeaderParamImpl.

(Is this controversial?)

My main reason for this is that I'd like to use the parser in other threads, e.g. when reading metadata asynchronously and extracting a MIME type.

It would also probably save a few cycles, as it won't have to fetch (and possibly create) the service every time it is needed.
sgtm. thanks
Whiteboard: [necko-would-take]
Thank you for volunteering to review. :-)
(But please feel free to forward to someone else, as appropriate...)
Attachment #8829327 - Flags: review?(mcmanus) → review?(honzab.moz)
Attachment #8829326 - Flags: review?(mcmanus) → review?(honzab.moz)
Attachment #8829325 - Flags: review?(mcmanus) → review?(honzab.moz)
Please fix the patches in rb or please reupload as normal patches so I can review them in splitner.  thanks.
Flags: needinfo?(gsquelart)
Attachment #8829325 - Flags: review?(mcmanus)
Attachment #8829326 - Flags: review?(mcmanus)
Attachment #8829327 - Flags: review?(mcmanus)
p1. Expose nsMIMEHeaderParamImpl.h and make DoGetParameter static and public
Attachment #8829325 - Attachment is obsolete: true
Attachment #8831823 - Flags: review?(honzab.moz)
p2. Make nsContentTypeParser use nsMIMEHeaderParamImpl::DoGetParameter
Attachment #8829326 - Attachment is obsolete: true
Attachment #8831824 - Flags: review?(honzab.moz)
p3. MediaMIMETypes can use thread-safe nsContentTypeParser
Attachment #8829327 - Attachment is obsolete: true
Flags: needinfo?(gsquelart)
Attachment #8831825 - Flags: review?(honzab.moz)
Comment on attachment 8831823 [details] [diff] [review]
p1. Expose nsMIMEHeaderParamImpl.h and make DoGetParameter static and public

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

::: netwerk/mime/nsMIMEHeaderParamImpl.h
@@ +19,5 @@
>      MIME_FIELD_ENCODING = 1,
>      HTTP_FIELD_ENCODING
> +  };
> +  static
> +  nsresult DoGetParameter(const nsACString& aHeaderVal,

in the cpp file, please mark these two methods with 

// static 

comment, and please double check that none of them (including the callees) writes to any global memory
Attachment #8831823 - Flags: review?(honzab.moz) → review+
Comment on attachment 8831824 [details] [diff] [review]
p2. Make nsContentTypeParser use nsMIMEHeaderParamImpl::DoGetParameter

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

::: dom/base/nsContentUtils.cpp
@@ +6134,5 @@
>  
>    return NS_SUCCEEDED(aPrincipal->CheckMayLoad(channelURI, false, aAllowIfInheritsPrincipal));
>  }
>  
>  nsContentTypeParser::nsContentTypeParser(const nsAString& aString)

please make sure that this class is not accessing any globals so it can be safely used on more than one thread.
Attachment #8831824 - Flags: review?(honzab.moz) → review+
Attachment #8831825 - Flags: review?(honzab.moz) → review+
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P5

Abandonning this old bug I haven't touched for years! I don't think it's worth keeping around, patches are probably very bit-rotten, and if there was a need for this, someone else could probably do it better than me now, and open a bug for their own work.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: