summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 21:48:02 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 21:48:02 +0000
commitbfa5cf8199e3b86cf15864b2390cd10ad893c212 (patch)
treecd40647800e1fe860250147658f14de7c4dba04d /chrome
parent5d383ab616e2e5ed67db60052ba95ebfeb2067ca (diff)
downloadchromium_src-bfa5cf8199e3b86cf15864b2390cd10ad893c212.zip
chromium_src-bfa5cf8199e3b86cf15864b2390cd10ad893c212.tar.gz
chromium_src-bfa5cf8199e3b86cf15864b2390cd10ad893c212.tar.bz2
Fix DCHECK() failure when about:memory used.
BUG=28358 TEST=On a debug build (on any platform), go to about:memory and make sure it doesn't fail a DCHECK(). Review URL: http://codereview.chromium.org/418022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_about_handler.cc22
-rw-r--r--chrome/browser/memory_details.h13
2 files changed, 21 insertions, 14 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index ad517f3..44fab78 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -136,11 +136,14 @@ class AboutSource : public ChromeURLDataManager::DataSource {
DISALLOW_COPY_AND_ASSIGN(AboutSource);
};
-// Handling about:memory is complicated enough to encapsulate it's
-// related methods into a single class.
+// Handling about:memory is complicated enough to encapsulate its related
+// methods into a single class. The user should create it (on the heap) and call
+// its |StartFetch()| method.
class AboutMemoryHandler : public MemoryDetails {
public:
- AboutMemoryHandler(AboutSource* source, int request_id);
+ AboutMemoryHandler(AboutSource* source, int request_id)
+ : source_(source), request_id_(request_id) {}
+
virtual void OnDetailsAvailable();
@@ -270,8 +273,11 @@ std::string AboutHistograms(const std::string& query) {
}
void AboutMemory(AboutSource* source, int request_id) {
- // The AboutMemoryHandler cleans itself up.
- new AboutMemoryHandler(source, request_id);
+ // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want the
+ // refcount to be greater than 0.
+ scoped_refptr<AboutMemoryHandler>
+ handler(new AboutMemoryHandler(source, request_id));
+ handler->StartFetch();
}
std::string AboutObjects(const std::string& query) {
@@ -663,12 +669,6 @@ void AboutSource::FinishDataRequest(const std::string& response,
// AboutMemoryHandler ----------------------------------------------------------
-AboutMemoryHandler::AboutMemoryHandler(AboutSource* source, int request_id)
- : source_(source),
- request_id_(request_id) {
- StartFetch();
-}
-
// Helper for AboutMemory to bind results from a ProcessMetrics object
// to a DictionaryValue. Fills ws_usage and comm_usage so that the objects
// can be used in caller's scope (e.g for appending to a net total).
diff --git a/chrome/browser/memory_details.h b/chrome/browser/memory_details.h
index bfee58e..21af097 100644
--- a/chrome/browser/memory_details.h
+++ b/chrome/browser/memory_details.h
@@ -64,14 +64,21 @@ class ProcessInfoSnapshot;
//
// class MyMemoryDetailConsumer : public MemoryDetails {
//
-// MyMemoryDetailConsumer() : MemoryDetails(true) {
+// MyMemoryDetailConsumer() {
+// // Anything but |StartFetch()|.
+// }
+//
+// // (Or just call |StartFetch()| explicitly if there's nothing else to
+// // do.)
+// void StartDoingStuff() {
// StartFetch(); // Starts fetching details.
+// // Etc.
// }
//
-// // Your class stuff here
+// // Your other class stuff here
//
// virtual void OnDetailsAvailable() {
-// // do work with memory info here
+// // do work with memory info here
// }
// }
class MemoryDetails : public base::RefCountedThreadSafe<MemoryDetails> {