2009-03-05 02:10:06 +01:00
|
|
|
// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
// can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "../precompiled_libcef.h"
|
|
|
|
#include "cpptoc/stream_cpptoc.h"
|
|
|
|
|
|
|
|
|
|
|
|
size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* stream,
|
|
|
|
void *ptr, size_t size, size_t n)
|
|
|
|
{
|
|
|
|
DCHECK(stream);
|
|
|
|
if(!stream)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
return CefStreamReaderCppToC::Get(stream)->Read(ptr, size, n);
|
2009-03-05 02:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* stream,
|
|
|
|
long offset, int whence)
|
|
|
|
{
|
|
|
|
DCHECK(stream);
|
|
|
|
if(!stream)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
return CefStreamReaderCppToC::Get(stream)->Seek(offset, whence);
|
2009-03-05 02:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
long CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* stream)
|
|
|
|
{
|
|
|
|
DCHECK(stream);
|
|
|
|
if(!stream)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
return CefStreamReaderCppToC::Get(stream)->Tell();
|
2009-03-05 02:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* stream)
|
|
|
|
{
|
|
|
|
DCHECK(stream);
|
|
|
|
if(!stream)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
return CefStreamReaderCppToC::Get(stream)->Eof();
|
2009-03-05 02:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-08 03:26:16 +01:00
|
|
|
CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls)
|
2009-05-28 02:31:21 +02:00
|
|
|
: CefCppToC<CefStreamReaderCppToC, CefStreamReader,
|
|
|
|
cef_stream_reader_t>(cls)
|
2009-03-05 02:10:06 +01:00
|
|
|
{
|
|
|
|
struct_.struct_.read = stream_reader_read;
|
|
|
|
struct_.struct_.seek = stream_reader_seek;
|
|
|
|
struct_.struct_.tell = stream_reader_tell;
|
|
|
|
struct_.struct_.eof = stream_reader_eof;
|
|
|
|
}
|
2009-03-08 03:26:16 +01:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2009-05-28 02:31:21 +02:00
|
|
|
long CefCppToC<CefStreamReaderCppToC, CefStreamReader,
|
|
|
|
cef_stream_reader_t>::DebugObjCt = 0;
|
2009-03-08 03:26:16 +01:00
|
|
|
#endif
|
2009-03-05 02:10:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* stream,
|
|
|
|
const void *ptr, size_t size, size_t n)
|
|
|
|
{
|
|
|
|
DCHECK(stream);
|
|
|
|
if(!stream)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
return CefStreamWriterCppToC::Get(stream)->Write(ptr, size, n);
|
2009-03-05 02:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* stream,
|
|
|
|
long offset, int whence)
|
|
|
|
{
|
|
|
|
DCHECK(stream);
|
|
|
|
if(!stream)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
return CefStreamWriterCppToC::Get(stream)->Seek(offset, whence);
|
2009-03-05 02:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
long CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* stream)
|
|
|
|
{
|
|
|
|
DCHECK(stream);
|
|
|
|
if(!stream)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
return CefStreamWriterCppToC::Get(stream)->Tell();
|
2009-03-05 02:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* stream)
|
|
|
|
{
|
|
|
|
DCHECK(stream);
|
|
|
|
if(!stream)
|
|
|
|
return 0;
|
|
|
|
|
2009-05-28 02:31:21 +02:00
|
|
|
return CefStreamWriterCppToC::Get(stream)->Flush();
|
2009-03-05 02:10:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-08 03:26:16 +01:00
|
|
|
CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls)
|
2009-05-28 02:31:21 +02:00
|
|
|
: CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
|
|
|
|
cef_stream_writer_t>(cls)
|
2009-03-05 02:10:06 +01:00
|
|
|
{
|
|
|
|
struct_.struct_.write = stream_writer_write;
|
|
|
|
struct_.struct_.seek = stream_writer_seek;
|
|
|
|
struct_.struct_.tell = stream_writer_tell;
|
|
|
|
struct_.struct_.flush = stream_writer_flush;
|
|
|
|
}
|
2009-03-08 03:26:16 +01:00
|
|
|
|
|
|
|
#ifdef _DEBUG
|
2009-05-28 02:31:21 +02:00
|
|
|
long CefCppToC<CefStreamWriterCppToC, CefStreamWriter,
|
|
|
|
cef_stream_writer_t>::DebugObjCt = 0;
|
2009-03-08 03:26:16 +01:00
|
|
|
#endif
|