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

Unified Diff: third_party/WebKit/Source/core/fileapi/FileReaderLoader.cpp

Issue 2837873007: Tell V8 about the extra memory being held by FileReader objects. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/FileReaderLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
}
« no previous file with comments | « third_party/WebKit/Source/core/fileapi/FileReaderLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698