summaryrefslogtreecommitdiffstats
path: root/chrome/common/icon_messages.cc
blob: 7648c1471e83214b32968a5bdb2382478256d812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2011 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.

#include "chrome/common/icon_messages.h"

#include "content/common/common_param_traits.h"

FaviconURL::FaviconURL()
  : icon_type(INVALID_ICON) {
}

FaviconURL::FaviconURL(const GURL& url, IconType type)
  : icon_url(url),
    icon_type(type) {
}

FaviconURL::~FaviconURL() {
}

namespace IPC {

// static
void ParamTraits<IconType>::Write(Message* m, const param_type& p) {
  m->WriteInt(p);
}

// static
bool ParamTraits<IconType>::Read(const Message* m, void** iter, param_type* p) {
  int type;
  if (!m->ReadInt(iter, &type))
    return false;
  *p = static_cast<IconType>(type);
  return true;
}

// static
void ParamTraits<IconType>::Log(const param_type& p, std::string* l) {
  l->append("IconType");
}

// static
void ParamTraits<FaviconURL>::Write(Message* m, const param_type& p) {
  WriteParam(m, p.icon_url);
  WriteParam(m, p.icon_type);
}

// static
bool ParamTraits<FaviconURL>::Read(const Message* m,
                                   void** iter,
                                   param_type* p) {
  return ReadParam(m, iter, &p->icon_url) && ReadParam(m, iter, &p->icon_type);
}

// static
void ParamTraits<FaviconURL>::Log(const param_type& p, std::string* l) {
  l->append("<FaviconURL>");
}

}  // namespace IPC