Bug 34686

Summary: [Haiku] Improve MIME type data base implementation on Haiku
Product: WebKit Reporter: Stephan Aßmus <superstippi>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, leavengood, simon.maxime
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: Other   
Attachments:
Description Flags
Patch makes MIMETypeRegistry fall back to use system data base on Haiku
eric: review-
[Haiku] Fall back to the system MIME database, return correct string for unknown types.
levin: review-
[Haiku] Fall back to the system MIME database, return correct string for unknown types. none

Description Stephan Aßmus 2010-02-06 14:42:05 PST
Patch implements using the Haiku MIME type data base as a fall back for unknown file extensions. The hard-coded MIME types have been sorted to resolve more frequenly used extensions quicker.
Comment 1 Stephan Aßmus 2010-02-06 14:44:47 PST
Created attachment 48299 [details]
Patch makes MIMETypeRegistry fall back to use system data base on Haiku

Patch against r54275.
Comment 2 Eric Seidel (no email) 2010-02-10 13:33:13 PST
Comment on attachment 48299 [details]
Patch makes MIMETypeRegistry fall back to use system data base on Haiku

The mime type lines used to be sorted alphabetically.  Why change that?  There is no performance benefit to your change.  The CPU on my cellphone can execute a billion comparisons a second, so shortening the array walk by a few places is no perf savings. :)
Comment 3 Ryan Leavengood 2010-02-14 10:59:39 PST
Hi Eric,

Would you accept this patch if the ordering/optimization of the list was changed back to how it was? Though I think you are being pretty strict here. Don't ports get some leeway in defining how their platform code works?

Either way I think falling back to the Haiku MIME database is a very valid platform-specific feature we should make use of in our port. So I would hope you would accept a patch with those changes at least.
Comment 4 Stephan Aßmus 2010-04-11 14:35:04 PDT
Created attachment 53112 [details]
[Haiku] Fall back to the system MIME database, return correct string for unknown types.

Revised patch, also fixes string returned for unknown types, which other code relies on.
Comment 5 David Levin 2010-04-12 23:27:54 PDT
Comment on attachment 53112 [details]
[Haiku] Fall back to the system MIME database, return correct string for unknown types.

r- for struct name change (and the fact that I can't get you to change it on landing).


>  2010-04-10  Adam Barth  <abarth@webkit.org>
>  
>          Unreviewed.  Rename m_forceSandboxFlags to m_forcedSandoxFlags, as
> Index: WebCore/platform/haiku/MIMETypeRegistryHaiku.cpp

> -static const ExtensionMap extensionMap [] = {
> +static const ExtensionMap sExtensionMap[] = {

Please don't change the name of this struct. WebKit doesn't use this style of notation for static const arrays.


> +    // Try system mime database
Please add a "."

> +    String fakeFileName("filename.");
> +    fakeFileName.append(str);
> +
> +    BMimeType type;
> +    if (BMimeType::GuessMimeType(fakeFileName.utf8().data(), &type) == B_OK)

Mild concern about passing untrusted data (derived from ext) to system api, but since it is a a null terminated string, this appears fine.
Comment 6 Stephan Aßmus 2010-04-13 02:00:00 PDT
Created attachment 53233 [details]
[Haiku] Fall back to the system MIME database, return correct string for unknown types.

Revised patch after review. Thanks! Somehow I was under the wrong impression that the style guide said this about static variables, but was obviously mistaken.
Comment 7 WebKit Commit Bot 2010-04-13 06:45:33 PDT
Comment on attachment 53233 [details]
[Haiku] Fall back to the system MIME database, return correct string for unknown types.

Clearing flags on attachment: 53233

Committed r57513: <http://trac.webkit.org/changeset/57513>
Comment 8 WebKit Commit Bot 2010-04-13 06:45:38 PDT
All reviewed patches have been landed.  Closing bug.