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

Side by Side Diff: content/renderer/memory_benchmarking_extension.cc

Issue 259993003: Make sure gin Handles exist before using them (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/renderer/memory_benchmarking_extension.h" 5 #include "content/renderer/memory_benchmarking_extension.h"
6 6
7 #include "content/common/memory_benchmark_messages.h" 7 #include "content/common/memory_benchmark_messages.h"
8 #include "content/renderer/render_thread_impl.h" 8 #include "content/renderer/render_thread_impl.h"
9 #include "gin/arguments.h" 9 #include "gin/arguments.h"
10 #include "gin/handle.h" 10 #include "gin/handle.h"
(...skipping 14 matching lines...) Expand all
25 void MemoryBenchmarkingExtension::Install(blink::WebFrame* frame) { 25 void MemoryBenchmarkingExtension::Install(blink::WebFrame* frame) {
26 v8::Isolate* isolate = blink::mainThreadIsolate(); 26 v8::Isolate* isolate = blink::mainThreadIsolate();
27 v8::HandleScope handle_scope(isolate); 27 v8::HandleScope handle_scope(isolate);
28 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); 28 v8::Handle<v8::Context> context = frame->mainWorldScriptContext();
29 if (context.IsEmpty()) 29 if (context.IsEmpty())
30 return; 30 return;
31 31
32 v8::Context::Scope context_scope(context); 32 v8::Context::Scope context_scope(context);
33 gin::Handle<MemoryBenchmarkingExtension> controller = 33 gin::Handle<MemoryBenchmarkingExtension> controller =
34 gin::CreateHandle(isolate, new MemoryBenchmarkingExtension()); 34 gin::CreateHandle(isolate, new MemoryBenchmarkingExtension());
35 if (controller.IsEmpty())
36 return;
37
35 v8::Handle<v8::Object> global = context->Global(); 38 v8::Handle<v8::Object> global = context->Global();
36 v8::Handle<v8::Object> chrome = 39 v8::Handle<v8::Object> chrome =
37 global->Get(gin::StringToV8(isolate, "chrome"))->ToObject(); 40 global->Get(gin::StringToV8(isolate, "chrome"))->ToObject();
38 if (chrome.IsEmpty()) { 41 if (chrome.IsEmpty()) {
39 chrome = v8::Object::New(isolate); 42 chrome = v8::Object::New(isolate);
40 global->Set(gin::StringToV8(isolate, "chrome"), chrome); 43 global->Set(gin::StringToV8(isolate, "chrome"), chrome);
41 } 44 }
42 chrome->Set(gin::StringToV8(isolate, "memoryBenchmarking"), 45 chrome->Set(gin::StringToV8(isolate, "memoryBenchmarking"),
43 controller.ToV8()); 46 controller.ToV8());
44 } 47 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (process_type == "browser") { 82 if (process_type == "browser") {
80 content::RenderThreadImpl::current()->Send( 83 content::RenderThreadImpl::current()->Send(
81 new MemoryBenchmarkHostMsg_HeapProfilerDump(reason)); 84 new MemoryBenchmarkHostMsg_HeapProfilerDump(reason));
82 } else { 85 } else {
83 ::HeapProfilerDump(reason.c_str()); 86 ::HeapProfilerDump(reason.c_str());
84 } 87 }
85 #endif 88 #endif
86 } 89 }
87 90
88 } // namespace content 91 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/dom_automation_controller.cc ('k') | content/renderer/skia_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698