2009-03-04 03:31:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_MEMORY_DEALER_H
|
|
|
|
#define ANDROID_MEMORY_DEALER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2009-05-20 02:08:10 +00:00
|
|
|
#include <binder/IMemory.h>
|
|
|
|
#include <binder/MemoryHeapBase.h>
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2010-01-26 03:00:00 +00:00
|
|
|
class SimpleBestFitAllocator;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class MemoryDealer : public RefBase
|
|
|
|
{
|
|
|
|
public:
|
2010-01-26 03:00:00 +00:00
|
|
|
MemoryDealer(size_t size, const char* name = 0);
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2010-01-26 03:00:00 +00:00
|
|
|
virtual sp<IMemory> allocate(size_t size);
|
2009-03-04 03:31:44 +00:00
|
|
|
virtual void deallocate(size_t offset);
|
2010-01-26 03:00:00 +00:00
|
|
|
virtual void dump(const char* what) const;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
|
|
|
sp<IMemoryHeap> getMemoryHeap() const { return heap(); }
|
|
|
|
|
2009-07-16 17:05:57 +00:00
|
|
|
protected:
|
|
|
|
virtual ~MemoryDealer();
|
|
|
|
|
2010-01-26 03:00:00 +00:00
|
|
|
private:
|
|
|
|
const sp<IMemoryHeap>& heap() const;
|
|
|
|
SimpleBestFitAllocator* allocator() const;
|
2009-03-04 03:31:44 +00:00
|
|
|
|
2010-01-26 03:00:00 +00:00
|
|
|
sp<IMemoryHeap> mHeap;
|
|
|
|
SimpleBestFitAllocator* mAllocator;
|
2009-03-04 03:31:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif // ANDROID_MEMORY_DEALER_H
|