Remove the "sid" parameter from the interface.
Clients have been advised to not set this for a long time, and it
defaults to NULL.
Review URL: https://codereview.appspot.com/5696046
git-svn-id: http://rlz.googlecode.com/svn/trunk@62 10bc0f33-e4bf-9a86-80cf-af638054f0c4
diff --git a/win/lib/financial_ping.cc b/win/lib/financial_ping.cc
index a75e3a4..575327e 100644
--- a/win/lib/financial_ping.cc
+++ b/win/lib/financial_ping.cc
@@ -55,7 +55,7 @@
bool FinancialPing::FormRequest(Product product,
const AccessPoint* access_points, const char* product_signature,
const char* product_brand, const char* product_id,
- const char* product_lang, bool exclude_machine_id, const wchar_t* sid,
+ const char* product_lang, bool exclude_machine_id,
std::string* request) {
if (!request) {
ASSERT_STRING("FinancialPing::FormRequest: request is NULL");
@@ -68,7 +68,7 @@
if (lock.failed())
return false;
- UserKey user_key(sid);
+ UserKey user_key(NULL);
if (!user_key.HasAccess(false))
return false;
@@ -109,7 +109,7 @@
// Add the product events.
char cgi[kMaxCgiLength + 1];
cgi[0] = 0;
- bool has_events = GetProductEventsAsCgi(product, cgi, arraysize(cgi), sid);
+ bool has_events = GetProductEventsAsCgi(product, cgi, arraysize(cgi));
if (has_events)
base::StringAppendF(request, "&%s", cgi);
@@ -123,7 +123,7 @@
for (int ap = NO_ACCESS_POINT + 1; ap < LAST_ACCESS_POINT; ap++) {
rlz[0] = 0;
AccessPoint point = static_cast<AccessPoint>(ap);
- if (GetAccessPointRlz(point, rlz, arraysize(rlz), sid) &&
+ if (GetAccessPointRlz(point, rlz, arraysize(rlz)) &&
rlz[0] != NULL)
all_points[idx++] = point;
}
@@ -134,7 +134,7 @@
// This will also include the RLZ Exchange Protocol CGI Argument.
cgi[0] = 0;
if (GetPingParams(product, has_events ? access_points : all_points,
- cgi, arraysize(cgi), sid))
+ cgi, arraysize(cgi)))
base::StringAppendF(request, "&%s", cgi);
if (has_events && !exclude_machine_id) {
@@ -205,7 +205,7 @@
bool FinancialPing::ParseResponse(Product product, const char* response,
const wchar_t* sid) {
- return ParsePingResponse(product, response, sid);
+ return ParsePingResponse(product, response);
}
bool FinancialPing::IsPingTime(Product product, const wchar_t* sid,
@@ -234,7 +234,7 @@
// Check if this product has any unreported events.
char cgi[kMaxCgiLength + 1];
cgi[0] = 0;
- bool has_events = GetProductEventsAsCgi(product, cgi, arraysize(cgi), sid);
+ bool has_events = GetProductEventsAsCgi(product, cgi, arraysize(cgi));
if (no_delay && has_events)
return true;
diff --git a/win/lib/financial_ping.h b/win/lib/financial_ping.h
index 1b795f3..6203ac8 100644
--- a/win/lib/financial_ping.h
+++ b/win/lib/financial_ping.h
@@ -22,7 +22,7 @@
const char* product_signature,
const char* product_brand, const char* product_id,
const char* product_lang, bool exclude_machine_id,
- const wchar_t* sid, std::string* request);
+ std::string* request);
// Parse the HTTP response from the financial ping server.
static bool ParseResponse(Product product, const char* response,
diff --git a/win/lib/financial_ping_test.cc b/win/lib/financial_ping_test.cc
index 070a705..25e47bf 100644
--- a/win/lib/financial_ping_test.cc
+++ b/win/lib/financial_ping_test.cc
@@ -78,7 +78,7 @@
std::string request;
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
- points, "swg", brand, NULL, "en", false, NULL, &request));
+ points, "swg", brand, NULL, "en", false, &request));
std::string expected_response;
base::StringAppendF(&expected_response,
"/tools/pso/ping?as=swg&brand=%s&hl=en&"
@@ -90,7 +90,7 @@
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX, ""));
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
- points, "swg", brand, "IdOk2", NULL, false, NULL, &request));
+ points, "swg", brand, "IdOk2", NULL, false, &request));
expected_response.clear();
base::StringAppendF(&expected_response,
"/tools/pso/ping?as=swg&brand=%s&pid=IdOk2&"
@@ -101,7 +101,7 @@
EXPECT_EQ(expected_response, request);
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
- points, "swg", brand, "IdOk", NULL, true, NULL, &request));
+ points, "swg", brand, "IdOk", NULL, true, &request));
expected_response.clear();
base::StringAppendF(&expected_response,
"/tools/pso/ping?as=swg&brand=%s&pid=IdOk&"
@@ -109,7 +109,7 @@
EXPECT_EQ(expected_response, request);
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
- points, "swg", brand, NULL, NULL, true, NULL, &request));
+ points, "swg", brand, NULL, NULL, true, &request));
expected_response.clear();
base::StringAppendF(&expected_response,
"/tools/pso/ping?as=swg&brand=%s&events=I7S,W1I&rep=2"
@@ -137,7 +137,7 @@
EXPECT_TRUE(rlz_lib::SetAccessPointRlz(rlz_lib::QUICK_SEARCH_BOX,
"QsbRlzValue"));
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
- points, "swg", brand, NULL, NULL, false, NULL, &request));
+ points, "swg", brand, NULL, NULL, false, &request));
expected_response.clear();
base::StringAppendF(&expected_response,
"/tools/pso/ping?as=swg&brand=%s&rep=2&rlz=T4:TbRlzValue,"
@@ -147,7 +147,7 @@
if (!GetAccessPointRlz(rlz_lib::IE_HOME_PAGE, rlz, arraysize(rlz))) {
points[2] = rlz_lib::IE_HOME_PAGE;
EXPECT_TRUE(rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
- points, "swg", brand, "MyId", "en-US", true, NULL, &request));
+ points, "swg", brand, "MyId", "en-US", true, &request));
expected_response.clear();
base::StringAppendF(&expected_response,
"/tools/pso/ping?as=swg&brand=%s&hl=en-US&pid=MyId&rep=2"
@@ -163,7 +163,7 @@
std::string request;
bool ok = rlz_lib::FinancialPing::FormRequest(rlz_lib::TOOLBAR_NOTIFIER,
- points, "swg", "GOOG", NULL, "en", false, NULL, &request);
+ points, "swg", "GOOG", NULL, "en", false, &request);
EXPECT_EQ(rlz_lib::SupplementaryBranding::GetBrand().empty(), ok);
}
diff --git a/win/lib/rlz_lib.cc b/win/lib/rlz_lib.cc
index 7cf30aa..53a1835 100644
--- a/win/lib/rlz_lib.cc
+++ b/win/lib/rlz_lib.cc
@@ -201,12 +201,12 @@
// Event storage functions.
bool RecordStatefulEvent(rlz_lib::Product product, rlz_lib::AccessPoint point,
- rlz_lib::Event event, const wchar_t* sid) {
+ rlz_lib::Event event) {
rlz_lib::LibMutex lock;
if (lock.failed())
return false;
- rlz_lib::UserKey user_key(sid);
+ rlz_lib::UserKey user_key(NULL);
if (!user_key.HasAccess(true))
return false;
@@ -290,13 +290,12 @@
ERROR_SUCCESS : ERROR_FILE_NOT_FOUND;
}
-bool ClearAllProductEventValues(rlz_lib::Product product, const wchar_t* key,
- const wchar_t* sid) {
+bool ClearAllProductEventValues(rlz_lib::Product product, const wchar_t* key) {
rlz_lib::LibMutex lock;
if (lock.failed())
return false;
- rlz_lib::UserKey user_key(sid);
+ rlz_lib::UserKey user_key(NULL);
if (!user_key.HasAccess(true))
return false;
@@ -340,13 +339,12 @@
namespace rlz_lib {
-bool RecordProductEvent(Product product, AccessPoint point, Event event,
- const wchar_t* sid) {
+bool RecordProductEvent(Product product, AccessPoint point, Event event) {
LibMutex lock;
if (lock.failed())
return false;
- UserKey user_key(sid);
+ UserKey user_key(NULL);
if (!user_key.HasAccess(true))
return false;
@@ -393,13 +391,12 @@
return true;
}
-bool ClearProductEvent(Product product, AccessPoint point, Event event,
- const wchar_t* sid) {
+bool ClearProductEvent(Product product, AccessPoint point, Event event) {
LibMutex lock;
if (lock.failed())
return false;
- UserKey user_key(sid);
+ UserKey user_key(NULL);
if (!user_key.HasAccess(true))
return false;
@@ -431,8 +428,7 @@
return true;
}
-bool GetProductEventsAsCgi(Product product, char* cgi, size_t cgi_size,
- const wchar_t* sid) {
+bool GetProductEventsAsCgi(Product product, char* cgi, size_t cgi_size) {
if (!cgi || cgi_size <= 0) {
ASSERT_STRING("GetProductEventsAsCgi: Invalid buffer");
return false;
@@ -444,7 +440,7 @@
if (lock.failed())
return false;
- UserKey user_key(sid);
+ UserKey user_key(NULL);
if (!user_key.HasAccess(false))
return false;
@@ -466,11 +462,11 @@
return true;
}
-bool ClearAllProductEvents(Product product, const wchar_t* sid) {
+bool ClearAllProductEvents(Product product) {
bool result;
- result = ClearAllProductEventValues(product, kEventsSubkeyName, sid);
- result &= ClearAllProductEventValues(product, kStatefulEventsSubkeyName, sid);
+ result = ClearAllProductEventValues(product, kEventsSubkeyName);
+ result &= ClearAllProductEventValues(product, kStatefulEventsSubkeyName);
return result;
}
@@ -516,19 +512,17 @@
return true;
}
-bool GetAccessPointRlz(AccessPoint point, char* rlz, size_t rlz_size,
- const wchar_t* sid) {
- UserKey user_key(sid);
+bool GetAccessPointRlz(AccessPoint point, char* rlz, size_t rlz_size) {
+ UserKey user_key(NULL);
return GetAccessPointRlz(point, rlz, rlz_size, user_key.Get());
}
-bool SetAccessPointRlz(AccessPoint point, const char* new_rlz,
- const wchar_t* sid) {
+bool SetAccessPointRlz(AccessPoint point, const char* new_rlz) {
LibMutex lock;
if (lock.failed())
return false;
- UserKey user_key(sid);
+ UserKey user_key(NULL);
if (!user_key.HasAccess(true))
return false;
@@ -769,7 +763,7 @@
// Combined functions.
bool GetPingParams(Product product, const AccessPoint* access_points,
- char* cgi, size_t cgi_size, const wchar_t* sid) {
+ char* cgi, size_t cgi_size) {
if (!cgi || cgi_size <= 0) {
ASSERT_STRING("GetPingParams: Invalid buffer");
return false;
@@ -781,7 +775,7 @@
if (lock.failed())
return false;
- UserKey user_key(sid);
+ UserKey user_key(NULL);
if (!user_key.HasAccess(false))
return false;
@@ -800,7 +794,7 @@
bool first_rlz = true; // comma before every RLZ but the first.
for (int i = 0; access_points[i] != NO_ACCESS_POINT; i++) {
char rlz[kMaxRlzLength + 1];
- if (GetAccessPointRlz(access_points[i], rlz, arraysize(rlz), sid)) {
+ if (GetAccessPointRlz(access_points[i], rlz, arraysize(rlz))) {
const char* access_point = GetAccessPointName(access_points[i]);
if (!access_point)
continue;
@@ -879,13 +873,12 @@
// TODO: Use something like RSA to make sure the response is
// from a Google server.
-bool ParsePingResponse(Product product, const char* response,
- const wchar_t* sid) {
+bool ParsePingResponse(Product product, const char* response) {
LibMutex lock;
if (lock.failed())
return false;
- UserKey user_key(sid);
+ UserKey user_key(NULL);
if (!user_key.HasAccess(true))
return false;
@@ -947,14 +940,14 @@
continue; // Too long.
if (IsAccessPointSupported(point))
- SetAccessPointRlz(point, rlz_value.substr(0, rlz_length).c_str(), sid);
+ SetAccessPointRlz(point, rlz_value.substr(0, rlz_length).c_str());
} else if (StartsWithASCII(response_line, events_variable, true)) {
// Clear events which server parsed.
std::vector<ReturnedEvent> event_array;
GetEventsFromResponseString(response_line, events_variable, &event_array);
for (size_t i = 0; i < event_array.size(); ++i) {
ClearProductEvent(product, event_array[i].access_point,
- event_array[i].event_type, sid);
+ event_array[i].event_type);
}
} else if (StartsWithASCII(response_line, stateful_events_variable, true)) {
// Record any stateful events the server send over.
@@ -963,7 +956,7 @@
&event_array);
for (size_t i = 0; i < event_array.size(); ++i) {
RecordStatefulEvent(product, event_array[i].access_point,
- event_array[i].event_type, sid);
+ event_array[i].event_type);
}
}
} while (line_end_index >= 0);
@@ -984,8 +977,7 @@
const char* product_id,
const char* product_lang,
bool exclude_machine_id,
- char* request, size_t request_buffer_size,
- const wchar_t* sid) {
+ char* request, size_t request_buffer_size) {
if (!request || request_buffer_size == 0)
return false;
request[0] = 0;
@@ -993,7 +985,7 @@
std::string request_string;
if (!FinancialPing::FormRequest(product, access_points, product_signature,
product_brand, product_id, product_lang,
- exclude_machine_id, sid, &request_string))
+ exclude_machine_id, &request_string))
return false;
if ((request_string.size() < 0) ||
@@ -1007,13 +999,13 @@
bool PingFinancialServer(Product product, const char* request, char* response,
- size_t response_buffer_size, const wchar_t* sid) {
+ size_t response_buffer_size) {
if (!response || response_buffer_size == 0)
return false;
response[0] = 0;
// Check if the time is right to ping.
- if (!FinancialPing::IsPingTime(product, sid, false)) return false;
+ if (!FinancialPing::IsPingTime(product, NULL, false)) return false;
// Send out the ping.
std::string response_string;
@@ -1030,22 +1022,21 @@
}
-bool ParseFinancialPingResponse(Product product, const char* response,
- const wchar_t* sid) {
+bool ParseFinancialPingResponse(Product product, const char* response) {
// Update the last ping time irrespective of success.
- FinancialPing::UpdateLastPingTime(product, sid);
+ FinancialPing::UpdateLastPingTime(product, NULL);
// Parse the ping response - update RLZs, clear events.
- return FinancialPing::ParseResponse(product, response, sid);
+ return FinancialPing::ParseResponse(product, response, NULL);
}
bool SendFinancialPing(Product product, const AccessPoint* access_points,
const char* product_signature,
const char* product_brand,
const char* product_id, const char* product_lang,
- bool exclude_machine_id, const wchar_t* sid) {
+ bool exclude_machine_id) {
return SendFinancialPing(product, access_points, product_signature,
product_brand, product_id, product_lang,
- exclude_machine_id, sid, false);
+ exclude_machine_id, false);
}
@@ -1053,48 +1044,47 @@
const char* product_signature,
const char* product_brand,
const char* product_id, const char* product_lang,
- bool exclude_machine_id, const wchar_t* sid,
+ bool exclude_machine_id,
const bool skip_time_check) {
// Create the financial ping request.
std::string request;
if (!FinancialPing::FormRequest(product, access_points, product_signature,
product_brand, product_id, product_lang,
- exclude_machine_id, sid, &request))
+ exclude_machine_id, &request))
return false;
// Check if the time is right to ping.
- if (!FinancialPing::IsPingTime(product, sid, skip_time_check))
+ if (!FinancialPing::IsPingTime(product, NULL, skip_time_check))
return false;
// Send out the ping, update the last ping time irrespective of success.
- FinancialPing::UpdateLastPingTime(product, sid);
+ FinancialPing::UpdateLastPingTime(product, NULL);
std::string response;
if (!FinancialPing::PingServer(request.c_str(), &response))
return false;
// Parse the ping response - update RLZs, clear events.
- return FinancialPing::ParseResponse(product, response.c_str(), sid);
+ return FinancialPing::ParseResponse(product, response.c_str(), NULL);
}
-void ClearProductState(Product product, const AccessPoint* access_points,
- const wchar_t* sid) {
+void ClearProductState(Product product, const AccessPoint* access_points) {
LibMutex lock;
if (lock.failed())
return;
- UserKey user_key(sid);
+ UserKey user_key(NULL);
if (!user_key.HasAccess(true))
return;
// Delete all product specific state.
- VERIFY(ClearAllProductEvents(product, sid));
- VERIFY(FinancialPing::ClearLastPingTime(product, sid));
+ VERIFY(ClearAllProductEvents(product));
+ VERIFY(FinancialPing::ClearLastPingTime(product, NULL));
// Delete all RLZ's for access points being uninstalled.
if (access_points) {
for (int i = 0; access_points[i] != NO_ACCESS_POINT; i++) {
- VERIFY(SetAccessPointRlz(access_points[i], "" , sid));
+ VERIFY(SetAccessPointRlz(access_points[i], ""));
}
}
diff --git a/win/lib/rlz_lib.h b/win/lib/rlz_lib.h
index 9ea6457..542d576 100644
--- a/win/lib/rlz_lib.h
+++ b/win/lib/rlz_lib.h
@@ -184,26 +184,24 @@
// that information being reported.
// Access: HKCU write.
bool RLZ_LIB_API RecordProductEvent(Product product, AccessPoint point,
- Event event_id, const wchar_t* sid=NULL);
+ Event event_id);
// Get all the events reported by this product as a CGI string to append to
// the daily ping.
// Access: HKCU read.
bool RLZ_LIB_API GetProductEventsAsCgi(Product product, char* unescaped_cgi,
- size_t unescaped_cgi_size,
- const wchar_t* sid=NULL);
+ size_t unescaped_cgi_size);
// Clear all reported events and recorded stateful events of this product.
// This should be called on complete uninstallation of the product.
// Access: HKCU write.
-bool RLZ_LIB_API ClearAllProductEvents(Product product,
- const wchar_t* sid=NULL);
+bool RLZ_LIB_API ClearAllProductEvents(Product product);
// Clear an event reported by this product. This should be called after a
// successful ping to the RLZ server.
// Access: HKCU write.
bool RLZ_LIB_API ClearProductEvent(Product product, AccessPoint point,
- Event event_id, const wchar_t* sid=NULL);
+ Event event_id);
// RLZ storage functions.
@@ -211,15 +209,14 @@
// RLZ will be the empty string and the function will return false.
// Access: HKCU read.
bool RLZ_LIB_API GetAccessPointRlz(AccessPoint point, char* rlz,
- size_t rlz_size, const wchar_t* sid=NULL);
+ size_t rlz_size);
// Set the RLZ for the access-point. Fails and asserts if called when the access
// point is not set to Google.
// new_rlz should come from a server-response. Client applications should not
// create their own RLZ values.
// Access: HKCU write.
-bool RLZ_LIB_API SetAccessPointRlz(AccessPoint point, const char* new_rlz,
- const wchar_t* sid=NULL);
+bool RLZ_LIB_API SetAccessPointRlz(AccessPoint point, const char* new_rlz);
@@ -270,7 +267,6 @@
// request : The buffer where the function returns the HTTP request.
// request_buffer_size: The size of the request buffer in WCHARs. The buffer
// size (kMaxCgiLength+1) is guaranteed to be enough.
-// sid : The user account SID - needed when running as system.
//
// Access: HKCU read.
bool RLZ_LIB_API FormFinancialPingRequest(Product product,
@@ -281,8 +277,7 @@
const char* product_lang,
bool exclude_machine_id,
char* request,
- size_t request_buffer_size,
- const wchar_t* sid=NULL);
+ size_t request_buffer_size);
// Pings the financial server and returns the HTTP response. This will fail
// if it is too early to ping the server since the last ping.
@@ -296,21 +291,18 @@
// legitimate server responses (any response that is
// bigger should be considered the same way as a general
// network problem).
-// sid : The user account SID - needed when running as system.
//
// Access: HKCU read.
bool RLZ_LIB_API PingFinancialServer(Product product,
const char* request,
char* response,
- size_t response_buffer_size,
- const wchar_t* sid=NULL);
+ size_t response_buffer_size);
// Parses the responses from the financial server and updates product state
// and access point RLZ's in registry.
// Access: HKCU write.
bool RLZ_LIB_API ParseFinancialPingResponse(Product product,
- const char* response,
- const wchar_t* sid=NULL);
+ const char* response);
// Complex helpers built on top of other functions.
@@ -322,14 +314,12 @@
// Access: HKCU read.
bool RLZ_LIB_API GetPingParams(Product product,
const AccessPoint* access_points,
- char* unescaped_cgi, size_t unescaped_cgi_size,
- const wchar_t* sid=NULL);
+ char* unescaped_cgi, size_t unescaped_cgi_size);
// Parses RLZ related ping response information from the server.
// Updates stored RLZ values and clears stored events accordingly.
// Access: HKCU write.
-bool RLZ_LIB_API ParsePingResponse(Product product, const char* response,
- const wchar_t* sid=NULL);
+bool RLZ_LIB_API ParsePingResponse(Product product, const char* response);
// Checks if a ping response is valid - ie. it has a checksum line which
// is the CRC-32 checksum of the message uptil the checksum. If
@@ -359,7 +349,6 @@
// product_lang : The language for the product (used to determine cohort).
// exclude_machine_id : Whether the Machine ID should be explicitly excluded
// based on the products privacy policy.
-// sid : The user account SID - needed when running as system.
//
// Returns true on successful ping and response, false otherwise.
// Access: HKCU write.
@@ -369,8 +358,7 @@
const char* product_brand,
const char* product_id,
const char* product_lang,
- bool exclude_machine_id,
- const wchar_t* sid=NULL);
+ bool exclude_machine_id);
// An alternate implementations of SendFinancialPing with the same behavior,
// except the caller can optionally choose to skip the timing check.
@@ -381,7 +369,6 @@
const char* product_id,
const char* product_lang,
bool exclude_machine_id,
- const wchar_t* sid,
const bool skip_time_check);
@@ -400,8 +387,7 @@
// failed attempts.
// Access: HKCU write.
void RLZ_LIB_API ClearProductState(Product product,
- const AccessPoint* access_points,
- const wchar_t* sid=NULL);
+ const AccessPoint* access_points);
// Gets the unique ID for the machine used for RLZ tracking purposes. This ID
// is derived from the Windows machine SID, and is the string representation of
@@ -413,7 +399,6 @@
// Segment RLZ persistence based on branding information.
-// The RLZ library uses the Windows registry to save persistent information.
// All information for a given product is persisted under keys with the either
// product's name or its access point's name. This assumes that only
// one instance of the product is installed on the machine, and that only one
diff --git a/win/lib/rlz_lib_test.cc b/win/lib/rlz_lib_test.cc
index 13eb07f..12d363e 100644
--- a/win/lib/rlz_lib_test.cc
+++ b/win/lib/rlz_lib_test.cc
@@ -443,7 +443,7 @@
EXPECT_LT(0u, events.find("T4I"));
EXPECT_LT(0u, events.find("T4R"));
- rlz_lib::ClearProductState(rlz_lib::TOOLBAR_NOTIFIER, points, NULL);
+ rlz_lib::ClearProductState(rlz_lib::TOOLBAR_NOTIFIER, points);
EXPECT_TRUE(rlz_lib::GetAccessPointRlz(rlz_lib::IETB_SEARCH_BOX,
cgi, 2048));