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

Unified Diff: src/service.cc

Issue 3797006: cashew: support additional usage API error result strings (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/cashew.git
Patch Set: Created 10 years, 2 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
« no previous file with comments | « src/service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/service.cc
diff --git a/src/service.cc b/src/service.cc
index 0735bfc55f6252a2fb301027e487b33168a959db..1159385011467935b06d97228d40a71b4d44f420 100644
--- a/src/service.cc
+++ b/src/service.cc
@@ -53,6 +53,11 @@ static const int kCrosUsageVersionMaxSupported = 1;
// Chromium OS Usage API status values
static const char *kCrosUsageStatusOk = "OK";
static const char *kCrosUsageStatusError = "ERROR";
+static const char *kCrosUsageStatusMalformedRequest = "MALFORMED REQUEST";
+static const char *kCrosUsageStatusInternalError = "INTERNAL ERROR";
+static const char *kCrosUsageStatusServiceUnavailable = "SERVICE UNAVAILABLE";
+static const char *kCrosUsageStatusRequestRefused = "REQUEST REFUSED";
+static const char *kCrosUsageStatusUnknownDevice = "UNKNOWN DEVICE";
Eric Shienbrood 2010/10/15 18:43:18 If you add a new status, you have to modify IsVali
Vince Laviano 2010/10/15 20:25:12 This is a good point. Composing a rambling reply
Service::Service(ServiceManager * const parent,
DBus::Connection& connection, // NOLINT
@@ -217,12 +222,13 @@ void Service::OnRequestComplete(const DataPlanProvider *provider,
return;
}
DLOG(INFO) << path_ << ": OnRequestComplete: status = " << status;
- if (status != kCrosUsageStatusOk && status != kCrosUsageStatusError) {
+ if (!IsValidCrosUsageStatus(status)) {
LOG(WARNING) << path_ << ": OnRequestComplete: invalid status: " << status;
return;
}
- if (status == kCrosUsageStatusError) {
+ if (status != kCrosUsageStatusOk) {
LOG(WARNING) << path_ << ": OnRequestComplete: status: " << status;
+ OnCrosUsageErrorResult(status);
return;
}
@@ -569,4 +575,24 @@ void Service::DeleteCarrierState() {
}
}
+bool Service::IsValidCrosUsageStatus(const std::string& status) const {
+ if (status == kCrosUsageStatusOk ||
+ status == kCrosUsageStatusError ||
+ status == kCrosUsageStatusMalformedRequest ||
+ status == kCrosUsageStatusInternalError ||
+ status == kCrosUsageStatusServiceUnavailable ||
+ status == kCrosUsageStatusRequestRefused ||
+ status == kCrosUsageStatusUnknownDevice) {
+ return true;
+ }
+ return false;
+}
+
+void Service::OnCrosUsageErrorResult(const std::string& status) {
+ DLOG(WARNING) << path_ << ": OnCrosUsageErrorResult: " << status;
+ // TODO(vlaviano): take action based on which specific error status string
+ // we've received (e.g., we could adjust the update timer interval, or
+ // disable the timer entirely).
+}
+
} // namespace cashew
« no previous file with comments | « src/service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698