Closed Bug 114439 Opened 23 years ago Closed 23 years ago

nsFileTransportService should cache the mime service.

Categories

(Core :: Networking, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla0.9.7

People

(Reporter: neeti, Assigned: neeti)

Details

Attachments

(4 files)

Currently everytime we do a nsFileIO::Open(..), we call do_GetService(NS_MIMESERVICE_CONTRACTID,..)
Comment on attachment 61106 [details] [diff] [review] patch to cache mimeservice When is the mInstance released ? If you haven't already found a way, netwerk/build/nsNetModule.cpp has a nsNeckoShutdown when it can be released.
Comment on attachment 61106 [details] [diff] [review] patch to cache mimeservice nsFileTransportService::GetInstance should return a addref'ed interface pointer.
Attachment #61106 - Flags: needs-work+
Target Milestone: --- → mozilla0.9.7
I see trouble - nsFileTransportService::GetInstance() is being called from both nsFileTransportService::Create() - the thing that creates the instance and from nsFileIO::Open() - the thing that just wants to use it. This model is an addref/release nightmare esp if GetInstance() is addreffing. Neeti and I talked and here is what Neeti is going to try: - Eliminate GetInstance() - Access and fill mInstance in Create() - Get nsFileIO::Open() to check mInstance and call Create() if it aint created already to get to the nsFileTransportService
wait a second!! nsFileTransportService should set mInstance in its constructor, and clear it in its destructor. then nsFileTransportService::GetInstance() can be inlined. then nsFileTransport should AddRef the FTS instance in its constructor and Release the FTS instance in its destructor. doing so ensures that the nsFileTransportService is alive for the entire lifetime of a nsFileTransport. the current implementation of GetInstance() is missing the fact that you can't have a nsFileTransport without the nsFileTransportService already existing. it is the FTS that creates nsFileTransport objects. so, there is no need to have the check for if (!mInstance)
Attached a new patch with Darins' comments.
One of the things the earlier patch was doing was enforce singleton-ness of nsFileTransportService, meaning, even if multiple calls to CreateInstance(..filetransportservice..) happens, only one FTS will exist. That isn't true anymore (and this is similar to the way code is now). Is that an issue ?
not an issue since everyone is expected to call do_GetService instead of do_CreateInstance. perhaps we should enforce it, but we don't here as well as in many other places :( i wouldn't object to adding code to enforce singleton-ness :)
Comment on attachment 61332 [details] [diff] [review] revised patch with Darin's suggestions >Index: src/nsFileStreams.cpp > } >- >- if (NS_FAILED(rv)) { >+ >+ if (!mimeServ || (NS_FAILED(rv))) { > // if all else fails treat it as text/html? indentation problems. >Index: src/nsFileTransportService.h >+ nsCOMPtr<nsIMIMEService> mMimeService; >+ static nsFileTransportService* mInstance; alignment! otherwise, sr=darin
Attachment #61332 - Flags: needs-work+
Comment on attachment 61332 [details] [diff] [review] revised patch with Darin's suggestions r=dp if we are absolutely sure that nsFileTransportService::mInstance is not null when hitting nsFileIO::Open().
Attachment #61332 - Flags: needs-work+ → review+
No need to reattach patch for alignment stuff. Check it in. You have r=dp and sr=darin
Comment on attachment 61370 [details] [diff] [review] fixed alignment and indentation sr=darin
Attachment #61370 - Flags: superreview+
fixed checked in. thanks everyone for the reviews.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Summary: nsFileTransportService should cache the mime service.
Could someone please write a summary line for this bug?
Summary: nsFileTransportService should cache the mime service.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: