Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1034)

Unified Diff: blimp/client/core/session/assignment_source.cc

Issue 2211613002: Add AssignmentSource to BlimpClientContextImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge origin/master Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/client/core/session/assignment_source.cc
diff --git a/blimp/client/core/session/assignment_source.cc b/blimp/client/core/session/assignment_source.cc
index e2c28249fb16fb65a65e137a75900cc5c8c68a16..bc9f95c38bc9215af86fd1bc266a15c59aefc7ab 100644
--- a/blimp/client/core/session/assignment_source.cc
+++ b/blimp/client/core/session/assignment_source.cc
@@ -168,23 +168,6 @@ Assignment GetAssignmentFromCommandLine() {
} // namespace
-Assignment::Assignment() : transport_protocol(TransportProtocol::UNKNOWN) {}
-
-Assignment::Assignment(const Assignment& other) = default;
-
-Assignment::~Assignment() {}
-
-bool Assignment::IsValid() const {
- if (engine_endpoint.address().empty() || engine_endpoint.port() == 0 ||
- transport_protocol == TransportProtocol::UNKNOWN) {
- return false;
- }
- if (transport_protocol == TransportProtocol::SSL && !cert) {
- return false;
- }
- return true;
-}
-
AssignmentSource::AssignmentSource(
const GURL& assigner_endpoint,
const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner,
@@ -221,7 +204,7 @@ void AssignmentSource::OnGetAssignmentFromCommandLineDone(
// If GetAssignmentFromCommandLine succeeded, then return its output.
if (parsed_assignment.IsValid()) {
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::RESULT_OK, parsed_assignment);
+ .Run(ASSIGNMENT_REQUEST_RESULT_OK, parsed_assignment);
return;
}
@@ -259,7 +242,7 @@ void AssignmentSource::OnURLFetchComplete(const net::URLFetcher* source) {
DVLOG(1) << "Assignment request failed due to network error: "
<< net::ErrorToString(source->GetStatus().error());
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_NETWORK_FAILURE, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_NETWORK_FAILURE, Assignment());
return;
}
@@ -269,28 +252,27 @@ void AssignmentSource::OnURLFetchComplete(const net::URLFetcher* source) {
break;
case net::HTTP_BAD_REQUEST:
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_BAD_REQUEST, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_BAD_REQUEST, Assignment());
break;
case net::HTTP_UNAUTHORIZED:
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_EXPIRED_ACCESS_TOKEN,
- Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_EXPIRED_ACCESS_TOKEN, Assignment());
break;
case net::HTTP_FORBIDDEN:
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_USER_INVALID, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_USER_INVALID, Assignment());
break;
case 429: // Too Many Requests
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_OUT_OF_VMS, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_OUT_OF_VMS, Assignment());
break;
case net::HTTP_INTERNAL_SERVER_ERROR:
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_SERVER_ERROR, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_SERVER_ERROR, Assignment());
break;
default:
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment());
break;
}
}
@@ -304,7 +286,7 @@ void AssignmentSource::ParseAssignerResponse() {
std::string response;
if (!url_fetcher_->GetResponseAsString(&response)) {
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment());
return;
}
@@ -319,7 +301,7 @@ void AssignmentSource::OnJsonParsed(std::unique_ptr<base::Value> json) {
const base::DictionaryValue* dict;
if (!json->GetAsDictionary(&dict)) {
Kevin M 2016/08/09 21:00:34 nit: Add LOG(WARNING)s here and wherever BAD_RESPO
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment());
return;
}
@@ -332,20 +314,20 @@ void AssignmentSource::OnJsonParsed(std::unique_ptr<base::Value> json) {
dict->GetString(kHostKey, &host) && dict->GetInteger(kPortKey, &port) &&
dict->GetString(kCertificateKey, &cert_str))) {
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment());
return;
}
net::IPAddress ip_address;
if (!ip_address.AssignFromIPLiteral(host)) {
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment());
return;
}
if (!base::IsValueInRangeForNumericType<uint16_t>(port)) {
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment());
return;
}
@@ -355,7 +337,7 @@ void AssignmentSource::OnJsonParsed(std::unique_ptr<base::Value> json) {
net::X509Certificate::FORMAT_PEM_CERT_SEQUENCE);
if (cert_list.size() != 1) {
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_INVALID_CERT, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_INVALID_CERT, Assignment());
return;
}
@@ -368,13 +350,13 @@ void AssignmentSource::OnJsonParsed(std::unique_ptr<base::Value> json) {
assignment.cert = std::move(cert_list[0]);
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_OK, assignment);
+ .Run(ASSIGNMENT_REQUEST_RESULT_OK, assignment);
}
void AssignmentSource::OnJsonParseError(const std::string& error) {
DLOG(ERROR) << "Error while parsing assigner JSON: " << error;
base::ResetAndReturn(&callback_)
- .Run(AssignmentSource::Result::RESULT_BAD_RESPONSE, Assignment());
+ .Run(ASSIGNMENT_REQUEST_RESULT_BAD_RESPONSE, Assignment());
}
} // namespace client

Powered by Google App Engine
This is Rietveld 408576698