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

Side by Side Diff: chrome/renderer/net_benchmarking_extension.cc

Issue 11801024: Fixed browser crash when using Debug build: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Separates chrome.benchmarking.closeConnections() in order to remove --enable-benchmarking from tele… Created 7 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/net_benchmarking_extension.h"
6
7 #include "chrome/common/benchmarking_messages.h"
8 #include "content/public/renderer/render_thread.h"
9 #include "v8/include/v8.h"
10
11 const char kNetBenchmarkingExtensionName[] = "v8/NetBenchmarking";
12
13 namespace extensions_v8 {
14
15 class NetBenchmarkingWrapper : public v8::Extension {
16 public:
17 NetBenchmarkingWrapper() :
18 v8::Extension(kNetBenchmarkingExtensionName,
19 "if (typeof(chrome) == 'undefined') {"
20 " chrome = {};"
21 "};"
22 "if (typeof(chrome.benchmarking) == 'undefined') {"
23 " chrome.benchmarking = {};"
24 "};"
25 "chrome.benchmarking.closeConnections = function() {"
26 " native function CloseConnections();"
27 " CloseConnections();"
28 "};"
29 ) {}
30
31 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
32 v8::Handle<v8::String> name) {
33 if (name->Equals(v8::String::New("CloseConnections"))) {
34 return v8::FunctionTemplate::New(CloseConnections);
35 }
36
37 return v8::Handle<v8::FunctionTemplate>();
38 }
39
40 static v8::Handle<v8::Value> CloseConnections(const v8::Arguments& args) {
41 content::RenderThread::Get()->Send(
42 new ChromeViewHostMsg_CloseCurrentConnections());
43 return v8::Undefined();
44 }
45 };
46
47 v8::Extension* NetBenchmarkingExtension::Get() {
48 return new NetBenchmarkingWrapper();
49 }
50
51 } // namespace extensions_v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698