summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 00:51:59 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 00:51:59 +0000
commitbbe1871538d5e32787284ac99be10ef871654b0e (patch)
tree8b8e00f4fdbab3b8a956b31826e2049f5d6257fc /webkit
parent765b3550e2164b7ccc5360b360ba940639be71c1 (diff)
downloadchromium_src-bbe1871538d5e32787284ac99be10ef871654b0e.zip
chromium_src-bbe1871538d5e32787284ac99be10ef871654b0e.tar.gz
chromium_src-bbe1871538d5e32787284ac99be10ef871654b0e.tar.bz2
Hopefully fix leaks of TestNavigationEntries. They aren't be deleted in the destructor. Hopefully the fancy new linked_ptr will fix the problem.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1138 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/test_shell/test_navigation_controller.cc17
-rw-r--r--webkit/tools/test_shell/test_navigation_controller.h3
2 files changed, 9 insertions, 11 deletions
diff --git a/webkit/tools/test_shell/test_navigation_controller.cc b/webkit/tools/test_shell/test_navigation_controller.cc
index 07a23fe..8aa0522 100644
--- a/webkit/tools/test_shell/test_navigation_controller.cc
+++ b/webkit/tools/test_shell/test_navigation_controller.cc
@@ -84,8 +84,6 @@ TestNavigationController::~TestNavigationController() {
}
void TestNavigationController::Reset() {
- for (int i = 0, c = static_cast<int>(entries_.size()); i < c; ++i)
- delete entries_[i];
entries_.clear();
DiscardPendingEntry();
@@ -138,7 +136,7 @@ void TestNavigationController::LoadEntry(TestNavigationEntry* entry) {
TestNavigationEntry* TestNavigationController::GetLastCommittedEntry() const {
if (last_committed_entry_index_ == -1)
return NULL;
- return entries_[last_committed_entry_index_];
+ return entries_[last_committed_entry_index_].get();
}
TestNavigationEntry* TestNavigationController::GetActiveEntry() const {
@@ -161,13 +159,13 @@ TestNavigationEntry* TestNavigationController::GetEntryAtOffset(
if (index < 0 || index >= GetEntryCount())
return NULL;
- return entries_[index];
+ return entries_[index].get();
}
TestNavigationEntry* TestNavigationController::GetEntryWithPageID(
int32 page_id) const {
int index = GetEntryIndexWithPageID(page_id);
- return (index != -1) ? entries_[index] : NULL;
+ return (index != -1) ? entries_[index].get() : NULL;
}
void TestNavigationController::DidNavigateToEntry(TestNavigationEntry* entry) {
@@ -184,8 +182,8 @@ void TestNavigationController::DidNavigateToEntry(TestNavigationEntry* entry) {
// same URL, a new PageID is not created.
int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID());
- TestNavigationEntry* existing_entry =
- (existing_entry_index != -1) ? entries_[existing_entry_index] : NULL;
+ TestNavigationEntry* existing_entry = (existing_entry_index != -1) ?
+ entries_[existing_entry_index].get() : NULL;
if (!existing_entry) {
// No existing entry, then simply ignore this navigation!
DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID();
@@ -231,13 +229,12 @@ void TestNavigationController::InsertEntry(TestNavigationEntry* entry) {
int current_size = static_cast<int>(entries_.size());
if (current_size > 0) {
while (last_committed_entry_index_ < (current_size - 1)) {
- delete entries_[current_size - 1];
entries_.pop_back();
current_size--;
}
}
- entries_.push_back(entry);
+ entries_.push_back(linked_ptr<TestNavigationEntry>(entry));
last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1;
UpdateMaxPageID();
}
@@ -254,7 +251,7 @@ void TestNavigationController::NavigateToPendingEntry(bool reload) {
// For session history navigations only the pending_entry_index_ is set.
if (!pending_entry_) {
DCHECK(pending_entry_index_ != -1);
- pending_entry_ = entries_[pending_entry_index_];
+ pending_entry_ = entries_[pending_entry_index_].get();
}
if (shell_->Navigate(*pending_entry_, reload)) {
diff --git a/webkit/tools/test_shell/test_navigation_controller.h b/webkit/tools/test_shell/test_navigation_controller.h
index c99a238..da78bac 100644
--- a/webkit/tools/test_shell/test_navigation_controller.h
+++ b/webkit/tools/test_shell/test_navigation_controller.h
@@ -34,6 +34,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/linked_ptr.h"
#include "base/ref_counted.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/weburlrequest.h"
@@ -193,7 +194,7 @@ class TestNavigationController {
void UpdateMaxPageID();
// List of NavigationEntry for this tab
- typedef std::vector<TestNavigationEntry*> NavigationEntryList;
+ typedef std::vector< linked_ptr<TestNavigationEntry> > NavigationEntryList;
typedef NavigationEntryList::iterator NavigationEntryListIterator;
NavigationEntryList entries_;