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

Unified Diff: components/arc/common/arc_message_param_traits.cc

Issue 1475583002: Add IPC messages for ARC notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the comments and splitted the patch Created 5 years, 1 month 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
Index: components/arc/common/arc_message_param_traits.cc
diff --git a/components/arc/common/arc_message_param_traits.cc b/components/arc/common/arc_message_param_traits.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2d1cf878861e6b0ad963c7ea2d37861e393277d5
--- /dev/null
+++ b/components/arc/common/arc_message_param_traits.cc
@@ -0,0 +1,66 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Using relative paths since this file is shared between chromium and android.
+#include "arc_message_param_traits.h"
+
+namespace IPC {
+
+// static
+void ParamTraits<arc::ArcNotificationData>::Write(Message* m,
+ const param_type& p) {
+ WriteParam(m, p.key);
+ WriteParam(m, p.message);
+ WriteParam(m, p.title);
+ WriteParam(m, p.icon_mimetype);
+ WriteParam(m, p.icon_data);
+ WriteParam(m, p.priority);
+}
+
+// static
+bool ParamTraits<arc::ArcNotificationData>::Read(const Message* m,
+ base::PickleIterator* iter,
+ param_type* r) {
+ std::string key;
+ std::string message;
+ std::string title;
+ std::string icon_mimetype;
+ std::vector<uint8_t> icon_data;
+ int priority;
+
+ if (!ReadParam(m, iter, &key) ||
+ !ReadParam(m, iter, &message) ||
+ !ReadParam(m, iter, &title) ||
+ !ReadParam(m, iter, &icon_mimetype) ||
+ !ReadParam(m, iter, &icon_data) ||
+ !ReadParam(m, iter, &priority)) {
+ return false;
+ }
+
+ r->key = key;
+
+ // TODO(yoshiki): Support other types.
+ r->type = arc::NOTIFICATION_TYPE_BASIC;
+
+ r->message = message;
+ r->title = title;
+ r->icon_mimetype = icon_mimetype;
+ r->icon_data.swap(icon_data);
+ r->priority = std::min(std::max(-2, priority), 2);
+
+ // TODO(yoshiki): Transfer following parameters from Android.
+ r->timestamp = base::Time::Now();
+ r->progress_current = 0;
+ r->progress_max = 0;
+
+ return true;
+}
+
+// static
+void ParamTraits<arc::ArcNotificationData>::Log(const param_type& p,
+ std::string* l) {
+ l->append(base::StringPrintf("<ArcNotificationData>"));
+}
+
+} // namespace IPC

Powered by Google App Engine
This is Rietveld 408576698