| Index: chrome/renderer/net_benchmarking_extension.cc
|
| diff --git a/chrome/renderer/net_benchmarking_extension.cc b/chrome/renderer/net_benchmarking_extension.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..333c9310cccb98f3e7f14b69b2ada9a135c53b3c
|
| --- /dev/null
|
| +++ b/chrome/renderer/net_benchmarking_extension.cc
|
| @@ -0,0 +1,51 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/renderer/net_benchmarking_extension.h"
|
| +
|
| +#include "chrome/common/benchmarking_messages.h"
|
| +#include "content/public/renderer/render_thread.h"
|
| +#include "v8/include/v8.h"
|
| +
|
| +const char kNetBenchmarkingExtensionName[] = "v8/NetBenchmarking";
|
| +
|
| +namespace extensions_v8 {
|
| +
|
| +class NetBenchmarkingWrapper : public v8::Extension {
|
| + public:
|
| + NetBenchmarkingWrapper() :
|
| + v8::Extension(kNetBenchmarkingExtensionName,
|
| + "if (typeof(chrome) == 'undefined') {"
|
| + " chrome = {};"
|
| + "};"
|
| + "if (typeof(chrome.benchmarking) == 'undefined') {"
|
| + " chrome.benchmarking = {};"
|
| + "};"
|
| + "chrome.benchmarking.closeConnections = function() {"
|
| + " native function CloseConnections();"
|
| + " CloseConnections();"
|
| + "};"
|
| + ) {}
|
| +
|
| + virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
|
| + v8::Handle<v8::String> name) {
|
| + if (name->Equals(v8::String::New("CloseConnections"))) {
|
| + return v8::FunctionTemplate::New(CloseConnections);
|
| + }
|
| +
|
| + return v8::Handle<v8::FunctionTemplate>();
|
| + }
|
| +
|
| + static v8::Handle<v8::Value> CloseConnections(const v8::Arguments& args) {
|
| + content::RenderThread::Get()->Send(
|
| + new ChromeViewHostMsg_CloseCurrentConnections());
|
| + return v8::Undefined();
|
| + }
|
| +};
|
| +
|
| +v8::Extension* NetBenchmarkingExtension::Get() {
|
| + return new NetBenchmarkingWrapper();
|
| +}
|
| +
|
| +} // namespace extensions_v8
|
|
|