Commit ca6c2a9a authored by ukai@chromium.org's avatar ukai@chromium.org

Use ChromeThread::IO instead of virtual set_request_context

ChromeThread::IO will be used to cancel URLFetcher request and
clean up URLRequestContextGetter.

BUG=52562,52826
TEST=valgrind passes

Review URL: http://codereview.chromium.org/3176028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57032 0039d316-1c4b-4281-b951-d872f2087c98
parent d7bd8121
...@@ -70,13 +70,16 @@ class TestInfoBarDelegateFactory ...@@ -70,13 +70,16 @@ class TestInfoBarDelegateFactory
class GoogleURLTrackerTest : public testing::Test { class GoogleURLTrackerTest : public testing::Test {
protected: protected:
GoogleURLTrackerTest() GoogleURLTrackerTest()
: original_default_request_context_(NULL) { : message_loop_(NULL),
io_thread_(NULL),
original_default_request_context_(NULL) {
} }
void SetUp() { void SetUp() {
original_default_request_context_ = Profile::GetDefaultRequestContext(); original_default_request_context_ = Profile::GetDefaultRequestContext();
Profile::set_default_request_context(NULL); Profile::set_default_request_context(NULL);
message_loop_ = new MessageLoop(MessageLoop::TYPE_IO); message_loop_ = new MessageLoop(MessageLoop::TYPE_IO);
io_thread_ = new ChromeThread(ChromeThread::IO, message_loop_);
network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
testing_profile_.reset(new TestingProfile); testing_profile_.reset(new TestingProfile);
TestingBrowserProcess* testing_browser_process = TestingBrowserProcess* testing_browser_process =
...@@ -99,8 +102,10 @@ class GoogleURLTrackerTest : public testing::Test { ...@@ -99,8 +102,10 @@ class GoogleURLTrackerTest : public testing::Test {
testing_browser_process->SetPrefService(NULL); testing_browser_process->SetPrefService(NULL);
testing_profile_.reset(); testing_profile_.reset();
network_change_notifier_.reset(); network_change_notifier_.reset();
delete io_thread_;
delete message_loop_; delete message_loop_;
Profile::set_default_request_context(original_default_request_context_); Profile::set_default_request_context(original_default_request_context_);
original_default_request_context_ = NULL;
} }
void CreateRequestContext() { void CreateRequestContext() {
...@@ -215,6 +220,7 @@ class GoogleURLTrackerTest : public testing::Test { ...@@ -215,6 +220,7 @@ class GoogleURLTrackerTest : public testing::Test {
private: private:
MessageLoop* message_loop_; MessageLoop* message_loop_;
ChromeThread* io_thread_;
scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
scoped_ptr<TestingProfile> testing_profile_; scoped_ptr<TestingProfile> testing_profile_;
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
// Typical usage: // Typical usage:
// // TestURLFetcher requires a MessageLoop: // // TestURLFetcher requires a MessageLoop:
// MessageLoopForUI message_loop; // MessageLoopForUI message_loop;
// // And io_thread to release URLRequestContextGetter in URLFetcher::Core.
// ChromeThread io_thread(ChromeThread::IO, &message_loop);
// // Create and register factory. // // Create and register factory.
// TestURLFetcherFactory factory; // TestURLFetcherFactory factory;
// URLFetcher::set_factory(&factory); // URLFetcher::set_factory(&factory);
...@@ -53,13 +55,6 @@ class TestURLFetcher : public URLFetcher { ...@@ -53,13 +55,6 @@ class TestURLFetcher : public URLFetcher {
// Returns the data uploaded on this URLFetcher. // Returns the data uploaded on this URLFetcher.
const std::string& upload_data() const { return URLFetcher::upload_data(); } const std::string& upload_data() const { return URLFetcher::upload_data(); }
// Overriden to do nothing. URLFetcher implementation add reference
// to request_context_getter in core_, but it might not be released
// because we wouldn't call Core::CancelURLRequest.
// Without this, we'll see leaks of URLRequestContext in test.
virtual void set_request_context(
URLRequestContextGetter* request_context_getter) {}
private: private:
const GURL original_url_; const GURL original_url_;
......
...@@ -140,7 +140,7 @@ class URLFetcher { ...@@ -140,7 +140,7 @@ class URLFetcher {
// Set the URLRequestContext on the request. Must be called before the // Set the URLRequestContext on the request. Must be called before the
// request is started. // request is started.
virtual void set_request_context( void set_request_context(
URLRequestContextGetter* request_context_getter); URLRequestContextGetter* request_context_getter);
// If |retry| is false, 5xx responses will be propagated to the observer, // If |retry| is false, 5xx responses will be propagated to the observer,
......
...@@ -4141,13 +4141,6 @@ ...@@ -4141,13 +4141,6 @@
... ...
fun:_ZN17URLRequestHttpJobD0Ev fun:_ZN17URLRequestHttpJobD0Ev
} }
{
bug_52826
Memcheck:Leak
fun:_Znw*
fun:_ZN14TestingProfile20CreateRequestContextEv
fun:_ZN20GoogleURLTrackerTest20CreateRequestContextEv
}
{ {
bug_52831 bug_52831
Memcheck:Leak Memcheck:Leak
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment