OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 #include "chrome/common/common_param_traits.h" |
| 6 |
| 7 #define IPC_MESSAGE_IMPL |
| 8 #include "chrome/common/dom_storage_messages.h" |
| 9 |
| 10 DOMStorageMsg_Event_Params::DOMStorageMsg_Event_Params() |
| 11 : storage_type(DOM_STORAGE_LOCAL) { |
| 12 } |
| 13 |
| 14 DOMStorageMsg_Event_Params::~DOMStorageMsg_Event_Params() { |
| 15 } |
| 16 |
| 17 namespace IPC { |
| 18 |
| 19 void ParamTraits<DOMStorageMsg_Event_Params>::Write(Message* m, |
| 20 const param_type& p) { |
| 21 WriteParam(m, p.key); |
| 22 WriteParam(m, p.old_value); |
| 23 WriteParam(m, p.new_value); |
| 24 WriteParam(m, p.origin); |
| 25 WriteParam(m, p.url); |
| 26 WriteParam(m, p.storage_type); |
| 27 } |
| 28 |
| 29 bool ParamTraits<DOMStorageMsg_Event_Params>::Read(const Message* m, |
| 30 void** iter, |
| 31 param_type* p) { |
| 32 return |
| 33 ReadParam(m, iter, &p->key) && |
| 34 ReadParam(m, iter, &p->old_value) && |
| 35 ReadParam(m, iter, &p->new_value) && |
| 36 ReadParam(m, iter, &p->origin) && |
| 37 ReadParam(m, iter, &p->url) && |
| 38 ReadParam(m, iter, &p->storage_type); |
| 39 } |
| 40 |
| 41 void ParamTraits<DOMStorageMsg_Event_Params>::Log(const param_type& p, |
| 42 std::string* l) { |
| 43 l->append("("); |
| 44 LogParam(p.key, l); |
| 45 l->append(", "); |
| 46 LogParam(p.old_value, l); |
| 47 l->append(", "); |
| 48 LogParam(p.new_value, l); |
| 49 l->append(", "); |
| 50 LogParam(p.origin, l); |
| 51 l->append(", "); |
| 52 LogParam(p.url, l); |
| 53 l->append(", "); |
| 54 LogParam(p.storage_type, l); |
| 55 l->append(")"); |
| 56 } |
| 57 |
| 58 void ParamTraits<DOMStorageType>::Write(Message* m, const param_type& p) { |
| 59 m->WriteInt(p); |
| 60 } |
| 61 |
| 62 bool ParamTraits<DOMStorageType>::Read(const Message* m, |
| 63 void** iter, |
| 64 param_type* p) { |
| 65 int type; |
| 66 if (!m->ReadInt(iter, &type)) |
| 67 return false; |
| 68 *p = static_cast<param_type>(type); |
| 69 return true; |
| 70 } |
| 71 |
| 72 void ParamTraits<DOMStorageType>::Log(const param_type& p, std::string* l) { |
| 73 std::string control; |
| 74 switch (p) { |
| 75 case DOM_STORAGE_LOCAL: |
| 76 control = "DOM_STORAGE_LOCAL"; |
| 77 break; |
| 78 case DOM_STORAGE_SESSION: |
| 79 control = "DOM_STORAGE_SESSION"; |
| 80 break; |
| 81 default: |
| 82 NOTIMPLEMENTED(); |
| 83 control = "UNKNOWN"; |
| 84 break; |
| 85 } |
| 86 LogParam(control, l); |
| 87 } |
| 88 |
| 89 void ParamTraits<WebKit::WebStorageArea::Result>::Write(Message* m, |
| 90 const param_type& p) { |
| 91 m->WriteInt(p); |
| 92 } |
| 93 |
| 94 bool ParamTraits<WebKit::WebStorageArea::Result>::Read(const Message* m, |
| 95 void** iter, |
| 96 param_type* p) { |
| 97 int type; |
| 98 if (!m->ReadInt(iter, &type)) |
| 99 return false; |
| 100 *p = static_cast<param_type>(type); |
| 101 return true; |
| 102 } |
| 103 |
| 104 void ParamTraits<WebKit::WebStorageArea::Result>::Log(const param_type& p, |
| 105 std::string* l) { |
| 106 std::string control; |
| 107 switch (p) { |
| 108 case WebKit::WebStorageArea::ResultOK: |
| 109 control = "WebKit::WebStorageArea::ResultOK"; |
| 110 break; |
| 111 case WebKit::WebStorageArea::ResultBlockedByQuota: |
| 112 control = "WebKit::WebStorageArea::ResultBlockedByQuota"; |
| 113 break; |
| 114 case WebKit::WebStorageArea::ResultBlockedByPolicy: |
| 115 control = "WebKit::WebStorageArea::ResultBlockedByPolicy"; |
| 116 break; |
| 117 default: |
| 118 NOTIMPLEMENTED(); |
| 119 control = "UNKNOWN"; |
| 120 break; |
| 121 } |
| 122 LogParam(control, l); |
| 123 } |
| 124 |
| 125 } // namespace IPC |
OLD | NEW |