| Index: content/shell/renderer/gc_controller.cc
|
| diff --git a/content/shell/renderer/gc_controller.cc b/content/shell/renderer/gc_controller.cc
|
| index ad4fa0419e2c41e50f229a3cd030030068cfcdf8..f8d3b0909c54cb16ce16a331724bc831a5e87eba 100644
|
| --- a/content/shell/renderer/gc_controller.cc
|
| +++ b/content/shell/renderer/gc_controller.cc
|
| @@ -39,6 +39,7 @@ gin::ObjectTemplateBuilder GCController::GetObjectTemplateBuilder(
|
| v8::Isolate* isolate) {
|
| return gin::Wrappable<GCController>::GetObjectTemplateBuilder(isolate)
|
| .SetMethod("collect", &GCController::Collect)
|
| + .SetMethod("collectAll", &GCController::CollectAll)
|
| .SetMethod("minorCollect", &GCController::MinorCollect);
|
| }
|
|
|
| @@ -47,6 +48,20 @@ void GCController::Collect(const gin::Arguments& args) {
|
| v8::Isolate::kFullGarbageCollection);
|
| }
|
|
|
| +void GCController::CollectAll(const gin::Arguments& args) {
|
| + // In order to collect a DOM wrapper, two GC cycles are needed.
|
| + // In the first GC cycle, a weak callback of the DOM wrapper is called back
|
| + // and the weak callback disposes a persistent handle to the DOM wrapper.
|
| + // In the second GC cycle, the DOM wrapper is reclaimed.
|
| + // Given that two GC cycles are needed to collect one DOM wrapper,
|
| + // more than two GC cycles are needed to collect all DOM wrappers
|
| + // that are chained. Seven GC cycles look enough in most tests.
|
| + for (int i = 0; i < 7; i++) {
|
| + args.isolate()->RequestGarbageCollectionForTesting(
|
| + v8::Isolate::kFullGarbageCollection);
|
| + }
|
| +}
|
| +
|
| void GCController::MinorCollect(const gin::Arguments& args) {
|
| args.isolate()->RequestGarbageCollectionForTesting(
|
| v8::Isolate::kMinorGarbageCollection);
|
|
|