OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 5 #ifndef CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
6 #define CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 6 #define CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include <map> | 10 #include <map> |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 static bool Read(const Message* m, void** iter, param_type* r) { | 576 static bool Read(const Message* m, void** iter, param_type* r) { |
577 DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); | 577 DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); |
578 return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); | 578 return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); |
579 } | 579 } |
580 static void Log(const param_type& p, std::wstring* l) { | 580 static void Log(const param_type& p, std::wstring* l) { |
581 l->append(StringPrintf(L"0x%X", p)); | 581 l->append(StringPrintf(L"0x%X", p)); |
582 } | 582 } |
583 }; | 583 }; |
584 | 584 |
585 template <> | 585 template <> |
586 struct ParamTraits<HRGN> { | |
587 typedef HRGN param_type; | |
588 static void Write(Message* m, const param_type& p) { | |
589 int data_size = GetRegionData(p, 0, NULL); | |
590 if (data_size) { | |
591 char* bytes = new char[data_size]; | |
592 GetRegionData(p, data_size, reinterpret_cast<LPRGNDATA>(bytes)); | |
593 m->WriteData(reinterpret_cast<const char*>(bytes), data_size); | |
594 delete [] bytes; | |
595 } else { | |
596 m->WriteData(NULL, 0); | |
597 } | |
598 } | |
599 static bool Read(const Message* m, void** iter, param_type* r) { | |
600 bool res = FALSE; | |
601 const char *data; | |
602 int data_size = 0; | |
603 res = m->ReadData(iter, &data, &data_size); | |
604 if (data_size) { | |
605 *r = ExtCreateRegion(NULL, data_size, | |
606 reinterpret_cast<CONST RGNDATA*>(data)); | |
607 } else { | |
608 res = TRUE; | |
609 *r = CreateRectRgn(0, 0, 0, 0); | |
610 } | |
611 return res; | |
612 } | |
613 static void Log(const param_type& p, std::wstring* l) { | |
614 l->append(StringPrintf(L"0x%X", p)); | |
615 } | |
616 }; | |
617 | |
618 template <> | |
619 struct ParamTraits<HACCEL> { | 586 struct ParamTraits<HACCEL> { |
620 typedef HACCEL param_type; | 587 typedef HACCEL param_type; |
621 static void Write(Message* m, const param_type& p) { | 588 static void Write(Message* m, const param_type& p) { |
622 m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); | 589 m->WriteIntPtr(reinterpret_cast<intptr_t>(p)); |
623 } | 590 } |
624 static bool Read(const Message* m, void** iter, param_type* r) { | 591 static bool Read(const Message* m, void** iter, param_type* r) { |
625 DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); | 592 DCHECK_EQ(sizeof(param_type), sizeof(intptr_t)); |
626 return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); | 593 return m->ReadIntPtr(iter, reinterpret_cast<intptr_t*>(r)); |
627 } | 594 } |
628 }; | 595 }; |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 ReplyParam p(a, b, c, d, e); | 1343 ReplyParam p(a, b, c, d, e); |
1377 WriteParam(reply, p); | 1344 WriteParam(reply, p); |
1378 } | 1345 } |
1379 }; | 1346 }; |
1380 | 1347 |
1381 //----------------------------------------------------------------------------- | 1348 //----------------------------------------------------------------------------- |
1382 | 1349 |
1383 } // namespace IPC | 1350 } // namespace IPC |
1384 | 1351 |
1385 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ | 1352 #endif // CHROME_COMMON_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |