summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 21:36:46 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 21:36:46 +0000
commit773b636acde3e4435e8597587b4d50409a1d3865 (patch)
treea847b4accfae8cec1fd834fcfb9d7c026ce28599
parentf23d4da9135be3862d1b9a209628876987961d5e (diff)
downloadchromium_src-773b636acde3e4435e8597587b4d50409a1d3865.zip
chromium_src-773b636acde3e4435e8597587b4d50409a1d3865.tar.gz
chromium_src-773b636acde3e4435e8597587b4d50409a1d3865.tar.bz2
Revert 67284 - Used a MessageLoopProxy to store the delegate's message loop in URLFetcher::Core. This allows the thread that created the URLFetcher object to go away without causing the IO thread to crash.
BUG=None TEST=None Review URL: http://codereview.chromium.org/5283001 TBR=sanjeevr@chromium.org Review URL: http://codereview.chromium.org/5382001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67320 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/speech/speech_recognition_request_unittest.cc1
-rw-r--r--chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc2
-rw-r--r--chrome/common/net/url_fetcher.cc22
3 files changed, 7 insertions, 18 deletions
diff --git a/chrome/browser/speech/speech_recognition_request_unittest.cc b/chrome/browser/speech/speech_recognition_request_unittest.cc
index 6d1db5f..e328eb4 100644
--- a/chrome/browser/speech/speech_recognition_request_unittest.cc
+++ b/chrome/browser/speech/speech_recognition_request_unittest.cc
@@ -37,7 +37,6 @@ class SpeechRecognitionRequestTest : public SpeechRecognitionRequestDelegate,
}
protected:
- MessageLoop message_loop_;
TestURLFetcherFactory url_fetcher_factory_;
bool error_;
SpeechInputResultArray result_;
diff --git a/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc
index 5f9be34..47df6b7 100644
--- a/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc
+++ b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc
@@ -73,8 +73,6 @@ class GaiaAuthFetcherTest : public testing::Test {
GURL client_login_source_;
GURL issue_auth_token_source_;
TestingProfile profile_;
- protected:
- MessageLoop message_loop_;
};
class MockGaiaConsumer : public GaiaAuthConsumer {
diff --git a/chrome/common/net/url_fetcher.cc b/chrome/common/net/url_fetcher.cc
index 1a359f7..ebc876d 100644
--- a/chrome/common/net/url_fetcher.cc
+++ b/chrome/common/net/url_fetcher.cc
@@ -97,9 +97,7 @@ class URLFetcher::Core
GURL url_; // The URL we eventually wound up at
RequestType request_type_; // What type of request is this?
URLFetcher::Delegate* delegate_; // Object to notify on completion
- scoped_refptr<base::MessageLoopProxy> delegate_loop_proxy_;
- // Message loop proxy of the creating
- // thread.
+ MessageLoop* delegate_loop_; // Message loop of the creating thread
scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
// The message loop proxy for the thread
// on which the request IO happens.
@@ -194,7 +192,7 @@ URLFetcher::Core::Core(URLFetcher* fetcher,
original_url_(original_url),
request_type_(request_type),
delegate_(d),
- delegate_loop_proxy_(base::MessageLoopProxy::CreateForCurrentThread()),
+ delegate_loop_(MessageLoop::current()),
request_(NULL),
load_flags_(net::LOAD_NORMAL),
response_code_(-1),
@@ -212,7 +210,7 @@ URLFetcher::Core::~Core() {
}
void URLFetcher::Core::Start() {
- DCHECK(delegate_loop_proxy_);
+ DCHECK(delegate_loop_);
CHECK(request_context_getter_) << "We need an URLRequestContext!";
io_message_loop_proxy_ = request_context_getter_->GetIOMessageLoopProxy();
CHECK(io_message_loop_proxy_.get()) << "We need an IO message loop proxy";
@@ -223,7 +221,7 @@ void URLFetcher::Core::Start() {
}
void URLFetcher::Core::Stop() {
- DCHECK(delegate_loop_proxy_->BelongsToCurrentThread());
+ DCHECK_EQ(MessageLoop::current(), delegate_loop_);
delegate_ = NULL;
fetcher_ = NULL;
if (io_message_loop_proxy_.get()) {
@@ -271,14 +269,8 @@ void URLFetcher::Core::OnReadCompleted(URLRequest* request, int bytes_read) {
// See comments re: HEAD requests in OnResponseStarted().
if (!request_->status().is_io_pending() || (request_type_ == HEAD)) {
- bool posted = delegate_loop_proxy_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this,
- &Core::OnCompletedURLRequest,
- request_->status()));
- // If the delegate message loop does not exist any more, then the delegate
- // should be gone too.
- DCHECK(posted || !delegate_);
+ delegate_loop_->PostTask(FROM_HERE, NewRunnableMethod(
+ this, &Core::OnCompletedURLRequest, request_->status()));
ReleaseRequest();
}
}
@@ -349,7 +341,7 @@ void URLFetcher::Core::CancelURLRequest() {
}
void URLFetcher::Core::OnCompletedURLRequest(const URLRequestStatus& status) {
- DCHECK(delegate_loop_proxy_->BelongsToCurrentThread());
+ DCHECK(MessageLoop::current() == delegate_loop_);
// Checks the response from server.
if (response_code_ >= 500) {