Respond with QuotaExceededError when IndexedDB has no disk space on open.
[chromium-blink-merge.git] / content / common / input / input_param_traits.h
bloba493c4b86914250f37b9254580257d37b2844410
1 // Copyright 2013 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.
5 // This file defines IPC::ParamTraits<> specializations for several
6 // input-related types that require manual serialiation code.
8 #ifndef CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
9 #define CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "content/common/content_param_traits_macros.h"
13 #include "content/common/input/event_packet.h"
14 #include "content/common/input/input_event.h"
15 #include "content/common/input/web_input_event_payload.h"
17 namespace IPC {
19 // TODO(jdduke): There should be a common copy of this utility somewhere...
20 // Move or remove appropriately.
21 template <class P>
22 struct ParamTraits<scoped_ptr<P> > {
23 typedef scoped_ptr<P> param_type;
24 static void Write(Message* m, const param_type& p) {
25 bool valid = !!p;
26 WriteParam(m, valid);
27 if (valid)
28 WriteParam(m, *p);
30 static bool Read(const Message* m, PickleIterator* iter, param_type* r) {
31 bool valid = false;
32 if (!ReadParam(m, iter, &valid))
33 return false;
35 if (!valid) {
36 r->reset();
37 return true;
40 param_type temp(new P());
41 if (!ReadParam(m, iter, temp.get()))
42 return false;
44 r->swap(temp);
45 return true;
47 static void Log(const param_type& p, std::string* l) {
48 if (p)
49 LogParam(*p, l);
50 else
51 l->append("NULL");
55 template <>
56 struct CONTENT_EXPORT ParamTraits<content::EventPacket> {
57 typedef content::EventPacket param_type;
58 static void Write(Message* m, const param_type& p);
59 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
60 static void Log(const param_type& p, std::string* l);
63 template <>
64 struct CONTENT_EXPORT ParamTraits<content::InputEvent> {
65 typedef content::InputEvent param_type;
66 static void Write(Message* m, const param_type& p);
67 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
68 static void Log(const param_type& p, std::string* l);
71 template <>
72 struct CONTENT_EXPORT ParamTraits<content::WebInputEventPayload> {
73 typedef content::WebInputEventPayload param_type;
74 static void Write(Message* m, const param_type& p);
75 static bool Read(const Message* m, PickleIterator* iter, param_type* r);
76 static void Log(const param_type& p, std::string* l);
79 } // namespace IPC
81 #endif // CONTENT_COMMON_INPUT_INPUT_PARAM_TRAITS_H_