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

Unified Diff: chromeos_login.cc

Issue 6772019: [cros] Change Store/RetrievePolicy to use a GArray (Closed) Base URL: http://git.chromium.org/git/cros.git@master
Patch Set: DCHECK and delete Created 9 years, 9 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 | « chromeos_cros_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos_login.cc
diff --git a/chromeos_login.cc b/chromeos_login.cc
index 201eac93a2391ae08164dc2aa6f307bef1bc4401..a366b0969904c5799401db7695bde72731f3ed5f 100644
--- a/chromeos_login.cc
+++ b/chromeos_login.cc
@@ -229,6 +229,8 @@ bool ChromeOSRetrievePropertySafe(const char* name, Property** OUT_property) {
if (!ChromeOSLoginHelpers::RetrievePropertyHelper(name, &value, &sig))
return false;
*OUT_property = ChromeOSLoginHelpers::CreateProperty(name, value, sig);
+ g_array_free(sig, false);
+ g_free(value);
return true;
}
@@ -463,18 +465,22 @@ void RetrievePolicyNotify(DBusGProxy* gproxy,
reinterpret_cast<CallbackData<RetrievePolicyCallback>*>(user_data);
DCHECK(cb_data);
glib::ScopedError error;
- gchar* policy_blob = NULL;
+ GArray* policy_blob = NULL;
if (!::dbus_g_proxy_end_call(gproxy,
call_id,
&Resetter(&error).lvalue(),
- G_TYPE_STRING, &policy_blob,
+ DBUS_TYPE_G_UCHAR_ARRAY, &policy_blob,
G_TYPE_INVALID)) {
LOG(ERROR) << login_manager::kSessionManagerRetrievePolicy
<< " failed: " << SCOPED_SAFE_MESSAGE(error);
}
- cb_data->callback(cb_data->object, policy_blob);
- if (policy_blob)
- g_free(policy_blob);
+ if (policy_blob) {
+ std::string policy(policy_blob->data, policy_blob->len);
+ cb_data->callback(cb_data->object, policy.c_str());
+ g_array_free(policy_blob, TRUE);
+ } else {
+ cb_data->callback(cb_data->object, NULL);
+ }
}
extern "C"
@@ -519,22 +525,27 @@ extern "C"
void ChromeOSStorePolicy(const char* prop,
StorePolicyCallback callback,
void* delegate) {
+ DCHECK(prop);
DCHECK(delegate);
CallbackData<StorePolicyCallback>* cb_data =
new CallbackData<StorePolicyCallback>(callback, delegate);
+ GArray* policy = g_array_new(FALSE, FALSE, 1);
+ policy->data = const_cast<gchar*>(prop); // This just gets copied below.
+ policy->len = strlen(prop);
DBusGProxyCall* call_id =
::dbus_g_proxy_begin_call(cb_data->proxy.gproxy(),
login_manager::kSessionManagerStorePolicy,
&StorePolicyNotify,
cb_data,
&DeleteCallbackData<StorePolicyCallback>,
- G_TYPE_STRING, prop,
+ DBUS_TYPE_G_UCHAR_ARRAY, policy,
G_TYPE_INVALID);
if (!call_id) {
LOG(ERROR) << "StorePolicy async call failed";
delete cb_data;
callback(delegate, false);
}
+ g_array_free(policy, FALSE);
}
} // namespace chromeos
« no previous file with comments | « chromeos_cros_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698