Commit f85ab8f6 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Make PrivetURLFetcher::Delegate::OnParsedJson() take a response code.

The method does not need access to a PrivetURLFetcher pointer.

Change-Id: I94d42334cdfab47131bc29e8de5b090a0634f120
Reviewed-on: https://chromium-review.googlesource.com/804670
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521946}
parent 16083267
...@@ -118,7 +118,7 @@ void PrivetInfoOperationImpl::OnError(int response_code, ...@@ -118,7 +118,7 @@ void PrivetInfoOperationImpl::OnError(int response_code,
callback_.Run(nullptr); callback_.Run(nullptr);
} }
void PrivetInfoOperationImpl::OnParsedJson(PrivetURLFetcher* fetcher, void PrivetInfoOperationImpl::OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) { bool has_error) {
callback_.Run(&value); callback_.Run(&value);
...@@ -192,7 +192,7 @@ void PrivetRegisterOperationImpl::OnError(int response_code, ...@@ -192,7 +192,7 @@ void PrivetRegisterOperationImpl::OnError(int response_code,
} }
void PrivetRegisterOperationImpl::OnParsedJson( void PrivetRegisterOperationImpl::OnParsedJson(
PrivetURLFetcher* fetcher, int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) { bool has_error) {
if (has_error) { if (has_error) {
...@@ -200,11 +200,8 @@ void PrivetRegisterOperationImpl::OnParsedJson( ...@@ -200,11 +200,8 @@ void PrivetRegisterOperationImpl::OnParsedJson(
value.GetString(kPrivetKeyError, &error); value.GetString(kPrivetKeyError, &error);
ongoing_ = false; ongoing_ = false;
delegate_->OnPrivetRegisterError(this, delegate_->OnPrivetRegisterError(this, current_action_, FAILURE_JSON_ERROR,
current_action_, response_code, &value);
FAILURE_JSON_ERROR,
fetcher->response_code(),
&value);
return; return;
} }
...@@ -318,10 +315,9 @@ void PrivetRegisterOperationImpl::Cancelation::OnError( ...@@ -318,10 +315,9 @@ void PrivetRegisterOperationImpl::Cancelation::OnError(
PrivetURLFetcher::ErrorType error) {} PrivetURLFetcher::ErrorType error) {}
void PrivetRegisterOperationImpl::Cancelation::OnParsedJson( void PrivetRegisterOperationImpl::Cancelation::OnParsedJson(
PrivetURLFetcher* fetcher, int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) { bool has_error) {}
}
void PrivetRegisterOperationImpl::Cancelation::Cleanup() { void PrivetRegisterOperationImpl::Cancelation::Cleanup() {
// Nothing needs to be done, as base::Owned will delete this object, // Nothing needs to be done, as base::Owned will delete this object,
...@@ -358,7 +354,7 @@ void PrivetJSONOperationImpl::OnError(int response_code, ...@@ -358,7 +354,7 @@ void PrivetJSONOperationImpl::OnError(int response_code,
callback_.Run(nullptr); callback_.Run(nullptr);
} }
void PrivetJSONOperationImpl::OnParsedJson(PrivetURLFetcher* fetcher, void PrivetJSONOperationImpl::OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) { bool has_error) {
callback_.Run(&value); callback_.Run(&value);
...@@ -609,7 +605,7 @@ void PrivetLocalPrintOperationImpl::OnError(int response_code, ...@@ -609,7 +605,7 @@ void PrivetLocalPrintOperationImpl::OnError(int response_code,
} }
void PrivetLocalPrintOperationImpl::OnParsedJson( void PrivetLocalPrintOperationImpl::OnParsedJson(
PrivetURLFetcher* fetcher, int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) { bool has_error) {
DCHECK(!current_response_.is_null()); DCHECK(!current_response_.is_null());
......
...@@ -35,7 +35,7 @@ class PrivetInfoOperationImpl : public PrivetJSONOperation, ...@@ -35,7 +35,7 @@ class PrivetInfoOperationImpl : public PrivetJSONOperation,
PrivetHTTPClient* GetHTTPClient() override; PrivetHTTPClient* GetHTTPClient() override;
void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; void OnError(int response_code, PrivetURLFetcher::ErrorType error) override;
void OnParsedJson(PrivetURLFetcher* fetcher, void OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) override; bool has_error) override;
...@@ -61,7 +61,7 @@ class PrivetRegisterOperationImpl ...@@ -61,7 +61,7 @@ class PrivetRegisterOperationImpl
void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; void OnError(int response_code, PrivetURLFetcher::ErrorType error) override;
void OnParsedJson(PrivetURLFetcher* fetcher, void OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) override; bool has_error) override;
...@@ -77,7 +77,7 @@ class PrivetRegisterOperationImpl ...@@ -77,7 +77,7 @@ class PrivetRegisterOperationImpl
void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; void OnError(int response_code, PrivetURLFetcher::ErrorType error) override;
void OnParsedJson(PrivetURLFetcher* fetcher, void OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) override; bool has_error) override;
...@@ -127,7 +127,7 @@ class PrivetJSONOperationImpl : public PrivetJSONOperation, ...@@ -127,7 +127,7 @@ class PrivetJSONOperationImpl : public PrivetJSONOperation,
PrivetHTTPClient* GetHTTPClient() override; PrivetHTTPClient* GetHTTPClient() override;
void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; void OnError(int response_code, PrivetURLFetcher::ErrorType error) override;
void OnParsedJson(PrivetURLFetcher* fetcher, void OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) override; bool has_error) override;
void OnNeedPrivetToken(PrivetURLFetcher::TokenCallback callback) override; void OnNeedPrivetToken(PrivetURLFetcher::TokenCallback callback) override;
...@@ -165,7 +165,7 @@ class PrivetLocalPrintOperationImpl ...@@ -165,7 +165,7 @@ class PrivetLocalPrintOperationImpl
// PrivetURLFetcher::Delegate: // PrivetURLFetcher::Delegate:
void OnError(int response_code, PrivetURLFetcher::ErrorType error) override; void OnError(int response_code, PrivetURLFetcher::ErrorType error) override;
void OnParsedJson(PrivetURLFetcher* fetcher, void OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) override; bool has_error) override;
void OnNeedPrivetToken(PrivetURLFetcher::TokenCallback callback) override; void OnNeedPrivetToken(PrivetURLFetcher::TokenCallback callback) override;
......
...@@ -1068,11 +1068,10 @@ class PrivetHttpWithServerTest : public ::testing::Test, ...@@ -1068,11 +1068,10 @@ class PrivetHttpWithServerTest : public ::testing::Test,
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_); base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_);
} }
void OnParsedJson(PrivetURLFetcher* fetcher, void OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) override { bool has_error) override {
NOTREACHED(); NOTREACHED();
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_);
} }
bool OnRawData(bool response_is_file, bool OnRawData(bool response_is_file,
......
...@@ -328,7 +328,8 @@ void PrivetURLFetcher::OnURLFetchCompleteParseData( ...@@ -328,7 +328,8 @@ void PrivetURLFetcher::OnURLFetchCompleteParseData(
is_error_response = true; is_error_response = true;
} }
delegate_->OnParsedJson(this, *dictionary_value, is_error_response); delegate_->OnParsedJson(response_code(), *dictionary_value,
is_error_response);
} }
void PrivetURLFetcher::ScheduleRetry(int timeout_seconds) { void PrivetURLFetcher::ScheduleRetry(int timeout_seconds) {
......
...@@ -50,7 +50,7 @@ class PrivetURLFetcher : public net::URLFetcherDelegate { ...@@ -50,7 +50,7 @@ class PrivetURLFetcher : public net::URLFetcherDelegate {
// |response_code| is only needed for RESPONSE_CODE_ERROR. // |response_code| is only needed for RESPONSE_CODE_ERROR.
virtual void OnError(int response_code, ErrorType error) = 0; virtual void OnError(int response_code, ErrorType error) = 0;
virtual void OnParsedJson(PrivetURLFetcher* fetcher, virtual void OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) = 0; bool has_error) = 0;
......
...@@ -46,7 +46,7 @@ class MockPrivetURLFetcherDelegate : public PrivetURLFetcher::Delegate { ...@@ -46,7 +46,7 @@ class MockPrivetURLFetcherDelegate : public PrivetURLFetcher::Delegate {
MOCK_METHOD1(OnErrorInternal, void(PrivetURLFetcher::ErrorType error)); MOCK_METHOD1(OnErrorInternal, void(PrivetURLFetcher::ErrorType error));
void OnParsedJson(PrivetURLFetcher* fetcher, void OnParsedJson(int response_code,
const base::DictionaryValue& value, const base::DictionaryValue& value,
bool has_error) override { bool has_error) override {
saved_value_.reset(value.DeepCopy()); saved_value_.reset(value.DeepCopy());
......
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