| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/gamepad_param_traits.h" | 5 #include "content/common/gamepad_param_traits.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 for (size_t i = 0; i < array_size && web_string[i]; ++i) { | 26 for (size_t i = 0; i < array_size && web_string[i]; ++i) { |
| 27 utf16[i] = web_string[i]; | 27 utf16[i] = web_string[i]; |
| 28 } | 28 } |
| 29 log->append(base::UTF16ToUTF8(utf16)); | 29 log->append(base::UTF16ToUTF8(utf16)); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace IPC { | 34 namespace IPC { |
| 35 | 35 |
| 36 void ParamTraits<WebGamepad>::Write( | 36 void ParamTraits<WebGamepad>::Write(base::Pickle* m, const WebGamepad& p) { |
| 37 Message* m, | |
| 38 const WebGamepad& p) { | |
| 39 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(WebGamepad)); | 37 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(WebGamepad)); |
| 40 } | 38 } |
| 41 | 39 |
| 42 bool ParamTraits<WebGamepad>::Read(const Message* m, | 40 bool ParamTraits<WebGamepad>::Read(const base::Pickle* m, |
| 43 base::PickleIterator* iter, | 41 base::PickleIterator* iter, |
| 44 WebGamepad* p) { | 42 WebGamepad* p) { |
| 45 int length; | 43 int length; |
| 46 const char* data; | 44 const char* data; |
| 47 if (!iter->ReadData(&data, &length) || length != sizeof(WebGamepad)) | 45 if (!iter->ReadData(&data, &length) || length != sizeof(WebGamepad)) |
| 48 return false; | 46 return false; |
| 49 memcpy(p, data, sizeof(WebGamepad)); | 47 memcpy(p, data, sizeof(WebGamepad)); |
| 50 | 48 |
| 51 return true; | 49 return true; |
| 52 } | 50 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 72 l->append(", ["); | 70 l->append(", ["); |
| 73 for (size_t i = 0; i < arraysize(p.buttons); ++i) { | 71 for (size_t i = 0; i < arraysize(p.buttons); ++i) { |
| 74 l->append(base::StringPrintf("(%u, %f)%s", | 72 l->append(base::StringPrintf("(%u, %f)%s", |
| 75 p.buttons[i].pressed, p.buttons[i].value, | 73 p.buttons[i].pressed, p.buttons[i].value, |
| 76 i < (arraysize(p.buttons) - 1) ? ", " : "], ")); | 74 i < (arraysize(p.buttons) - 1) ? ", " : "], ")); |
| 77 } | 75 } |
| 78 l->append(")"); | 76 l->append(")"); |
| 79 } | 77 } |
| 80 | 78 |
| 81 } // namespace IPC | 79 } // namespace IPC |
| OLD | NEW |