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

Unified Diff: rlz/lib/rlz_lib.cc

Issue 2857343004: Add rlz_utils as a new build target to rlz/ (Closed)
Patch Set: build.gn fix Created 3 years, 7 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 | « rlz/lib/rlz_lib.h ('k') | rlz/lib/rlz_lib_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rlz/lib/rlz_lib.cc
diff --git a/rlz/lib/rlz_lib.cc b/rlz/lib/rlz_lib.cc
index 081f80b0d6a5915b180ebbbdb79404b6f279e409..eb4c8d9bcc075f628cb76165bf6b3bca1c2e7f90 100644
--- a/rlz/lib/rlz_lib.cc
+++ b/rlz/lib/rlz_lib.cc
@@ -14,9 +14,9 @@
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "rlz/lib/assert.h"
-#include "rlz/lib/crc32.h"
#include "rlz/lib/financial_ping.h"
#include "rlz/lib/lib_values.h"
+#include "rlz/lib/net_response_check.h"
#include "rlz/lib/rlz_value_store.h"
#include "rlz/lib/string_utils.h"
@@ -377,57 +377,6 @@ bool FormFinancialPingRequest(Product product, const AccessPoint* access_points,
return true;
}
-bool IsPingResponseValid(const char* response, int* checksum_idx) {
- if (!response || !response[0])
- return false;
-
- if (checksum_idx)
- *checksum_idx = -1;
-
- if (strlen(response) > kMaxPingResponseLength) {
- ASSERT_STRING("IsPingResponseValid: response is too long to parse.");
- return false;
- }
-
- // Find the checksum line.
- std::string response_string(response);
-
- std::string checksum_param("\ncrc32: ");
- int calculated_crc;
- int checksum_index = response_string.find(checksum_param);
- if (checksum_index >= 0) {
- // Calculate checksum of message preceeding checksum line.
- // (+ 1 to include the \n)
- std::string message(response_string.substr(0, checksum_index + 1));
- if (!Crc32(message.c_str(), &calculated_crc))
- return false;
- } else {
- checksum_param = "crc32: "; // Empty response case.
- if (!base::StartsWith(response_string, checksum_param,
- base::CompareCase::SENSITIVE))
- return false;
-
- checksum_index = 0;
- if (!Crc32("", &calculated_crc))
- return false;
- }
-
- // Find the checksum value on the response.
- int checksum_end = response_string.find("\n", checksum_index + 1);
- if (checksum_end < 0)
- checksum_end = response_string.size();
-
- int checksum_begin = checksum_index + checksum_param.size();
- std::string checksum = response_string.substr(checksum_begin,
- checksum_end - checksum_begin + 1);
- base::TrimWhitespaceASCII(checksum, base::TRIM_ALL, &checksum);
-
- if (checksum_idx)
- *checksum_idx = checksum_index;
-
- return calculated_crc == HexStringToInteger(checksum.c_str());
-}
-
// Complex helpers built on top of other functions.
bool ParseFinancialPingResponse(Product product, const char* response) {
« no previous file with comments | « rlz/lib/rlz_lib.h ('k') | rlz/lib/rlz_lib_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698