Closed
Bug 845804
Opened 11 years ago
Closed 11 years ago
Refactor duplicated code in nsMemoryInfoDumper and nsCycleCollector.cpp
Categories
(Toolkit :: about:memory, defect)
Tracking
()
RESOLVED
FIXED
mozilla22
People
(Reporter: kats, Assigned: kats)
Details
Attachments
(1 file, 1 obsolete file)
4.61 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
The code in the OpenTempFile function in nsMemoryInfoDumper is pretty much duplicated in nsCycleCollectorLogger::CreateTempFile in nsCycleCollector.cpp and should be refactored.
Assignee | ||
Comment 1•11 years ago
|
||
This is what I imagine you meant in bug 845342 comment 1, but it seems wrong to have this random OpenTempFile floating around in no namespace. Is there a better place to move it to?
Assignee: nobody → bugmail.mozilla
Attachment #718966 -
Flags: feedback?(n.nethercote)
Comment 2•11 years ago
|
||
Comment on attachment 718966 [details] [diff] [review] Patch Review of attachment 718966 [details] [diff] [review]: ----------------------------------------------------------------- Definitely heading in the right direction, but shouldn't nsMemoryInfoDumper.cpp call OpenTempFile() somewhere? jlebar might have an opinion about the best place for OpenTempFile. It feels like it belongs in some lower-level header that can be imported by both nsMemoryInfoDumper.cpp and nsCycleCollector.cpp.
Attachment #718966 -
Flags: feedback?(n.nethercote) → feedback+
Assignee | ||
Comment 3•11 years ago
|
||
nsMemoryInfoDumper already calls OpenTempFile; I didn't modify the signature of the function so the existing calls to it don't show up in the patch. Or am I misunderstanding your question?
Assignee | ||
Comment 4•11 years ago
|
||
Comment on attachment 718966 [details] [diff] [review] Patch :jlebar, any thoughts on where I should relocate OpenTempFile to so that it can be cleanly reused across nsCycleCollector and nsMemoryInfoDumper?
Attachment #718966 -
Flags: feedback?(justin.lebar+bug)
Comment 5•11 years ago
|
||
Maybe OpenTempFile could be a static method on nsMemoryInfoDumper? I'd like that better than a global function, since that lacks any context as to why you're opening a temp file.
Updated•11 years ago
|
Attachment #718966 -
Flags: feedback?(justin.lebar+bug)
Comment 6•11 years ago
|
||
> nsMemoryInfoDumper already calls OpenTempFile; I didn't modify the signature
> of the function so the existing calls to it don't show up in the patch.
Right! Carry on :)
Assignee | ||
Comment 7•11 years ago
|
||
Made it a static method on nsMemoryInfoDumper
Attachment #718966 -
Attachment is obsolete: true
Attachment #719603 -
Flags: review?(n.nethercote)
Comment 8•11 years ago
|
||
Comment on attachment 719603 [details] [diff] [review] Patch (v2) Review of attachment 719603 [details] [diff] [review]: ----------------------------------------------------------------- r=me with the comment below addressed. ::: xpcom/base/nsCycleCollector.cpp @@ +1412,4 @@ > NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, > getter_AddRefs(logFile)); > } > + nsresult rv = nsMemoryInfoDumper::OpenTempFile(filename, Don't you need to check |logFile| before calling OpenTempFile()?
Attachment #719603 -
Flags: review?(n.nethercote) → review+
Assignee | ||
Comment 9•11 years ago
|
||
(In reply to Nicholas Nethercote [:njn] from comment #8) > > Don't you need to check |logFile| before calling OpenTempFile()? No, because OpenTempFile does the check internally. Note that we want to execute the tail end of OpenTempFile regardless of whether logFile is set or not at the call site; it's just that it if it's not set we want to do the additional work of finding the temp dir. It is a little confusing though, I can add some documentation to that effect.
Assignee | ||
Comment 10•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/1eda65741914
Comment 11•11 years ago
|
||
Backed out for xpcshell failures: https://tbpl.mozilla.org/?tree=Mozilla-Inbound&rev=1eda65741914 https://hg.mozilla.org/integration/mozilla-inbound/rev/fedd96a37a7c
Comment 12•11 years ago
|
||
Sorry for the false alarm here! :-0
Assignee | ||
Comment 13•11 years ago
|
||
No problem :) RyanVM re-landed this as https://hg.mozilla.org/integration/mozilla-inbound/rev/8392e41895df once it was determined to be free of blame for the xpcshell failures.
Comment 14•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/8392e41895df
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla22
You need to log in
before you can comment on or make changes to this bug.
Description
•