diff options
author | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 14:21:27 +0000 |
---|---|---|
committer | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 14:21:27 +0000 |
commit | 5915a01df45fa8044b956a13ec25c8a3e193df74 (patch) | |
tree | 83f399e3866e4a5bb665c07a291bc4e7ece61447 /content | |
parent | 4c1c5d8409e0029f77b0531331187da3c42a96e7 (diff) | |
download | chromium_src-5915a01df45fa8044b956a13ec25c8a3e193df74.zip chromium_src-5915a01df45fa8044b956a13ec25c8a3e193df74.tar.gz chromium_src-5915a01df45fa8044b956a13ec25c8a3e193df74.tar.bz2 |
Update params to OnURLFetchComplete().
BUG=83592
TEST=SpeechRecognitionRequestTest.BasicTest
Review URL: http://codereview.chromium.org/8002025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
4 files changed, 32 insertions, 26 deletions
diff --git a/content/browser/speech/speech_recognition_request.cc b/content/browser/speech/speech_recognition_request.cc index 52345e0..31b7f1f 100644 --- a/content/browser/speech/speech_recognition_request.cc +++ b/content/browser/speech/speech_recognition_request.cc @@ -179,19 +179,15 @@ void SpeechRecognitionRequest::UploadAudioChunk(const std::string& audio_data, url_fetcher_->AppendChunkToUpload(audio_data, is_last_chunk); } -void SpeechRecognitionRequest::OnURLFetchComplete( - const URLFetcher* source, - const GURL& url, - const net::URLRequestStatus& status, - int response_code, - const net::ResponseCookies& cookies, - const std::string& data) { +void SpeechRecognitionRequest::OnURLFetchComplete(const URLFetcher* source) { DCHECK_EQ(url_fetcher_.get(), source); - bool error = !status.is_success() || response_code != 200; + bool error = + !source->status().is_success() || source->response_code() != 200; + SpeechInputResultArray result; if (!error) - error = !ParseServerResponse(data, &result); + error = !ParseServerResponse(source->GetResponseStringRef(), &result); url_fetcher_.reset(); DVLOG(1) << "SpeechRecognitionRequest: Invoking delegate with result."; diff --git a/content/browser/speech/speech_recognition_request.h b/content/browser/speech/speech_recognition_request.h index 6a66641..4ff780a 100644 --- a/content/browser/speech/speech_recognition_request.h +++ b/content/browser/speech/speech_recognition_request.h @@ -63,12 +63,7 @@ class SpeechRecognitionRequest : public URLFetcher::Delegate { bool HasPendingRequest() { return url_fetcher_ != NULL; } // URLFetcher::Delegate methods. - virtual void OnURLFetchComplete(const URLFetcher* source, - const GURL& url, - const net::URLRequestStatus& status, - int response_code, - const net::ResponseCookies& cookies, - const std::string& data); + virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; private: scoped_refptr<net::URLRequestContextGetter> url_context_; diff --git a/content/browser/speech/speech_recognition_request_unittest.cc b/content/browser/speech/speech_recognition_request_unittest.cc index f41649c..a5d75c4 100644 --- a/content/browser/speech/speech_recognition_request_unittest.cc +++ b/content/browser/speech/speech_recognition_request_unittest.cc @@ -42,12 +42,16 @@ void SpeechRecognitionRequestTest::CreateAndTestRequest( request.UploadAudioChunk(std::string(" "), true); TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); ASSERT_TRUE(fetcher); + + fetcher->set_url(fetcher->original_url()); net::URLRequestStatus status; status.set_status(success ? net::URLRequestStatus::SUCCESS : net::URLRequestStatus::FAILED); - fetcher->delegate()->OnURLFetchComplete( - fetcher, fetcher->original_url(), status, success ? 200 : 500, - net::ResponseCookies(), http_response); + fetcher->set_status(status); + fetcher->set_response_code(success ? 200 : 500); + fetcher->SetResponseString(http_response); + + fetcher->delegate()->OnURLFetchComplete(fetcher); // Parsed response will be available in result_. } diff --git a/content/browser/speech/speech_recognizer_unittest.cc b/content/browser/speech/speech_recognizer_unittest.cc index f2cc6ac..03b222b 100644 --- a/content/browser/speech/speech_recognizer_unittest.cc +++ b/content/browser/speech/speech_recognizer_unittest.cc @@ -169,11 +169,15 @@ TEST_F(SpeechRecognizerTest, StopWithData) { // Issue the network callback to complete the process. TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); ASSERT_TRUE(fetcher); + + fetcher->set_url(fetcher->original_url()); net::URLRequestStatus status; status.set_status(net::URLRequestStatus::SUCCESS); - fetcher->delegate()->OnURLFetchComplete( - fetcher, fetcher->original_url(), status, 200, net::ResponseCookies(), - "{\"hypotheses\":[{\"utterance\":\"123\"}]}"); + fetcher->set_status(status); + fetcher->set_response_code(200); + fetcher->SetResponseString("{\"hypotheses\":[{\"utterance\":\"123\"}]}"); + fetcher->delegate()->OnURLFetchComplete(fetcher); + EXPECT_TRUE(recognition_complete_); EXPECT_TRUE(result_received_); EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); @@ -219,11 +223,15 @@ TEST_F(SpeechRecognizerTest, ConnectionError) { EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); // Issue the network callback to complete the process. + fetcher->set_url(fetcher->original_url()); net::URLRequestStatus status; status.set_status(net::URLRequestStatus::FAILED); status.set_error(net::ERR_CONNECTION_REFUSED); - fetcher->delegate()->OnURLFetchComplete( - fetcher, fetcher->original_url(), status, 0, net::ResponseCookies(), ""); + fetcher->set_status(status); + fetcher->set_response_code(0); + fetcher->SetResponseString(""); + fetcher->delegate()->OnURLFetchComplete(fetcher); + EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); EXPECT_EQ(SpeechRecognizer::RECOGNIZER_ERROR_NETWORK, error_); @@ -250,11 +258,14 @@ TEST_F(SpeechRecognizerTest, ServerError) { EXPECT_EQ(SpeechRecognizer::RECOGNIZER_NO_ERROR, error_); // Issue the network callback to complete the process. + fetcher->set_url(fetcher->original_url()); net::URLRequestStatus status; status.set_status(net::URLRequestStatus::SUCCESS); - fetcher->delegate()->OnURLFetchComplete(fetcher, fetcher->original_url(), - status, 500, net::ResponseCookies(), - "Internal Server Error"); + fetcher->set_status(status); + fetcher->set_response_code(500); + fetcher->SetResponseString("Internal Server Error"); + fetcher->delegate()->OnURLFetchComplete(fetcher); + EXPECT_FALSE(recognition_complete_); EXPECT_FALSE(result_received_); EXPECT_EQ(SpeechRecognizer::RECOGNIZER_ERROR_NETWORK, error_); |