Commit 32d9089d authored by akalin@chromium.org's avatar akalin@chromium.org

Clean up logging for push_notifications_*.cc

Make Notification::ToString() base64 the data member (since it can hold
binary data).

Convert VLOGs to DVLOGs for push_notifications_*.cc.

BUG=141692


Review URL: https://chromiumcodereview.appspot.com/10828264

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151367 0039d316-1c4b-4281-b951-d872f2087c98
parent 50db9b0e
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
#include <cstddef> #include <cstddef>
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/values.h"
namespace notifier { namespace notifier {
Subscription::Subscription() {} Subscription::Subscription() {}
...@@ -60,7 +65,14 @@ bool Notification::Equals(const Notification& other) const { ...@@ -60,7 +65,14 @@ bool Notification::Equals(const Notification& other) const {
} }
std::string Notification::ToString() const { std::string Notification::ToString() const {
return "{ channel: \"" + channel + "\", data: \"" + data + "\" }"; // Put into a DictionaryValue and convert to a string; this gives a
// nice hex-encoding of |data|, which may be a binary string.
DictionaryValue dict;
dict.SetString("channel", channel);
dict.SetString("data", data);
std::string str;
base::JSONWriter::Write(&dict, &str);
return str;
} }
} // namespace notifier } // namespace notifier
...@@ -38,7 +38,7 @@ int PushNotificationsListenTask::ProcessResponse() { ...@@ -38,7 +38,7 @@ int PushNotificationsListenTask::ProcessResponse() {
return STATE_BLOCKED; return STATE_BLOCKED;
} }
VLOG(1) << "Received stanza " << XmlElementToString(*stanza); DVLOG(1) << "Received stanza " << XmlElementToString(*stanza);
// The push notifications service does not need us to acknowledge receipt of // The push notifications service does not need us to acknowledge receipt of
// the notification to the buzz server. // the notification to the buzz server.
...@@ -72,7 +72,7 @@ int PushNotificationsListenTask::ProcessResponse() { ...@@ -72,7 +72,7 @@ int PushNotificationsListenTask::ProcessResponse() {
LOG(WARNING) << "No data element found in push element " LOG(WARNING) << "No data element found in push element "
<< XmlElementToString(*push_element); << XmlElementToString(*push_element);
} }
VLOG(1) << "Received notification " << notification.ToString(); DVLOG(1) << "Received notification " << notification.ToString();
delegate_->OnNotificationReceived(notification); delegate_->OnNotificationReceived(notification);
} else { } else {
LOG(WARNING) << "No push element found in stanza " LOG(WARNING) << "No push element found in stanza "
......
...@@ -29,8 +29,8 @@ int PushNotificationsSendUpdateTask::ProcessStart() { ...@@ -29,8 +29,8 @@ int PushNotificationsSendUpdateTask::ProcessStart() {
scoped_ptr<buzz::XmlElement> stanza( scoped_ptr<buzz::XmlElement> stanza(
MakeUpdateMessage(notification_, MakeUpdateMessage(notification_,
GetClient()->jid().BareJid())); GetClient()->jid().BareJid()));
VLOG(1) << "Sending notification " << notification_.ToString() DVLOG(1) << "Sending notification " << notification_.ToString()
<< " as stanza " << XmlElementToString(*stanza); << " as stanza " << XmlElementToString(*stanza);
if (SendStanza(stanza.get()) != buzz::XMPP_RETURN_OK) { if (SendStanza(stanza.get()) != buzz::XMPP_RETURN_OK) {
LOG(WARNING) << "Could not send stanza " << XmlElementToString(*stanza); LOG(WARNING) << "Could not send stanza " << XmlElementToString(*stanza);
} }
......
...@@ -39,12 +39,12 @@ bool PushNotificationsSubscribeTask::HandleStanza( ...@@ -39,12 +39,12 @@ bool PushNotificationsSubscribeTask::HandleStanza(
} }
int PushNotificationsSubscribeTask::ProcessStart() { int PushNotificationsSubscribeTask::ProcessStart() {
VLOG(1) << "Push notifications: Subscription task started."; DVLOG(1) << "Push notifications: Subscription task started.";
scoped_ptr<buzz::XmlElement> iq_stanza( scoped_ptr<buzz::XmlElement> iq_stanza(
MakeSubscriptionMessage(subscriptions_, GetClient()->jid(), MakeSubscriptionMessage(subscriptions_, GetClient()->jid(),
task_id())); task_id()));
std::string stanza_str = XmlElementToString(*iq_stanza.get()); std::string stanza_str = XmlElementToString(*iq_stanza.get());
VLOG(1) << "Push notifications: Subscription stanza: " DVLOG(1) << "Push notifications: Subscription stanza: "
<< XmlElementToString(*iq_stanza.get()); << XmlElementToString(*iq_stanza.get());
if (SendStanza(iq_stanza.get()) != buzz::XMPP_RETURN_OK) { if (SendStanza(iq_stanza.get()) != buzz::XMPP_RETURN_OK) {
...@@ -56,14 +56,14 @@ int PushNotificationsSubscribeTask::ProcessStart() { ...@@ -56,14 +56,14 @@ int PushNotificationsSubscribeTask::ProcessStart() {
} }
int PushNotificationsSubscribeTask::ProcessResponse() { int PushNotificationsSubscribeTask::ProcessResponse() {
VLOG(1) << "Push notifications: Subscription response received."; DVLOG(1) << "Push notifications: Subscription response received.";
const buzz::XmlElement* stanza = NextStanza(); const buzz::XmlElement* stanza = NextStanza();
if (stanza == NULL) { if (stanza == NULL) {
return STATE_BLOCKED; return STATE_BLOCKED;
} }
std::string stanza_str = XmlElementToString(*stanza); std::string stanza_str = XmlElementToString(*stanza);
VLOG(1) << "Push notifications: Subscription response: " DVLOG(1) << "Push notifications: Subscription response: "
<< XmlElementToString(*stanza); << XmlElementToString(*stanza);
// We've receieved a response to our subscription request. // We've receieved a response to our subscription request.
if (stanza->HasAttr(buzz::QN_TYPE) && if (stanza->HasAttr(buzz::QN_TYPE) &&
stanza->Attr(buzz::QN_TYPE) == buzz::STR_RESULT) { stanza->Attr(buzz::QN_TYPE) == buzz::STR_RESULT) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment