OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Using relative paths since this file is shared between chromium and android. |
| 6 #include "arc_message_param_traits.h" |
| 7 |
| 8 namespace IPC { |
| 9 |
| 10 // static |
| 11 void ParamTraits<arc::ArcNotificationData>::Write(Message* m, |
| 12 const param_type& p) { |
| 13 WriteParam(m, p.key); |
| 14 WriteParam(m, p.message); |
| 15 WriteParam(m, p.title); |
| 16 WriteParam(m, p.icon_mimetype); |
| 17 WriteParam(m, p.icon_data); |
| 18 WriteParam(m, p.priority); |
| 19 } |
| 20 |
| 21 // static |
| 22 bool ParamTraits<arc::ArcNotificationData>::Read(const Message* m, |
| 23 base::PickleIterator* iter, |
| 24 param_type* r) { |
| 25 std::string key; |
| 26 std::string message; |
| 27 std::string title; |
| 28 std::string icon_mimetype; |
| 29 std::vector<uint8_t> icon_data; |
| 30 int priority; |
| 31 |
| 32 if (!ReadParam(m, iter, &key) || |
| 33 !ReadParam(m, iter, &message) || |
| 34 !ReadParam(m, iter, &title) || |
| 35 !ReadParam(m, iter, &icon_mimetype) || |
| 36 !ReadParam(m, iter, &icon_data) || |
| 37 !ReadParam(m, iter, &priority)) { |
| 38 return false; |
| 39 } |
| 40 |
| 41 r->key = key; |
| 42 |
| 43 // TODO(yoshiki): Support other types. |
| 44 r->type = arc::NOTIFICATION_TYPE_BASIC; |
| 45 |
| 46 r->message = message; |
| 47 r->title = title; |
| 48 r->icon_mimetype = icon_mimetype; |
| 49 r->icon_data.swap(icon_data); |
| 50 r->priority = std::min(std::max(-2, priority), 2); |
| 51 |
| 52 // TODO(yoshiki): Transfer following parameters from Android. |
| 53 r->timestamp = base::Time::Now(); |
| 54 r->progress_current = 0; |
| 55 r->progress_max = 0; |
| 56 |
| 57 return true; |
| 58 } |
| 59 |
| 60 // static |
| 61 void ParamTraits<arc::ArcNotificationData>::Log(const param_type& p, |
| 62 std::string* l) { |
| 63 l->append(base::StringPrintf("<ArcNotificationData>")); |
| 64 } |
| 65 |
| 66 } // namespace IPC |
OLD | NEW |