Changeset 103569 in vbox
- Timestamp:
- Feb 26, 2024 1:11:52 PM (11 months ago)
- Location:
- trunk/src/libs/xpcom18a4
- Files:
-
- 1 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/Makefile.kmk
r103562 r103569 292 292 IPCD-HEADERS_SOURCES = \ 293 293 ipc/ipcd/client/public/ipcCID.h \ 294 ipc/ipcd/util/public/ipcMessageWriter.h \295 294 ipc/ipcd/client/public/ipcdclient.h 296 295 … … 813 812 ipc/ipcd/client/src/ipcModuleFactory.cpp \ 814 813 ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp \ 815 \816 ipc/ipcd/util/src/ipcMessageWriter.cpp \817 814 \ 818 815 ipc/ipcd/client/src/ipcConnectionUnix.cpp -
trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
r103563 r103569 38 38 #define LOG_GROUP LOG_GROUP_IPC 39 39 #include "ipcDConnectService.h" 40 #include "ipcMessageWriter.h"41 #include "ipcMsgReader.h"42 40 43 41 #include "nsIServiceManagerUtils.h" … … 321 319 322 320 static nsresult 323 SerializeParam( ipcMessageWriter &writer, const nsXPTType &t, const nsXPTCMiniVariant &v)321 SerializeParam(PIPCMSGWRITER pMsgWriter, const nsXPTType &t, const nsXPTCMiniVariant &v) 324 322 { 325 323 switch (t.TagPart()) … … 327 325 case nsXPTType::T_I8: 328 326 case nsXPTType::T_U8: 329 writer.PutInt8(v.val.u8);327 IPCMsgWriterPutU8(pMsgWriter, v.val.u8); 330 328 break; 331 329 332 330 case nsXPTType::T_I16: 333 331 case nsXPTType::T_U16: 334 writer.PutInt16(v.val.u16);332 IPCMsgWriterPutU16(pMsgWriter, v.val.u16); 335 333 break; 336 334 337 335 case nsXPTType::T_I32: 338 336 case nsXPTType::T_U32: 339 writer.PutInt32(v.val.u32);337 IPCMsgWriterPutU32(pMsgWriter, v.val.u32); 340 338 break; 341 339 342 340 case nsXPTType::T_I64: 343 341 case nsXPTType::T_U64: 344 writer.PutBytes(&v.val.u64, sizeof(PRUint64));342 IPCMsgWriterPutU64(pMsgWriter, v.val.u64); 345 343 break; 346 344 347 345 case nsXPTType::T_FLOAT: 348 writer.PutBytes(&v.val.f, sizeof(float));346 IPCMsgWriterPutBytes(pMsgWriter, &v.val.f, sizeof(float)); 349 347 break; 350 348 351 349 case nsXPTType::T_DOUBLE: 352 writer.PutBytes(&v.val.d, sizeof(double));350 IPCMsgWriterPutBytes(pMsgWriter, &v.val.d, sizeof(double)); 353 351 break; 354 352 355 353 case nsXPTType::T_BOOL: 356 writer.PutBytes(&v.val.b, sizeof(PRBool));354 IPCMsgWriterPutBytes(pMsgWriter, &v.val.b, sizeof(PRBool)); 357 355 break; 358 356 359 357 case nsXPTType::T_CHAR: 360 writer.PutBytes(&v.val.c, sizeof(char));358 IPCMsgWriterPutBytes(pMsgWriter, &v.val.c, sizeof(char)); 361 359 break; 362 360 363 361 case nsXPTType::T_WCHAR: 364 writer.PutBytes(&v.val.wc, sizeof(PRUnichar));362 IPCMsgWriterPutBytes(pMsgWriter, &v.val.wc, sizeof(PRUnichar)); 365 363 break; 366 364 … … 368 366 { 369 367 AssertReturn(v.val.p, NS_ERROR_INVALID_POINTER); 370 writer.PutBytes(v.val.p, sizeof(nsID));368 IPCMsgWriterPutBytes(pMsgWriter, v.val.p, sizeof(nsID)); 371 369 } 372 370 break; … … 377 375 { 378 376 int len = strlen((const char *) v.val.p); 379 writer.PutInt32(len);380 writer.PutBytes(v.val.p, len);377 IPCMsgWriterPutU32(pMsgWriter, len); 378 IPCMsgWriterPutBytes(pMsgWriter, v.val.p, len); 381 379 } 382 380 else 383 381 { 384 382 // put -1 to indicate null string 385 writer.PutInt32((PRUint32) -1);383 IPCMsgWriterPutU32(pMsgWriter, (PRUint32) -1); 386 384 } 387 385 } … … 393 391 { 394 392 int len = 2 * nsCRT::strlen((const PRUnichar *) v.val.p); 395 writer.PutInt32(len);396 writer.PutBytes(v.val.p, len);393 IPCMsgWriterPutU32(pMsgWriter, len); 394 IPCMsgWriterPutBytes(pMsgWriter, v.val.p, len); 397 395 } 398 396 else 399 397 { 400 398 // put -1 to indicate null string 401 writer.PutInt32((PRUint32) -1);399 IPCMsgWriterPutU32(pMsgWriter, (PRUint32) -1); 402 400 } 403 401 } … … 418 416 const PRUnichar *data = str->BeginReading(begin).get(); 419 417 420 writer.PutInt32(len);421 writer.PutBytes(data, len);418 IPCMsgWriterPutU32(pMsgWriter, len); 419 IPCMsgWriterPutBytes(pMsgWriter, data, len); 422 420 } 423 421 break; … … 432 430 const char *data = str->BeginReading(begin).get(); 433 431 434 writer.PutInt32(len);435 writer.PutBytes(data, len);432 IPCMsgWriterPutU32(pMsgWriter, len); 433 IPCMsgWriterPutBytes(pMsgWriter, data, len); 436 434 } 437 435 break; … … 996 994 static nsresult 997 995 SerializeArrayParam(ipcDConnectService *dConnect, 998 ipcMessageWriter &writer, PRUint32 peerID,996 PIPCMSGWRITER pMsgWriter, PRUint32 peerID, 999 997 nsIInterfaceInfo *iinfo, uint16 methodIndex, 1000 998 const nsXPTMethodInfo &methodInfo, … … 1006 1004 { 1007 1005 // put 0 to indicate null array 1008 writer.PutInt8(0);1006 IPCMsgWriterPutU8(pMsgWriter, 0); 1009 1007 return NS_OK; 1010 1008 } 1011 1009 1012 1010 // put 1 to indicate non-null array 1013 writer.PutInt8(1);1011 IPCMsgWriterPutU8(pMsgWriter, 1); 1014 1012 1015 1013 PRUint32 size = 0; … … 1032 1030 { 1033 1031 // this is a simple arithmetic type, write the whole array at once 1034 writer.PutBytes(array, length * elemSize);1032 IPCMsgWriterPutBytes(pMsgWriter, array, length * elemSize); 1035 1033 return NS_OK; 1036 1034 } … … 1050 1048 iid); 1051 1049 if (NS_SUCCEEDED(rv)) 1052 rv = dConnect->SerializeInterfaceParam( writer, peerID, iid,1050 rv = dConnect->SerializeInterfaceParam(pMsgWriter, peerID, iid, 1053 1051 (nsISupports *) v.val.p, 1054 1052 wrappers); 1055 1053 } 1056 1054 else 1057 rv = SerializeParam( writer, elemType, v);1055 rv = SerializeParam(pMsgWriter, elemType, v); 1058 1056 1059 1057 if (NS_FAILED(rv)) … … 1631 1629 1632 1630 nsresult 1633 ipcDConnectService::SerializeInterfaceParam( ipcMessageWriter &writer,1631 ipcDConnectService::SerializeInterfaceParam(PIPCMSGWRITER pMsgWriter, 1634 1632 PRUint32 peer, const nsID &iid, 1635 1633 nsISupports *obj, … … 1661 1659 // write null address 1662 1660 DConAddr nullobj = 0; 1663 writer.PutBytes(&nullobj, sizeof(nullobj));1661 IPCMsgWriterPutBytes(pMsgWriter, &nullobj, sizeof(nullobj)); 1664 1662 } 1665 1663 else … … 1670 1668 { 1671 1669 DConAddr p = stub->Instance(); 1672 writer.PutBytes(&p, sizeof(p));1670 IPCMsgWriterPutBytes(pMsgWriter, &p, sizeof(p)); 1673 1671 } 1674 1672 else … … 1721 1719 NS_ASSERTION((bits & PTRBITS_REMOTE_BIT) == 0, "remote bit wrong)"); 1722 1720 bits |= PTRBITS_REMOTE_BIT; 1723 writer.PutBytes(&bits, sizeof(bits));1721 IPCMsgWriterPutBytes(pMsgWriter, &bits, sizeof(bits)); 1724 1722 } 1725 1723 NS_IF_RELEASE(stub); … … 1952 1950 1953 1951 nsresult 1954 ipcDConnectService::SerializeException( ipcMessageWriter &writer,1952 ipcDConnectService::SerializeException(PIPCMSGWRITER pMsgWriter, 1955 1953 PRUint32 peer, nsIException *xcpt, 1956 1954 nsVoidArray &wrappers) … … 1976 1974 // see ipcDConnectService::DeserializeException()! 1977 1975 PtrBits bits = 0; 1978 writer.PutBytes(&bits, sizeof(bits));1976 IPCMsgWriterPutBytes(pMsgWriter, &bits, sizeof(bits)); 1979 1977 #else 1980 writer.PutBytes(&xcpt, sizeof(xcpt));1978 IPCMsgWriterPutBytes(pMsgWriter, &xcpt, sizeof(xcpt)); 1981 1979 #endif 1982 1980 } … … 1989 1987 // send the wrapper instance back to the peer 1990 1988 DConAddr p = stub->Stub()->Instance(); 1991 writer.PutBytes(&p, sizeof(p));1989 IPCMsgWriterPutBytes(pMsgWriter, &p, sizeof(p)); 1992 1990 } 1993 1991 else … … 2039 2037 // to the remote party that this is a remote instance wrapper. 2040 2038 PtrBits bits = ((PtrBits)(uintptr_t) wrapper) | PTRBITS_REMOTE_BIT; 2041 writer.PutBytes(&bits, sizeof(bits));2039 IPCMsgWriterPutBytes(pMsgWriter, &bits, sizeof(bits)); 2042 2040 2043 2041 // we want to cache fields to minimize the number of IPC calls when … … 2063 2061 nsACString::const_iterator begin; 2064 2062 const char *data = str.BeginReading(begin).get(); 2065 writer.PutInt32(len);2066 writer.PutBytes(data, len);2063 IPCMsgWriterPutU32(pMsgWriter, len); 2064 IPCMsgWriterPutBytes(pMsgWriter, data, len); 2067 2065 } 2068 2066 else 2069 writer.PutInt32(0);2067 IPCMsgWriterPutU32(pMsgWriter, 0); 2070 2068 2071 2069 // result 2072 2070 nsresult res = 0; 2073 2071 xcpt->GetResult(&res); 2074 writer.PutInt32(res);2072 IPCMsgWriterPutU32(pMsgWriter, res); 2075 2073 2076 2074 // name … … 2081 2079 nsACString::const_iterator begin; 2082 2080 const char *data = str.BeginReading(begin).get(); 2083 writer.PutInt32(len);2084 writer.PutBytes(data, len);2081 IPCMsgWriterPutU32(pMsgWriter, len); 2082 IPCMsgWriterPutBytes(pMsgWriter, data, len); 2085 2083 } 2086 2084 else 2087 writer.PutInt32(0);2085 IPCMsgWriterPutU32(pMsgWriter, 0); 2088 2086 2089 2087 // filename … … 2094 2092 nsACString::const_iterator begin; 2095 2093 const char *data = str.BeginReading(begin).get(); 2096 writer.PutInt32(len);2097 writer.PutBytes(data, len);2094 IPCMsgWriterPutU32(pMsgWriter, len); 2095 IPCMsgWriterPutBytes(pMsgWriter, data, len); 2098 2096 } 2099 2097 else 2100 writer.PutInt32(0);2098 IPCMsgWriterPutU32(pMsgWriter, 0); 2101 2099 2102 2100 // lineNumber 2103 2101 num = 0; 2104 2102 xcpt->GetLineNumber(&num); 2105 writer.PutInt32(num);2103 IPCMsgWriterPutU32(pMsgWriter, num); 2106 2104 2107 2105 // columnNumber 2108 2106 num = 0; 2109 2107 xcpt->GetColumnNumber(&num); 2110 writer.PutInt32(num);2111 2112 return writer.HasError() ? NS_ERROR_OUT_OF_MEMORY : NS_OK;2108 IPCMsgWriterPutU32(pMsgWriter, num); 2109 2110 return IPCMsgWriterHasError(pMsgWriter) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; 2113 2111 } 2114 2112 … … 2526 2524 #endif 2527 2525 2528 2529 ipcMessageWriter writer(16 * paramCount);2526 IPCMSGWRITER MsgWriter; 2527 IPCMsgWriterInit(&MsgWriter, 16 * paramCount); 2530 2528 2531 2529 // INVOKE message header … … 2540 2538 Log((" request-index=%d\n", (PRUint32) invoke.request_index)); 2541 2539 2542 writer.PutBytes(&invoke, sizeof(invoke));2540 IPCMsgWriterPutBytes(&MsgWriter, &invoke, sizeof(invoke)); 2543 2541 2544 2542 // list of wrappers that get created during parameter serialization. if we … … 2560 2558 aMethodIndex, aParams, PR_FALSE, iid); 2561 2559 if (NS_SUCCEEDED(rv)) 2562 rv = dConnect->SerializeInterfaceParam( writer, mPeerID, iid,2560 rv = dConnect->SerializeInterfaceParam(&MsgWriter, mPeerID, iid, 2563 2561 (nsISupports *) aParams[i].val.p, 2564 2562 wrappers); 2565 2563 } 2566 2564 else 2567 rv = SerializeParam( writer, type, aParams[i]);2565 rv = SerializeParam(&MsgWriter, type, aParams[i]); 2568 2566 2569 2567 AssertMsgBreak(NS_SUCCEEDED(rv), ("i=%d rv=%#x\n", i, rv)); … … 2582 2580 // INVOKE message wasn't sent; clean up wrappers 2583 2581 dConnect->ReleaseWrappers(wrappers, mPeerID); 2582 IPCMsgWriterCleanup(&MsgWriter); 2584 2583 return rv; 2585 2584 } … … 2595 2594 paramInfo.IsIn() && !paramInfo.IsDipper()) 2596 2595 { 2597 rv = SerializeArrayParam(dConnect, writer, mPeerID, mIInfo, aMethodIndex,2596 rv = SerializeArrayParam(dConnect, &MsgWriter, mPeerID, mIInfo, aMethodIndex, 2598 2597 *aInfo, aParams, PR_FALSE, paramInfo, 2599 2598 aParams[i].val.p, wrappers); … … 2602 2601 // INVOKE message wasn't sent; clean up wrappers 2603 2602 dConnect->ReleaseWrappers(wrappers, mPeerID); 2603 IPCMsgWriterCleanup(&MsgWriter); 2604 2604 return rv; 2605 2605 } … … 2612 2612 2613 2613 rv = IPC_SendMessage(mPeerID, kDConnectTargetID, 2614 writer.GetBuffer(), 2615 writer.GetSize()); 2614 IPCMsgWriterGetBuf(&MsgWriter), 2615 IPCMsgWriterGetSize(&MsgWriter)); 2616 IPCMsgWriterCleanup(&MsgWriter); 2617 2616 2618 Log(("DConnectStub::CallMethod: IPC_SendMessage()=%08X\n", rv)); 2617 2619 if (NS_FAILED(rv)) … … 3584 3586 } 3585 3587 3586 ipcMessageWriter writer(64); 3588 IPCMSGWRITER MsgWriter; 3589 IPCMsgWriterInit(&MsgWriter, 64 /*cbInitial*/); 3587 3590 3588 3591 DConnectSetupReply msg; … … 3597 3600 msg.flags |= DCON_OP_FLAGS_REPLY_EXCEPTION; 3598 3601 3599 writer.PutBytes(&msg, sizeof(msg));3602 IPCMsgWriterPutBytes(&MsgWriter, &msg, sizeof(msg)); 3600 3603 3601 3604 if (got_exception) 3602 3605 { 3603 rv = SerializeException( writer, peer, exception, wrappers);3606 rv = SerializeException(&MsgWriter, peer, exception, wrappers); 3604 3607 NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get/serialize exception"); 3605 3608 } … … 3611 3614 else 3612 3615 rv = IPC_SendMessage(peer, kDConnectTargetID, 3613 writer.GetBuffer(), writer.GetSize());3616 IPCMsgWriterGetBuf(&MsgWriter), IPCMsgWriterGetSize(&MsgWriter)); 3614 3617 3615 3618 if (NS_FAILED(rv)) … … 3618 3621 ReleaseWrappers(wrappers, peer); 3619 3622 } 3623 3624 IPCMsgWriterCleanup(&MsgWriter); 3620 3625 } 3621 3626 … … 3813 3818 wrapper->Release(); 3814 3819 3815 ipcMessageWriter writer(64); 3820 IPCMSGWRITER MsgWriter; 3821 IPCMsgWriterInit(&MsgWriter, 64 /*cbInitial*/); 3816 3822 3817 3823 DConnectInvokeReply reply; … … 3825 3831 reply.flags |= DCON_OP_FLAGS_REPLY_EXCEPTION; 3826 3832 3827 writer.PutBytes(&reply, sizeof(reply));3833 IPCMsgWriterPutBytes(&MsgWriter, &reply, sizeof(reply)); 3828 3834 3829 3835 nsVoidArray wrappers; … … 3846 3852 invoke->method_index, params, PR_TRUE, iid); 3847 3853 if (NS_SUCCEEDED(rv)) 3848 rv = SerializeInterfaceParam( writer, peer, iid,3854 rv = SerializeInterfaceParam(&MsgWriter, peer, iid, 3849 3855 (nsISupports *) params[i].val.p, wrappers); 3850 3856 } 3851 3857 else 3852 rv = SerializeParam( writer, type, params[i]);3858 rv = SerializeParam(&MsgWriter, type, params[i]); 3853 3859 3854 3860 if (NS_FAILED(rv)) … … 3872 3878 (paramInfo.IsRetval() || paramInfo.IsOut())) 3873 3879 { 3874 rv = SerializeArrayParam(this, writer, peer, iinfo, invoke->method_index,3880 rv = SerializeArrayParam(this, &MsgWriter, peer, iinfo, invoke->method_index, 3875 3881 *methodInfo, params, PR_TRUE, paramInfo, 3876 3882 params[i].val.p, wrappers); … … 3887 3893 if (got_exception) 3888 3894 { 3889 rv = SerializeException( writer, peer, exception, wrappers);3895 rv = SerializeException(&MsgWriter, peer, exception, wrappers); 3890 3896 NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get/serialize exception"); 3891 3897 } … … 3894 3900 rv = IPC_SendMessage(peer, kDConnectTargetID, (const PRUint8 *) &reply, sizeof(reply)); 3895 3901 else 3896 rv = IPC_SendMessage(peer, kDConnectTargetID, writer.GetBuffer(), writer.GetSize());3902 rv = IPC_SendMessage(peer, kDConnectTargetID, IPCMsgWriterGetBuf(&MsgWriter), IPCMsgWriterGetSize(&MsgWriter)); 3897 3903 if (NS_FAILED(rv)) 3898 3904 { … … 3917 3923 RTMemFree(params); 3918 3924 } 3919 } 3925 3926 IPCMsgWriterCleanup(&MsgWriter); 3927 } -
trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.h
r103562 r103569 40 40 41 41 #include "ipcMsgReader.h" 42 #include "ipcMsgWriter.h" 42 43 43 44 #include "nsIInterfaceInfo.h" … … 57 58 58 59 class nsIException; 59 class ipcMessageWriter;60 60 61 61 // a key class used to identify DConnectInstance objects stored in a hash table … … 194 194 nsID &result); 195 195 196 NS_HIDDEN_(nsresult) SerializeInterfaceParam( ipcMessageWriter &writer,196 NS_HIDDEN_(nsresult) SerializeInterfaceParam(PIPCMSGWRITER pMsgWriter, 197 197 PRUint32 peer, const nsID &iid, 198 198 nsISupports *obj, … … 202 202 nsISupports *&obj); 203 203 204 NS_HIDDEN_(nsresult) SerializeException( ipcMessageWriter &writer,204 NS_HIDDEN_(nsresult) SerializeException(PIPCMSGWRITER pMsgWriter, 205 205 PRUint32 peer, nsIException *xcpt, 206 206 nsVoidArray &wrappers);
Note:
See TracChangeset
for help on using the changeset viewer.