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;
|
2023-06-01 16:06:15 +02:00
|
|
|
int Seek(int64_t offset, int whence) override;
|
|
|
|
int64_t Tell() override;
|
2021-06-17 21:43:06 +02:00
|
|
|
int Flush() override;
|
|
|
|
bool MayBlock() override { return false; }
|
2014-07-01 00:30:29 +02:00
|
|
|
|
|
|
|
void* GetData() { return data_; }
|
2023-06-01 16:06:15 +02:00
|
|
|
int64_t GetDataSize() { return offset_; }
|
2014-07-01 00:30:29 +02:00
|
|
|
|
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_;
|
2023-06-01 16:06:15 +02:00
|
|
|
int64_t datasize_;
|
|
|
|
int64_t offset_;
|
2014-07-01 00:30:29 +02:00
|
|
|
|
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_
|