Remove init and shutdown from interface nsICacheService

RESOLVED FIXED in mozilla1.8alpha5

Status

()

Core
Networking
RESOLVED FIXED
13 years ago
13 years ago

People

(Reporter: timeless, Assigned: Biesinger)

Tracking

Trunk
mozilla1.8alpha5
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

13 years ago
these three questions are among the four questions that i can think of while
reading those four lines of the nsICacheService idl file.

http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/netwerk/cache/public/nsICacheService.idl&rev=1.6&mark=55,57,60,62#50

Exception ``[Exception... "Component returned failure code: 0xc1f30001
(NS_ERROR_NOT_INITIALIZED) [nsICacheService.evictEntries]" nsresult: "0xc1f30001
(NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: foo.js :: bar :: line 2032"
data: no]'' thrown from function bar() in <foo.js> line 2032.
Stopped for thrown exception.
#0: function bar() in <foo.js> line 2032
2030: try {
2031: var cacheService =
Components.classes['@mozilla.org/network/cache-service;1'].getService(nsICacheService);
2032: cacheService.evictEntries(nsICache.STORE_ON_DISK);
2033: cacheService.evictEntries(nsICache.STORE_IN_MEMORY);

One final question comes to mind:
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/netwerk/cache/public/nsICacheService.idl&rev=1.6&mark=94,96#92
What happens if i pass STORE_ON_DISK|STORE_IN_MEMORY ?
Created attachment 163374 [details] [diff] [review]
does this answer the question?
Comment on attachment 163374 [details] [diff] [review]
does this answer the question?

so this patch removes Init and Shutdown from the interface.

this does a bit of cleanup too (removes one unused function, fixes indentation
in nsCacheEntryDescriptor ctor)
Attachment #163374 - Flags: review?(darin)
> What happens if i pass STORE_ON_DISK|STORE_IN_MEMORY ?

then you are passing STORE_ON_DISK_AS_FILE... this does not do anything
currently (maybe it should?)

you probably want to pass STORE_ANYWHERE to evict both disk and memory cache
entries.
dns service and sts are harder to fix, since Shutdown is called from the IO
Service on the two; and since they must be gotten through the service manager
the io service can't just hold a pointer to the concrete class and use operator new.

taking bug. I'm assuming this bug is not about the fact that you're getting the
exception, but that it's just the init/shutdown issue.
Assignee: darin → cbiesinger
Status: UNCONFIRMED → NEW
Ever confirmed: true
Status: NEW → ASSIGNED
OS: Windows XP → All
Hardware: PC → All
Target Milestone: --- → mozilla1.8alpha5

Comment 5

13 years ago
Comment on attachment 163374 [details] [diff] [review]
does this answer the question?

if we are going to rev nsICacheService, i'd like us to do a complete overhaul,
and think seriously about exposing a frozen API for accessing mozilla's cache.

WinINET has a cache API, and it's something that people would like to have in
mozilla.

my fear is that our current cache APIs are being used already.

please be sure to announce this API change on n.p.m.netlib and .embedding,
thanks!
Attachment #163374 - Flags: review?(darin) → review+
>if we are going to rev nsICacheService, i'd like us to do a complete overhaul,
>and think seriously about exposing a frozen API for accessing mozilla's cache.

that might be a good goal eventually. (can we make cache use PRTime? :-) )
I'm not sure that explicit access to cache is much needed... for the most part,
it's transparent to necko users, isn't it? Do people want to list cache contents
and get information about entries?

> my fear is that our current cache APIs are being used already.

maybe... but I really don't think that exposing init and shutdown on this
interface is a good think. someone eventually will call init and shutdown, and
that will be bad... Fortunately, this shouldn't require any code changes, just a
recompile.

> please be sure to announce this API change on n.p.m.netlib and .embedding,

will do when I check this in.
Attachment #163374 - Flags: superreview?(bzbarsky)
Comment on attachment 163374 [details] [diff] [review]
does this answer the question?

sr=bzbarsky
Attachment #163374 - Flags: superreview?(bzbarsky) → superreview+

Comment 8

13 years ago
nice summary, timeless. Can you come up w/ something briefer?
(Reporter)

Comment 9

13 years ago
Well, i'd love to know why I got the exception, but i'm settling for knowing
that it's not my fault that i didn't call init :).
Summary: Who is supposed to initialize the cache service and when are they supposed to initialize it? who is responsible for calling shutdown? → Remove init and shutdown from interface nsICacheService
checked in; newsgroup post made.

timeless: if you feel that it is a bug that you get the exception, please file a
new bug about it.
Status: ASSIGNED → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → FIXED
(Reporter)

Updated

13 years ago
Blocks: 281021
You need to log in before you can comment on or make changes to this bug.