1 // Copyright (c) 2014 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that 3 // can be found in the LICENSE file. 4 5 #ifndef CEF_TESTS_CEFCLIENT_BROWSER_BYTES_WRITE_HANDLER_H_ 6 #define CEF_TESTS_CEFCLIENT_BROWSER_BYTES_WRITE_HANDLER_H_ 7 #pragma once 8 9 #include "include/base/cef_lock.h" 10 #include "include/cef_stream.h" 11 12 namespace client { 13 14 class BytesWriteHandler : public CefWriteHandler { 15 public: 16 explicit BytesWriteHandler(size_t grow); 17 ~BytesWriteHandler(); 18 19 size_t Write(const void* ptr, size_t size, size_t n) override; 20 int Seek(int64 offset, int whence) override; 21 int64 Tell() override; 22 int Flush() override; MayBlock()23 bool MayBlock() override { return false; } 24 GetData()25 void* GetData() { return data_; } GetDataSize()26 int64 GetDataSize() { return offset_; } 27 28 private: 29 size_t Grow(size_t size); 30 31 size_t grow_; 32 void* data_; 33 int64 datasize_; 34 int64 offset_; 35 36 base::Lock lock_; 37 38 IMPLEMENT_REFCOUNTING(BytesWriteHandler); 39 DISALLOW_COPY_AND_ASSIGN(BytesWriteHandler); 40 }; 41 42 } // namespace client 43 44 #endif // CEF_TESTS_CEFCLIENT_BROWSER_BYTES_WRITE_HANDLER_H_ 45