예제 #1
0
result_t HeapSnapshot::serialize(std::string& retVal)
{
	class BufferStream : public v8::OutputStream {
	public:
		virtual void EndOfStream()
		{}

		virtual WriteResult WriteAsciiChunk(char* data, int size)
		{
			m_buf.append(data, size);
			return kContinue;
		}

		std::string result()
		{
			return m_buf.str();
		}

	private:
		StringBuffer m_buf;
	};

	BufferStream bs;

	m_snapshot->Serialize(&bs);
	retVal = bs.result();

	return 0;
}
예제 #2
0
result_t HeapSnapshotProxy::save(const char* fname, AsyncEvent* ac)
{
	class BufferStream : public v8::OutputStream {
	public:
		virtual void EndOfStream()
		{}

		virtual WriteResult WriteAsciiChunk(char* data, int size)
		{
			m_buf.append(data, size);
			return kContinue;
		}

		std::string result()
		{
			return m_buf.str();
		}

	private:
		StringBuffer m_buf;
	};

	BufferStream bs;
	m_snapshot->Serialize(&bs);

	return fs_base::ac_writeFile(fname, bs.result().c_str());
}