1 /* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef WebCore_SharedBufferStream_DEFINED 18 #define WebCore_SharedBufferStream_DEFINED 19 20 #include "SkStream.h" 21 #include "SharedBuffer.h" 22 23 namespace WebCore { 24 25 /** Subclass of SkStream that wrapps a webcore SharedBuffer object. To 26 allow this object to be deleted from any thread, the impl will ensure 27 that we unref the SharedBuffer object from the correct webcore thread. 28 */ 29 class SharedBufferStream : public SkMemoryStream { 30 public: 31 SharedBufferStream(SharedBuffer* buffer); 32 virtual ~SharedBufferStream(); 33 34 private: 35 // don't allow this to change our data. should not get called, but we 36 // override here just to be sure setMemory(const void * data,size_t length,bool copyData)37 virtual void setMemory(const void* data, size_t length, bool copyData) { 38 sk_throw(); 39 } 40 41 // we share ownership of this with webkit 42 SharedBuffer* fBuffer; 43 }; 44 } 45 46 #endif 47