Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/BytesConsumer.cpp

Issue 2847543003: Report BytesConsumer::Chunk buffer size to V8 (Closed)
Patch Set: fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/fetch/BytesConsumer.h" 5 #include "modules/fetch/BytesConsumer.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include "core/dom/ExecutionContext.h" 9 #include "core/dom/ExecutionContext.h"
10 #include "core/dom/TaskRunnerHelper.h" 10 #include "core/dom/TaskRunnerHelper.h"
11 #include "modules/fetch/BlobBytesConsumer.h" 11 #include "modules/fetch/BlobBytesConsumer.h"
12 #include "platform/WebTaskRunner.h" 12 #include "platform/WebTaskRunner.h"
13 #include "platform/blob/BlobData.h" 13 #include "platform/blob/BlobData.h"
14 #include "platform/wtf/Functional.h" 14 #include "platform/wtf/Functional.h"
15 #include "platform/wtf/RefPtr.h" 15 #include "platform/wtf/RefPtr.h"
16 #include "v8/include/v8.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 namespace { 20 namespace {
20 21
21 class NoopClient final : public GarbageCollectedFinalized<NoopClient>, 22 class NoopClient final : public GarbageCollectedFinalized<NoopClient>,
22 public BytesConsumer::Client { 23 public BytesConsumer::Client {
23 USING_GARBAGE_COLLECTED_MIXIN(NoopClient); 24 USING_GARBAGE_COLLECTED_MIXIN(NoopClient);
24 25
25 public: 26 public:
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 BytesConsumer::Client::Trace(visitor); 108 BytesConsumer::Client::Trace(visitor);
108 } 109 }
109 110
110 private: 111 private:
111 using Result = BytesConsumer::Result; 112 using Result = BytesConsumer::Result;
112 class Chunk final : public GarbageCollectedFinalized<Chunk> { 113 class Chunk final : public GarbageCollectedFinalized<Chunk> {
113 public: 114 public:
114 Chunk(const char* data, size_t size) { 115 Chunk(const char* data, size_t size) {
115 buffer_.ReserveInitialCapacity(size); 116 buffer_.ReserveInitialCapacity(size);
116 buffer_.Append(data, size); 117 buffer_.Append(data, size);
118 // Report buffer size to V8 so GC can be triggered appropriately.
119 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
120 static_cast<int64_t>(buffer_.size()));
121 }
122 ~Chunk() {
123 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
124 -static_cast<int64_t>(buffer_.size()));
117 } 125 }
118 const char* data() const { return buffer_.data(); } 126 const char* data() const { return buffer_.data(); }
119 size_t size() const { return buffer_.size(); } 127 size_t size() const { return buffer_.size(); }
120 128
121 DEFINE_INLINE_TRACE() {} 129 DEFINE_INLINE_TRACE() {}
122 130
123 private: 131 private:
124 Vector<char> buffer_; 132 Vector<char> buffer_;
125 }; 133 };
126 134
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 375
368 BytesConsumer* BytesConsumer::CreateErrored(const BytesConsumer::Error& error) { 376 BytesConsumer* BytesConsumer::CreateErrored(const BytesConsumer::Error& error) {
369 return new ErroredBytesConsumer(error); 377 return new ErroredBytesConsumer(error);
370 } 378 }
371 379
372 BytesConsumer* BytesConsumer::CreateClosed() { 380 BytesConsumer* BytesConsumer::CreateClosed() {
373 return new ClosedBytesConsumer(); 381 return new ClosedBytesConsumer();
374 } 382 }
375 383
376 } // namespace blink 384 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698