| Index: third_party/WebKit/Source/platform/SharedBuffer.h
|
| diff --git a/third_party/WebKit/Source/platform/SharedBuffer.h b/third_party/WebKit/Source/platform/SharedBuffer.h
|
| index cefa8b963d242842b10c07c429d252b528fc732a..a371bae4db4c51cf0b272fcb78f3b636d6234b99 100644
|
| --- a/third_party/WebKit/Source/platform/SharedBuffer.h
|
| +++ b/third_party/WebKit/Source/platform/SharedBuffer.h
|
| @@ -23,13 +23,16 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
| -
|
| #ifndef SharedBuffer_h
|
| #define SharedBuffer_h
|
|
|
| +#include <atomic>
|
| +
|
| #include "platform/PlatformExport.h"
|
| +#include "platform/SharedBufferStep.h"
|
| #include "platform/wtf/Forward.h"
|
| #include "platform/wtf/RefCounted.h"
|
| +#include "platform/wtf/ThreadingPrimitives.h"
|
| #include "platform/wtf/Vector.h"
|
| #include "platform/wtf/text/WTFString.h"
|
| #include "third_party/skia/include/core/SkData.h"
|
| @@ -70,6 +73,50 @@ class PLATFORM_EXPORT SharedBuffer : public RefCounted<SharedBuffer> {
|
|
|
| ~SharedBuffer();
|
|
|
| + class ThreadSafeStepper : public ThreadSafeRefCounted<ThreadSafeStepper> {
|
| + public:
|
| + PassRefPtr<SharedBufferStep> current_step();
|
| + ~ThreadSafeStepper();
|
| +
|
| + private:
|
| + static PassRefPtr<ThreadSafeStepper> Create(
|
| + PassRefPtr<SharedBufferStep> step) {
|
| + return AdoptRef(new ThreadSafeStepper(std::move(step)));
|
| + }
|
| +
|
| + ThreadSafeStepper(PassRefPtr<SharedBufferStep>);
|
| +
|
| + void set_current_step(PassRefPtr<SharedBufferStep>);
|
| +
|
| + struct Steps {
|
| + Steps();
|
| +
|
| + static const size_t kStepArraySize = 5;
|
| + struct StepHolder {
|
| + RefPtr<SharedBufferStep> step;
|
| + bool self_keep;
|
| + bool keep_ref;
|
| + std::atomic<size_t> keep_count;
|
| + };
|
| + StepHolder step_holder_arr[kStepArraySize];
|
| +
|
| + Steps* next;
|
| + };
|
| +
|
| + void ClearStepHolderSelfKeep(Steps::StepHolder*);
|
| + void ClearStepHolder(Steps::StepHolder*);
|
| +
|
| + Steps* steps_head_;
|
| + Steps* steps_tail_;
|
| + Steps* steps_to_write_;
|
| + size_t to_write_index_;
|
| + Steps::StepHolder* step_holder_to_read_;
|
| +
|
| + friend class SharedBuffer;
|
| + };
|
| +
|
| + PassRefPtr<ThreadSafeStepper> thread_safe_stepper() const;
|
| +
|
| // DEPRECATED: use a segment iterator or Copy() instead.
|
| //
|
| // Calling this function will force internal segmented buffers to be merged
|
| @@ -149,16 +196,15 @@ class PLATFORM_EXPORT SharedBuffer : public RefCounted<SharedBuffer> {
|
| SharedBuffer(const char*, size_t);
|
| SharedBuffer(const unsigned char*, size_t);
|
|
|
| - // See SharedBuffer::data().
|
| - void MergeSegmentsIntoBuffer() const;
|
| -
|
| void AppendInternal(const char* data, size_t);
|
| bool GetBytesInternal(void* dest, size_t) const;
|
| size_t GetSomeDataInternal(const char*& data, size_t position) const;
|
|
|
| - size_t size_;
|
| - mutable Vector<char> buffer_;
|
| - mutable Vector<char*> segments_;
|
| + void SynchronizeStepWithThreadStepper() const;
|
| + bool forward_step_if_needed() const { return thread_safe_stepper_.Get(); }
|
| +
|
| + mutable RefPtr<SharedBufferStep> current_step_;
|
| + mutable RefPtr<ThreadSafeStepper> thread_safe_stepper_;
|
| };
|
|
|
| } // namespace blink
|
|
|