1/* 2 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#include "config.h" 27#include "MessageDecoder.h" 28 29#include "ArgumentCoders.h" 30#include "DataReference.h" 31#include "MessageFlags.h" 32#include "StringReference.h" 33 34#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 35#include "ImportanceAssertion.h" 36#endif 37 38namespace CoreIPC { 39 40PassOwnPtr<MessageDecoder> MessageDecoder::create(const DataReference& buffer) 41{ 42 Vector<Attachment> attachments; 43 return adoptPtr(new MessageDecoder(buffer, attachments)); 44} 45 46PassOwnPtr<MessageDecoder> MessageDecoder::create(const DataReference& buffer, Vector<Attachment>& attachments) 47{ 48 return adoptPtr(new MessageDecoder(buffer, attachments)); 49} 50 51MessageDecoder::~MessageDecoder() 52{ 53} 54 55MessageDecoder::MessageDecoder(const DataReference& buffer, Vector<Attachment>& attachments) 56 : ArgumentDecoder(buffer.data(), buffer.size(), attachments) 57{ 58 if (!decode(m_messageFlags)) 59 return; 60 61 if (!decode(m_messageReceiverName)) 62 return; 63 64 if (!decode(m_messageName)) 65 return; 66 67 decode(m_destinationID); 68} 69 70bool MessageDecoder::isSyncMessage() const 71{ 72 return m_messageFlags & SyncMessage; 73} 74 75bool MessageDecoder::shouldDispatchMessageWhenWaitingForSyncReply() const 76{ 77 return m_messageFlags & DispatchMessageWhenWaitingForSyncReply; 78} 79 80#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 81void MessageDecoder::setImportanceAssertion(PassOwnPtr<ImportanceAssertion> assertion) 82{ 83 m_importanceAssertion = assertion; 84} 85#endif 86 87} // namespace CoreIPC 88