summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-05 14:14:47 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-05 14:14:47 +0000
commita7c407073771677e301f35605f0be7415388c0b3 (patch)
tree7b123b87c88d7ff61e62f3521d330e24221ac7f4
parent2c6a70dc815f7d7632fdb4e44ebca551c010e468 (diff)
downloadchromium_src-a7c407073771677e301f35605f0be7415388c0b3.zip
chromium_src-a7c407073771677e301f35605f0be7415388c0b3.tar.gz
chromium_src-a7c407073771677e301f35605f0be7415388c0b3.tar.bz2
Change from CHECK to DCHECK and attempt to handle NULL values, in preparation for M11 branch point.
Add boolean to iteration history for whether item was removed from map, to verify something I saw in 11.0.690.0 crash dumps. Remove copy of command-line as we have seen there is no correlation between command line and these crashes. BUG=71721 TEST=net_unittests Review URL: http://codereview.chromium.org/6624028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77043 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/url_request/url_request_throttler_manager.cc36
-rw-r--r--net/url_request/url_request_throttler_unittest.cc5
2 files changed, 17 insertions, 24 deletions
diff --git a/net/url_request/url_request_throttler_manager.cc b/net/url_request/url_request_throttler_manager.cc
index a780b16..330cc48 100644
--- a/net/url_request/url_request_throttler_manager.cc
+++ b/net/url_request/url_request_throttler_manager.cc
@@ -6,8 +6,6 @@
#include <list>
-// TODO(joi): Remove once crbug.com/71721 is fixed.
-#include "base/command_line.h"
#include "base/logging.h"
#include "base/string_util.h"
@@ -27,6 +25,11 @@ struct IteratorHistory {
// Not a refptr, we don't want to change behavior by keeping it alive.
net::URLRequestThrottlerEntryInterface* entry;
+
+ // Set to true if the entry gets erased. Helpful to verify that entries
+ // with 0 refcount (since we don't take a refcount above) have been
+ // erased from the map.
+ bool was_erased;
};
} // namespace
@@ -132,23 +135,6 @@ void URLRequestThrottlerManager::GarbageCollectEntriesIfNecessary() {
void URLRequestThrottlerManager::GarbageCollectEntries() {
// TODO(joi): Remove these crash report aids once crbug.com/71721
// is figured out.
-
- // Copy the current process command line, in case some labs feature
- // is in common between the crash dumps. Note that this is not equivalent
- // to the command line stored in the PEB of the minidump since it may
- // have been modified based on the about:labs preferences.
- std::string command_line_string;
-#if defined(OS_WIN)
- std::wstring wstr = CommandLine::ForCurrentProcess()->command_line_string();
- command_line_string = WideToASCII(wstr);
-#else
- command_line_string =
- CommandLine::ForCurrentProcess()->command_line_string();
-#endif
- char command_line_buffer[400] = { 0 };
- base::strlcpy(command_line_buffer, command_line_string.c_str(),
- arraysize(command_line_buffer));
-
IteratorHistory history[32] = { { 0 } };
size_t history_ix = 0;
history[history_ix++].self = this;
@@ -170,18 +156,24 @@ void URLRequestThrottlerManager::GarbageCollectEntries() {
base::strlcpy(history[history_ix].url, i->first.c_str(),
arraysize(history[history_ix].url));
history[history_ix].entry = i->second.get();
+ history[history_ix].was_erased = false;
++history_ix;
}
- // TODO(joi): Remove first i->second check once no more bug.
- if ((i->second) && (i->second)->IsEntryOutdated()) {
+ // TODO(joi): Remove first i->second check when crbug.com/71721 is fixed.
+ if (i->second == NULL || (i->second)->IsEntryOutdated()) {
url_entries_.erase(i++);
+
+ if (nulls_found > 0 && (history_ix - 1) < arraysize(history)) {
+ history[history_ix - 1].was_erased = true;
+ }
} else {
++i;
}
}
- CHECK(nulls_found == 0);
+ // TODO(joi): Make this a CHECK again after M11 branch point.
+ DCHECK(nulls_found == 0);
// In case something broke we want to make sure not to grow indefinitely.
while (url_entries_.size() > kMaximumNumberOfEntries) {
diff --git a/net/url_request/url_request_throttler_unittest.cc b/net/url_request/url_request_throttler_unittest.cc
index a281564..7d4e739 100644
--- a/net/url_request/url_request_throttler_unittest.cc
+++ b/net/url_request/url_request_throttler_unittest.cc
@@ -403,7 +403,8 @@ TEST(URLRequestThrottlerManager, StressTest) {
}
}
-#if defined(GTEST_HAS_DEATH_TEST)
+// TODO(joi): Remove the debug-only condition after M11 branch point.
+#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
TEST(URLRequestThrottlerManager, NullHandlingTest) {
MockURLRequestThrottlerManager manager;
manager.OverrideEntryForTests(GURL("http://www.foo.com/"), NULL);
@@ -411,4 +412,4 @@ TEST(URLRequestThrottlerManager, NullHandlingTest) {
manager.DoGarbageCollectEntries();
}, "");
}
-#endif // defined(GTEST_HAS_DEATH_TEST)
+#endif // defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)