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

Side by Side Diff: content/shell/renderer/gc_controller.cc

Issue 153803002: Implement GCController::CollectAll (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « content/shell/renderer/gc_controller.h ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/shell/renderer/gc_controller.h" 5 #include "content/shell/renderer/gc_controller.h"
6 6
7 #include "gin/arguments.h" 7 #include "gin/arguments.h"
8 #include "gin/handle.h" 8 #include "gin/handle.h"
9 #include "gin/object_template_builder.h" 9 #include "gin/object_template_builder.h"
10 #include "third_party/WebKit/public/web/WebFrame.h" 10 #include "third_party/WebKit/public/web/WebFrame.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 GCController::GCController() {} 34 GCController::GCController() {}
35 35
36 GCController::~GCController() {} 36 GCController::~GCController() {}
37 37
38 gin::ObjectTemplateBuilder GCController::GetObjectTemplateBuilder( 38 gin::ObjectTemplateBuilder GCController::GetObjectTemplateBuilder(
39 v8::Isolate* isolate) { 39 v8::Isolate* isolate) {
40 return gin::Wrappable<GCController>::GetObjectTemplateBuilder(isolate) 40 return gin::Wrappable<GCController>::GetObjectTemplateBuilder(isolate)
41 .SetMethod("collect", &GCController::Collect) 41 .SetMethod("collect", &GCController::Collect)
42 .SetMethod("collectAll", &GCController::CollectAll)
42 .SetMethod("minorCollect", &GCController::MinorCollect); 43 .SetMethod("minorCollect", &GCController::MinorCollect);
43 } 44 }
44 45
45 void GCController::Collect(const gin::Arguments& args) { 46 void GCController::Collect(const gin::Arguments& args) {
46 args.isolate()->RequestGarbageCollectionForTesting( 47 args.isolate()->RequestGarbageCollectionForTesting(
47 v8::Isolate::kFullGarbageCollection); 48 v8::Isolate::kFullGarbageCollection);
48 } 49 }
49 50
51 void GCController::CollectAll(const gin::Arguments& args) {
52 // In order to collect a DOM wrapper, two GC cycles are needed.
53 // In the first GC cycle, a weak callback of the DOM wrapper is called back
54 // and the weak callback disposes a persistent handle to the DOM wrapper.
55 // In the second GC cycle, the DOM wrapper is reclaimed.
56 // Given that two GC cycles are needed to collect one DOM wrapper,
57 // more than two GC cycles are needed to collect all DOM wrappers
58 // that are chained. Seven GC cycles look enough in most tests.
59 for (int i = 0; i < 7; i++) {
60 args.isolate()->RequestGarbageCollectionForTesting(
61 v8::Isolate::kFullGarbageCollection);
62 }
63 }
64
50 void GCController::MinorCollect(const gin::Arguments& args) { 65 void GCController::MinorCollect(const gin::Arguments& args) {
51 args.isolate()->RequestGarbageCollectionForTesting( 66 args.isolate()->RequestGarbageCollectionForTesting(
52 v8::Isolate::kMinorGarbageCollection); 67 v8::Isolate::kMinorGarbageCollection);
53 } 68 }
54 69
55 } // namespace content 70 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/gc_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698