Index: third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp |
diff --git a/third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp b/third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp |
index d0e1b24c2d903d35d7c45a57fef9bfe7281ea8a8..653ccd9cc0cbd35c8929a76182abf8fe53460e4a 100644 |
--- a/third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp |
+++ b/third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp |
@@ -50,6 +50,7 @@ |
#include "platform/wtf/text/Base64.h" |
#include "platform/wtf/text/StringBuilder.h" |
#include "public/platform/WebURLRequest.h" |
+#include "v8/include/v8.h" |
namespace blink { |
@@ -69,6 +70,7 @@ FileReaderLoader::FileReaderLoader(ReadType read_type, |
FileReaderLoader::~FileReaderLoader() { |
Cleanup(); |
+ UnreportMemoryUsageToV8(); |
if (!url_for_reading_.IsEmpty()) { |
BlobRegistry::RevokePublicBlobURL(url_for_reading_); |
} |
@@ -143,9 +145,23 @@ void FileReaderLoader::Cleanup() { |
string_result_ = ""; |
is_raw_data_converted_ = true; |
decoder_.reset(); |
+ UnreportMemoryUsageToV8(); |
} |
} |
+void FileReaderLoader::ReportAdditionalMemoryUsageToV8(int64_t usage) { |
+ memory_usage_reported_to_v8_ += usage; |
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(usage); |
+} |
+ |
+void FileReaderLoader::UnreportMemoryUsageToV8() { |
+ if (!memory_usage_reported_to_v8_) |
+ return; |
+ v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
+ -memory_usage_reported_to_v8_); |
+ memory_usage_reported_to_v8_ = 0; |
+} |
+ |
void FileReaderLoader::DidReceiveResponse( |
unsigned long, |
const ResourceResponse& response, |
@@ -230,6 +246,7 @@ void FileReaderLoader::DidReceiveData(const char* data, unsigned data_length) { |
} |
bytes_loaded_ += bytes_appended; |
is_raw_data_converted_ = false; |
+ ReportAdditionalMemoryUsageToV8(bytes_appended); |
if (client_) |
client_->DidReceiveData(); |
@@ -332,6 +349,8 @@ String FileReaderLoader::StringResult() { |
NOTREACHED(); |
} |
+ if (finished_loading_) |
+ ReportAdditionalMemoryUsageToV8(string_result_.CharactersSizeInBytes()); |
michaeln
2017/04/26 20:36:59
Hmmm... I think this can miss reporting the the st
|
return string_result_; |
} |