зеркало из https://github.com/mozilla/gecko-dev.git
Bug 636063, part 2: Backend support for |compress|d messages. r=bent
This commit is contained in:
Родитель
e3beae9af4
Коммит
967d4da9ae
|
@ -28,11 +28,13 @@ Message::Message()
|
|||
}
|
||||
|
||||
Message::Message(int32 routing_id, msgid_t type, PriorityValue priority,
|
||||
const char* const name)
|
||||
MessageCompression compression, const char* const name)
|
||||
: Pickle(sizeof(Header)) {
|
||||
header()->routing = routing_id;
|
||||
header()->type = type;
|
||||
header()->flags = priority;
|
||||
if (compression == COMPRESSION_ENABLED)
|
||||
header()->flags |= COMPRESS_BIT;
|
||||
#if defined(OS_POSIX)
|
||||
header()->num_fds = 0;
|
||||
#endif
|
||||
|
|
|
@ -54,6 +54,11 @@ class Message : public Pickle {
|
|||
PRIORITY_HIGH
|
||||
};
|
||||
|
||||
enum MessageCompression {
|
||||
COMPRESSION_NONE,
|
||||
COMPRESSION_ENABLED
|
||||
};
|
||||
|
||||
virtual ~Message();
|
||||
|
||||
Message();
|
||||
|
@ -61,6 +66,7 @@ class Message : public Pickle {
|
|||
// Initialize a message with a user-defined type, priority value, and
|
||||
// destination WebView ID.
|
||||
Message(int32 routing_id, msgid_t type, PriorityValue priority,
|
||||
MessageCompression compression = COMPRESSION_NONE,
|
||||
const char* const name="???");
|
||||
|
||||
// Initializes a message from a const block of data. The data is not copied;
|
||||
|
@ -85,6 +91,11 @@ class Message : public Pickle {
|
|||
return (header()->flags & RPC_BIT) != 0;
|
||||
}
|
||||
|
||||
// True if compression is enabled for this message.
|
||||
bool compress() const {
|
||||
return (header()->flags & COMPRESS_BIT) != 0;
|
||||
}
|
||||
|
||||
// Set this on a reply to a synchronous message.
|
||||
void set_reply() {
|
||||
header()->flags |= REPLY_BIT;
|
||||
|
@ -263,7 +274,8 @@ class Message : public Pickle {
|
|||
UNBLOCK_BIT = 0x0020,
|
||||
PUMPING_MSGS_BIT= 0x0040,
|
||||
HAS_SENT_TIME_BIT = 0x0080,
|
||||
RPC_BIT = 0x0100
|
||||
RPC_BIT = 0x0100,
|
||||
COMPRESS_BIT = 0x0200
|
||||
};
|
||||
|
||||
#pragma pack(push, 2)
|
||||
|
|
|
@ -1550,13 +1550,15 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
|||
for md in p.messageDecls:
|
||||
ns.addstmts([
|
||||
_generateMessageClass(md.msgClass(), md.msgId(),
|
||||
typedefs, md.prettyMsgName(p.name+'::')),
|
||||
typedefs, md.prettyMsgName(p.name+'::'),
|
||||
md.decl.type.compress),
|
||||
Whitespace.NL ])
|
||||
if md.hasReply():
|
||||
ns.addstmts([
|
||||
_generateMessageClass(
|
||||
md.replyClass(), md.replyId(),
|
||||
typedefs, md.prettyReplyName(p.name+'::')),
|
||||
typedefs, md.prettyReplyName(p.name+'::'),
|
||||
md.decl.type.compress),
|
||||
Whitespace.NL ])
|
||||
|
||||
ns.addstmts([ Whitespace.NL, Whitespace.NL ])
|
||||
|
@ -1744,7 +1746,7 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
|||
|
||||
##--------------------------------------------------
|
||||
|
||||
def _generateMessageClass(clsname, msgid, typedefs, prettyName):
|
||||
def _generateMessageClass(clsname, msgid, typedefs, prettyName, compress):
|
||||
cls = Class(name=clsname, inherits=[ Inherit(Type('IPC::Message')) ])
|
||||
cls.addstmt(Label.PRIVATE)
|
||||
cls.addstmts(typedefs)
|
||||
|
@ -1757,12 +1759,17 @@ def _generateMessageClass(clsname, msgid, typedefs, prettyName):
|
|||
cls.addstmt(StmtDecl(Decl(idenum, '')))
|
||||
|
||||
# make the message constructor
|
||||
if compress:
|
||||
compression = ExprVar('COMPRESSION_ENABLED')
|
||||
else:
|
||||
compression = ExprVar('COMPRESSION_NONE')
|
||||
ctor = ConstructorDefn(
|
||||
ConstructorDecl(clsname),
|
||||
memberinits=[ ExprMemberInit(ExprVar('IPC::Message'),
|
||||
[ ExprVar('MSG_ROUTING_NONE'),
|
||||
ExprVar('ID'),
|
||||
ExprVar('PRIORITY_NORMAL'),
|
||||
compression,
|
||||
ExprLiteral.String(prettyName) ]) ])
|
||||
cls.addstmts([ ctor, Whitespace.NL ])
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче