utility_messages.h revision 21d179b334e59e9a3bfcaed4c4430bef1bc5759d
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#ifndef CHROME_COMMON_UTILITY_MESSAGES_H_
6#define CHROME_COMMON_UTILITY_MESSAGES_H_
7#pragma once
8
9#include <string>
10
11#include "base/basictypes.h"
12#include "chrome/common/common_param_traits.h"
13#include "chrome/common/extensions/update_manifest.h"
14#include "chrome/common/indexed_db_param_traits.h"
15#include "ipc/ipc_message_utils.h"
16
17namespace IPC {
18
19// Traits for UpdateManifest::Result.
20template <>
21struct ParamTraits<UpdateManifest::Result> {
22  typedef UpdateManifest::Result param_type;
23  static void Write(Message* m, const param_type& p) {
24    WriteParam(m, p.extension_id);
25    WriteParam(m, p.version);
26    WriteParam(m, p.browser_min_version);
27    WriteParam(m, p.package_hash);
28    WriteParam(m, p.crx_url);
29  }
30  static bool Read(const Message* m, void** iter, param_type* p) {
31    return ReadParam(m, iter, &p->extension_id) &&
32           ReadParam(m, iter, &p->version) &&
33           ReadParam(m, iter, &p->browser_min_version) &&
34           ReadParam(m, iter, &p->package_hash) &&
35           ReadParam(m, iter, &p->crx_url);
36  }
37  static void Log(const param_type& p, std::string* l) {
38    l->append("(");
39    LogParam(p.extension_id, l);
40    l->append(", ");
41    LogParam(p.version, l);
42    l->append(", ");
43    LogParam(p.browser_min_version, l);
44    l->append(", ");
45    LogParam(p.package_hash, l);
46    l->append(", ");
47    LogParam(p.crx_url, l);
48    l->append(")");
49  }
50};
51
52template<>
53struct ParamTraits<UpdateManifest::Results> {
54  typedef UpdateManifest::Results param_type;
55  static void Write(Message* m, const param_type& p) {
56    WriteParam(m, p.list);
57    WriteParam(m, p.daystart_elapsed_seconds);
58  }
59  static bool Read(const Message* m, void** iter, param_type* p) {
60    return ReadParam(m, iter, &p->list) &&
61           ReadParam(m, iter, &p->daystart_elapsed_seconds);
62  }
63  static void Log(const param_type& p, std::string* l) {
64    l->append("(");
65    LogParam(p.list, l);
66    l->append(", ");
67    LogParam(p.daystart_elapsed_seconds, l);
68    l->append(")");
69  }
70};
71
72}  // namespace IPC
73
74#include "chrome/common/utility_messages_internal.h"
75
76#endif  // CHROME_COMMON_UTILITY_MESSAGES_H_
77