libweave: Add 'reason' to backup command fetch requests

When XMPP channel is active we periodically (once every 30 minutes)
do a command fetch from the server. If XMPP channel doesn't miss any
commands, this fetch of command queue should never return any commands.

To help debug this on the server side, added "reason=just_in_case" to
such "backup" requests so we can identify if ever the server has to
return something for it. In addition, other reasons are added for
different fetch request origins:

- device_start
- regular_pull
- new_command
- just_in_case

BUG: 23321447
Change-Id: I6f2daf30424bc54a7b6d7d06052509e902c7ce1a
Reviewed-on: https://weave-review.googlesource.com/1391
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/libweave/src/notification/notification_parser.cc b/libweave/src/notification/notification_parser.cc
index 25c525f..0a27f1c 100644
--- a/libweave/src/notification/notification_parser.cc
+++ b/libweave/src/notification/notification_parser.cc
@@ -12,14 +12,15 @@
 
 // Processes COMMAND_CREATED notifications.
 bool ParseCommandCreated(const base::DictionaryValue& notification,
-                         NotificationDelegate* delegate) {
+                         NotificationDelegate* delegate,
+                         const std::string& channel_name) {
   const base::DictionaryValue* command = nullptr;
   if (!notification.GetDictionary("command", &command)) {
     LOG(ERROR) << "COMMAND_CREATED notification is missing 'command' property";
     return false;
   }
 
-  delegate->OnCommandCreated(*command);
+  delegate->OnCommandCreated(*command, channel_name);
   return true;
 }
 
@@ -39,7 +40,8 @@
 }  // anonymous namespace
 
 bool ParseNotificationJson(const base::DictionaryValue& notification,
-                           NotificationDelegate* delegate) {
+                           NotificationDelegate* delegate,
+                           const std::string& channel_name) {
   CHECK(delegate);
 
   std::string kind;
@@ -57,7 +59,7 @@
   }
 
   if (type == "COMMAND_CREATED")
-    return ParseCommandCreated(notification, delegate);
+    return ParseCommandCreated(notification, delegate, channel_name);
 
   if (type == "DEVICE_DELETED")
     return ParseDeviceDeleted(notification, delegate);