2014-07-01 00:30:29 +02:00
|
|
|
// Copyright (c) 2014 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.
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_BYTES_WRITE_HANDLER_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_BROWSER_BYTES_WRITE_HANDLER_H_
|
2014-07-01 00:30:29 +02:00
|
|
|
#pragma once
|
|
|
|
|
2014-07-15 00:18:51 +02:00
|
|
|
#include "include/base/cef_lock.h"
|
2014-07-01 00:30:29 +02:00
|
|
|
#include "include/cef_stream.h"
|
|
|
|
|
2015-01-23 20:09:34 +01:00
|
|
|
namespace client {
|
|
|
|
|
2014-07-01 00:30:29 +02:00
|
|
|
class BytesWriteHandler : public CefWriteHandler {
|
|
|
|
public:
|
|
|
|
explicit BytesWriteHandler(size_t grow);
|
2015-01-23 00:34:29 +01:00
|
|
|
~BytesWriteHandler();
|
2014-07-01 00:30:29 +02:00
|
|
|
|
2021-06-17 21:43:06 +02:00
|
|
|
size_t Write(const void* ptr, size_t size, size_t n) override;
|
|
|
|
int Seek(int64 offset, int whence) override;
|
|
|
|
int64 Tell() override;
|
|
|
|
int Flush() override;
|
|
|
|
bool MayBlock() override { return false; }
|
2014-07-01 00:30:29 +02:00
|
|
|
|
|
|
|
void* GetData() { return data_; }
|
|
|
|
int64 GetDataSize() { return offset_; }
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
private:
|
2014-07-01 00:30:29 +02:00
|
|
|
size_t Grow(size_t size);
|
|
|
|
|
|
|
|
size_t grow_;
|
|
|
|
void* data_;
|
|
|
|
int64 datasize_;
|
|
|
|
int64 offset_;
|
|
|
|
|
2014-07-15 00:18:51 +02:00
|
|
|
base::Lock lock_;
|
|
|
|
|
2014-07-01 00:30:29 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(BytesWriteHandler);
|
2015-01-23 20:23:54 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(BytesWriteHandler);
|
2014-07-01 00:30:29 +02:00
|
|
|
};
|
|
|
|
|
2015-01-23 20:09:34 +01:00
|
|
|
} // namespace client
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_BYTES_WRITE_HANDLER_H_
|