diff options
author | danhn@chromium.org <danhn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-15 17:57:21 +0000 |
---|---|---|
committer | danhn@chromium.org <danhn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-15 17:57:21 +0000 |
commit | 8093a58b34fb9d08c0bc84ef6e425da5eadfca97 (patch) | |
tree | 8cf027bbe2f70e4271f3144e617c4491823a172a | |
parent | 4e974359395d6d9851a334eb6cdbf125d88b060e (diff) | |
download | chromium_src-8093a58b34fb9d08c0bc84ef6e425da5eadfca97.zip chromium_src-8093a58b34fb9d08c0bc84ef6e425da5eadfca97.tar.gz chromium_src-8093a58b34fb9d08c0bc84ef6e425da5eadfca97.tar.bz2 |
Fixed browser crash when Telemetry uses Debug build.
Factored out chrome.benchmarking methods which don't depend on stats table.
BUG=168640
TEST=tools/telemetry/run_tests --browser=debug PageRunnerTests
Review URL: https://chromiumcodereview.appspot.com/11801024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182754 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chrome_content_browser_client.cc | 11 | ||||
-rw-r--r-- | chrome/browser/chrome_net_benchmarking_message_filter.cc (renamed from chrome/browser/chrome_benchmarking_message_filter.cc) | 29 | ||||
-rw-r--r-- | chrome/browser/chrome_net_benchmarking_message_filter.h (renamed from chrome/browser/chrome_benchmarking_message_filter.h) | 15 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 4 | ||||
-rw-r--r-- | chrome/chrome_renderer.gypi | 2 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 3 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/renderer/benchmarking_extension.cc | 76 | ||||
-rw-r--r-- | chrome/renderer/chrome_content_renderer_client.cc | 3 | ||||
-rw-r--r-- | chrome/renderer/net_benchmarking_extension.cc | 110 | ||||
-rw-r--r-- | chrome/renderer/net_benchmarking_extension.h | 19 | ||||
-rw-r--r-- | tools/telemetry/telemetry/desktop_browser_backend.py | 21 |
12 files changed, 188 insertions, 106 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 9c126c7..e1908ec 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -20,7 +20,7 @@ #include "chrome/browser/browsing_data/browsing_data_helper.h" #include "chrome/browser/browsing_data/browsing_data_remover.h" #include "chrome/browser/character_encoding.h" -#include "chrome/browser/chrome_benchmarking_message_filter.h" +#include "chrome/browser/chrome_net_benchmarking_message_filter.h" #include "chrome/browser/chrome_quota_permission_context.h" #include "chrome/browser/content_settings/content_settings_utils.h" #include "chrome/browser/content_settings/cookie_settings.h" @@ -648,8 +648,11 @@ void ChromeContentBrowserClient::RenderProcessHostCreated( content::RenderProcessHost* host) { int id = host->GetID(); Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); + net::URLRequestContextGetter* context = + profile->GetRequestContextForRenderProcess(id); + host->GetChannel()->AddFilter(new ChromeRenderMessageFilter( - id, profile, profile->GetRequestContextForRenderProcess(id))); + id, profile, context)); #if defined(ENABLE_PLUGINS) host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile)); #endif @@ -662,8 +665,8 @@ void ChromeContentBrowserClient::RenderProcessHostCreated( #if defined(OS_MACOSX) host->GetChannel()->AddFilter(new SpellCheckMessageFilterMac()); #endif - host->GetChannel()->AddFilter(new ChromeBenchmarkingMessageFilter( - id, profile, profile->GetRequestContextForRenderProcess(id))); + host->GetChannel()->AddFilter(new ChromeNetBenchmarkingMessageFilter( + id, profile, context)); host->GetChannel()->AddFilter( new prerender::PrerenderMessageFilter(id, profile)); diff --git a/chrome/browser/chrome_benchmarking_message_filter.cc b/chrome/browser/chrome_net_benchmarking_message_filter.cc index 5be4df1..abe3652 100644 --- a/chrome/browser/chrome_benchmarking_message_filter.cc +++ b/chrome/browser/chrome_net_benchmarking_message_filter.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chrome_benchmarking_message_filter.h" +#include "chrome/browser/chrome_net_benchmarking_message_filter.h" #include "base/bind.h" #include "base/bind_helpers.h" @@ -23,7 +23,7 @@ namespace { -void ClearCacheCallback(ChromeBenchmarkingMessageFilter* filter, +void ClearCacheCallback(ChromeNetBenchmarkingMessageFilter* filter, IPC::Message* reply_msg, int result) { ChromeViewHostMsg_ClearCache::WriteReplyParams(reply_msg, result); @@ -32,7 +32,7 @@ void ClearCacheCallback(ChromeBenchmarkingMessageFilter* filter, } // namespace -ChromeBenchmarkingMessageFilter::ChromeBenchmarkingMessageFilter( +ChromeNetBenchmarkingMessageFilter::ChromeNetBenchmarkingMessageFilter( int render_process_id, Profile* profile, net::URLRequestContextGetter* request_context) @@ -41,13 +41,13 @@ ChromeBenchmarkingMessageFilter::ChromeBenchmarkingMessageFilter( request_context_(request_context) { } -ChromeBenchmarkingMessageFilter::~ChromeBenchmarkingMessageFilter() { +ChromeNetBenchmarkingMessageFilter::~ChromeNetBenchmarkingMessageFilter() { } -bool ChromeBenchmarkingMessageFilter::OnMessageReceived( +bool ChromeNetBenchmarkingMessageFilter::OnMessageReceived( const IPC::Message& message, bool* message_was_ok) { bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(ChromeBenchmarkingMessageFilter, message, + IPC_BEGIN_MESSAGE_MAP_EX(ChromeNetBenchmarkingMessageFilter, message, *message_was_ok) IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CloseCurrentConnections, OnCloseCurrentConnections) @@ -62,7 +62,7 @@ bool ChromeBenchmarkingMessageFilter::OnMessageReceived( return handled; } -void ChromeBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) { +void ChromeNetBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) { // This function is disabled unless the user has enabled // benchmarking extensions. if (!CheckBenchmarkingEnabled()) { @@ -86,7 +86,7 @@ void ChromeBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) { Send(reply_msg); } -void ChromeBenchmarkingMessageFilter::OnClearHostResolverCache(int* result) { +void ChromeNetBenchmarkingMessageFilter::OnClearHostResolverCache(int* result) { // This function is disabled unless the user has enabled // benchmarking extensions. if (!CheckBenchmarkingEnabled()) { @@ -104,7 +104,7 @@ void ChromeBenchmarkingMessageFilter::OnClearHostResolverCache(int* result) { // TODO(lzheng): This only enables spdy over ssl. Enable spdy for http // when needed. -void ChromeBenchmarkingMessageFilter::OnEnableSpdy(bool enable) { +void ChromeNetBenchmarkingMessageFilter::OnEnableSpdy(bool enable) { // This function is disabled unless the user has enabled // benchmarking extensions. if (!CheckBenchmarkingEnabled()) { @@ -119,7 +119,7 @@ void ChromeBenchmarkingMessageFilter::OnEnableSpdy(bool enable) { } } -void ChromeBenchmarkingMessageFilter::OnCloseCurrentConnections() { +void ChromeNetBenchmarkingMessageFilter::OnCloseCurrentConnections() { // This function is disabled unless the user has enabled // benchmarking extensions. if (!CheckBenchmarkingEnabled()) { @@ -130,7 +130,7 @@ void ChromeBenchmarkingMessageFilter::OnCloseCurrentConnections() { http_transaction_factory()->GetCache()->CloseAllConnections(); } -void ChromeBenchmarkingMessageFilter::OnSetCacheMode(bool enabled) { +void ChromeNetBenchmarkingMessageFilter::OnSetCacheMode(bool enabled) { // This function is disabled unless the user has enabled // benchmarking extensions. if (!CheckBenchmarkingEnabled()) { @@ -144,7 +144,7 @@ void ChromeBenchmarkingMessageFilter::OnSetCacheMode(bool enabled) { http_cache->set_mode(mode); } -void ChromeBenchmarkingMessageFilter::OnClearPredictorCache(int* result) { +void ChromeNetBenchmarkingMessageFilter::OnClearPredictorCache(int* result) { // This function is disabled unless the user has enabled // benchmarking extensions. if (!CheckBenchmarkingEnabled()) { @@ -157,13 +157,14 @@ void ChromeBenchmarkingMessageFilter::OnClearPredictorCache(int* result) { *result = 0; } -bool ChromeBenchmarkingMessageFilter::CheckBenchmarkingEnabled() const { +bool ChromeNetBenchmarkingMessageFilter::CheckBenchmarkingEnabled() const { static bool checked = false; static bool result = false; if (!checked) { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - result = command_line.HasSwitch(switches::kEnableBenchmarking); + result = command_line.HasSwitch(switches::kEnableNetBenchmarking); checked = true; } return result; } + diff --git a/chrome/browser/chrome_benchmarking_message_filter.h b/chrome/browser/chrome_net_benchmarking_message_filter.h index ca1ae0f..6fa1d99 100644 --- a/chrome/browser/chrome_benchmarking_message_filter.h +++ b/chrome/browser/chrome_net_benchmarking_message_filter.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROME_BENCHMARKING_MESSAGE_FILTER_H_ -#define CHROME_BROWSER_CHROME_BENCHMARKING_MESSAGE_FILTER_H_ +#ifndef CHROME_BROWSER_CHROME_NET_BENCHMARKING_MESSAGE_FILTER_H_ +#define CHROME_BROWSER_CHROME_NET_BENCHMARKING_MESSAGE_FILTER_H_ #include "content/public/browser/browser_message_filter.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" @@ -16,9 +16,10 @@ class Profile; // This class filters out incoming Chrome-specific benchmarking IPC messages // for the renderer process on the IPC thread. -class ChromeBenchmarkingMessageFilter : public content::BrowserMessageFilter { +class ChromeNetBenchmarkingMessageFilter + : public content::BrowserMessageFilter { public: - ChromeBenchmarkingMessageFilter( + ChromeNetBenchmarkingMessageFilter( int render_process_id, Profile* profile, net::URLRequestContextGetter* request_context); @@ -28,7 +29,7 @@ class ChromeBenchmarkingMessageFilter : public content::BrowserMessageFilter { bool* message_was_ok) OVERRIDE; private: - virtual ~ChromeBenchmarkingMessageFilter(); + virtual ~ChromeNetBenchmarkingMessageFilter(); // Message handlers. void OnCloseCurrentConnections(); @@ -48,8 +49,8 @@ class ChromeBenchmarkingMessageFilter : public content::BrowserMessageFilter { Profile* profile_; scoped_refptr<net::URLRequestContextGetter> request_context_; - DISALLOW_COPY_AND_ASSIGN(ChromeBenchmarkingMessageFilter); + DISALLOW_COPY_AND_ASSIGN(ChromeNetBenchmarkingMessageFilter); }; -#endif // CHROME_BROWSER_CHROME_BENCHMARKING_MESSAGE_FILTER_H_ +#endif // CHROME_BROWSER_CHROME_NET_BENCHMARKING_MESSAGE_FILTER_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 7f8130d..adde372 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -425,8 +425,8 @@ 'browser/certificate_viewer.h', 'browser/character_encoding.cc', 'browser/character_encoding.h', - 'browser/chrome_benchmarking_message_filter.cc', - 'browser/chrome_benchmarking_message_filter.h', + 'browser/chrome_net_benchmarking_message_filter.cc', + 'browser/chrome_net_benchmarking_message_filter.h', 'browser/chrome_browser_application_mac.h', 'browser/chrome_browser_application_mac.mm', 'browser/chrome_browser_field_trials.cc', diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index d7aabab..3db7244 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -140,6 +140,8 @@ 'renderer/net/predictor_queue.h', 'renderer/net/renderer_net_predictor.cc', 'renderer/net/renderer_net_predictor.h', + 'renderer/net_benchmarking_extension.cc', + 'renderer/net_benchmarking_extension.h', 'renderer/one_click_signin_agent.cc', 'renderer/one_click_signin_agent.h', 'renderer/playback_extension.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index f3620aa..dacabd4 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -562,6 +562,9 @@ const char kEnableNaClExceptionHandling[] = "enable-nacl-exception-handling"; // Enables the native messaging extensions API. const char kEnableNativeMessaging[] = "enable-native-messaging"; +// Enables the network-related benchmarking extensions. +const char kEnableNetBenchmarking[] = "enable-net-benchmarking"; + // Enables the new Autofill UI, which is part of the browser process rather than // part of the renderer process. http://crbug.com/51644 const char kEnableNewAutofillUi[] = "enable-new-autofill-ui"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 0d2d837..1cc0c8c 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -159,6 +159,7 @@ extern const char kEnableNaCl[]; extern const char kEnableNaClDebug[]; extern const char kEnableNaClExceptionHandling[]; extern const char kEnableNativeMessaging[]; +extern const char kEnableNetBenchmarking[]; extern const char kEnableNewAutofillHeuristics[]; extern const char kEnableNewAutofillUi[]; extern const char kEnableNpn[]; diff --git a/chrome/renderer/benchmarking_extension.cc b/chrome/renderer/benchmarking_extension.cc index 1125550..7572a40 100644 --- a/chrome/renderer/benchmarking_extension.cc +++ b/chrome/renderer/benchmarking_extension.cc @@ -7,14 +7,10 @@ #include "base/command_line.h" #include "base/metrics/stats_table.h" #include "base/time.h" -#include "chrome/common/benchmarking_messages.h" #include "content/public/common/content_switches.h" #include "content/public/renderer/render_thread.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" #include "v8/include/v8.h" -using WebKit::WebCache; - const char kBenchmarkingExtensionName[] = "v8/Benchmarking"; namespace extensions_v8 { @@ -29,30 +25,10 @@ class BenchmarkingWrapper : public v8::Extension { "if (typeof(chrome.benchmarking) == 'undefined') {" " chrome.benchmarking = {};" "};" - "chrome.benchmarking.clearCache = function() {" - " native function ClearCache();" - " ClearCache();" - "};" - "chrome.benchmarking.clearHostResolverCache = function() {" - " native function ClearHostResolverCache();" - " ClearHostResolverCache();" - "};" - "chrome.benchmarking.clearPredictorCache = function() {" - " native function ClearPredictorCache();" - " ClearPredictorCache();" - "};" - "chrome.benchmarking.closeConnections = function() {" - " native function CloseConnections();" - " CloseConnections();" - "};" "chrome.benchmarking.counter = function(name) {" " native function GetCounter();" " return GetCounter(name);" "};" - "chrome.benchmarking.enableSpdy = function(name) {" - " native function EnableSpdy();" - " EnableSpdy(name);" - "};" "chrome.benchmarking.isSingleProcess = function() {" " native function IsSingleProcess();" " return IsSingleProcess();" @@ -80,18 +56,8 @@ class BenchmarkingWrapper : public v8::Extension { ) {} virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( - v8::Handle<v8::String> name) OVERRIDE { - if (name->Equals(v8::String::New("CloseConnections"))) { - return v8::FunctionTemplate::New(CloseConnections); - } else if (name->Equals(v8::String::New("ClearCache"))) { - return v8::FunctionTemplate::New(ClearCache); - } else if (name->Equals(v8::String::New("ClearHostResolverCache"))) { - return v8::FunctionTemplate::New(ClearHostResolverCache); - } else if (name->Equals(v8::String::New("ClearPredictorCache"))) { - return v8::FunctionTemplate::New(ClearPredictorCache); - } else if (name->Equals(v8::String::New("EnableSpdy"))) { - return v8::FunctionTemplate::New(EnableSpdy); - } else if (name->Equals(v8::String::New("GetCounter"))) { + v8::Handle<v8::String> name) { + if (name->Equals(v8::String::New("GetCounter"))) { return v8::FunctionTemplate::New(GetCounter); } else if (name->Equals(v8::String::New("IsSingleProcess"))) { return v8::FunctionTemplate::New(IsSingleProcess); @@ -102,44 +68,6 @@ class BenchmarkingWrapper : public v8::Extension { 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(); - } - - static v8::Handle<v8::Value> ClearCache(const v8::Arguments& args) { - int rv; - content::RenderThread::Get()->Send(new ChromeViewHostMsg_ClearCache(&rv)); - WebCache::clear(); - return v8::Undefined(); - } - - static v8::Handle<v8::Value> ClearHostResolverCache( - const v8::Arguments& args) { - int rv; - content::RenderThread::Get()->Send( - new ChromeViewHostMsg_ClearHostResolverCache(&rv)); - return v8::Undefined(); - } - - static v8::Handle<v8::Value> ClearPredictorCache( - const v8::Arguments& args) { - int rv; - content::RenderThread::Get()->Send( - new ChromeViewHostMsg_ClearPredictorCache(&rv)); - return v8::Undefined(); - } - - static v8::Handle<v8::Value> EnableSpdy(const v8::Arguments& args) { - if (!args.Length() || !args[0]->IsBoolean()) - return v8::Undefined(); - - content::RenderThread::Get()->Send(new ChromeViewHostMsg_EnableSpdy( - args[0]->BooleanValue())); - return v8::Undefined(); - } - static v8::Handle<v8::Value> GetCounter(const v8::Arguments& args) { if (!args.Length() || !args[0]->IsString() || !base::StatsTable::current()) return v8::Undefined(); diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 9932f4b..bb74b7b 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -47,6 +47,7 @@ #include "chrome/renderer/external_extension.h" #include "chrome/renderer/loadtimes_extension_bindings.h" #include "chrome/renderer/net/renderer_net_predictor.h" +#include "chrome/renderer/net_benchmarking_extension.h" #include "chrome/renderer/one_click_signin_agent.h" #include "chrome/renderer/page_click_tracker.h" #include "chrome/renderer/page_load_histograms.h" @@ -225,6 +226,8 @@ void ChromeContentRendererClient::RenderThreadStarted() { CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableBenchmarking)) thread->RegisterExtension(extensions_v8::BenchmarkingExtension::Get()); + if (command_line->HasSwitch(switches::kEnableNetBenchmarking)) + thread->RegisterExtension(extensions_v8::NetBenchmarkingExtension::Get()); if (command_line->HasSwitch(switches::kPlaybackMode) || command_line->HasSwitch(switches::kRecordMode) || diff --git a/chrome/renderer/net_benchmarking_extension.cc b/chrome/renderer/net_benchmarking_extension.cc new file mode 100644 index 0000000..9fb0581 --- /dev/null +++ b/chrome/renderer/net_benchmarking_extension.cc @@ -0,0 +1,110 @@ +// 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 "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" +#include "v8/include/v8.h" + +using WebKit::WebCache; + +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.clearCache = function() {" + " native function ClearCache();" + " ClearCache();" + "};" + "chrome.benchmarking.clearHostResolverCache = function() {" + " native function ClearHostResolverCache();" + " ClearHostResolverCache();" + "};" + "chrome.benchmarking.clearPredictorCache = function() {" + " native function ClearPredictorCache();" + " ClearPredictorCache();" + "};" + "chrome.benchmarking.closeConnections = function() {" + " native function CloseConnections();" + " CloseConnections();" + "};" + "chrome.benchmarking.enableSpdy = function(name) {" + " native function EnableSpdy();" + " EnableSpdy(name);" + "};" + ) {} + + virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( + v8::Handle<v8::String> name) { + if (name->Equals(v8::String::New("ClearCache"))) { + return v8::FunctionTemplate::New(ClearCache); + } else if (name->Equals(v8::String::New("ClearHostResolverCache"))) { + return v8::FunctionTemplate::New(ClearHostResolverCache); + } else if (name->Equals(v8::String::New("ClearPredictorCache"))) { + return v8::FunctionTemplate::New(ClearPredictorCache); + } else if (name->Equals(v8::String::New("EnableSpdy"))) { + return v8::FunctionTemplate::New(EnableSpdy); + } else if (name->Equals(v8::String::New("CloseConnections"))) { + return v8::FunctionTemplate::New(CloseConnections); + } + + return v8::Handle<v8::FunctionTemplate>(); + } + + static v8::Handle<v8::Value> ClearCache(const v8::Arguments& args) { + int rv; + content::RenderThread::Get()->Send(new ChromeViewHostMsg_ClearCache(&rv)); + WebCache::clear(); + return v8::Undefined(); + } + + static v8::Handle<v8::Value> ClearHostResolverCache( + const v8::Arguments& args) { + int rv; + content::RenderThread::Get()->Send( + new ChromeViewHostMsg_ClearHostResolverCache(&rv)); + return v8::Undefined(); + } + + static v8::Handle<v8::Value> ClearPredictorCache( + const v8::Arguments& args) { + int rv; + content::RenderThread::Get()->Send( + new ChromeViewHostMsg_ClearPredictorCache(&rv)); + return v8::Undefined(); + } + + static v8::Handle<v8::Value> CloseConnections(const v8::Arguments& args) { + content::RenderThread::Get()->Send( + new ChromeViewHostMsg_CloseCurrentConnections()); + return v8::Undefined(); + } + + static v8::Handle<v8::Value> EnableSpdy(const v8::Arguments& args) { + if (!args.Length() || !args[0]->IsBoolean()) + return v8::Undefined(); + + content::RenderThread::Get()->Send(new ChromeViewHostMsg_EnableSpdy( + args[0]->BooleanValue())); + return v8::Undefined(); + } +}; + +v8::Extension* NetBenchmarkingExtension::Get() { + return new NetBenchmarkingWrapper(); +} + +} // namespace extensions_v8 diff --git a/chrome/renderer/net_benchmarking_extension.h b/chrome/renderer/net_benchmarking_extension.h new file mode 100644 index 0000000..f3083d3 --- /dev/null +++ b/chrome/renderer/net_benchmarking_extension.h @@ -0,0 +1,19 @@ +// 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. + +#ifndef CHROME_RENDERER_NET_BENCHMARKING_EXTENSION_H_ +#define CHROME_RENDERER_NET_BENCHMARKING_EXTENSION_H_ + +#include "chrome/renderer/benchmarking_extension.h" + +namespace extensions_v8 { + +class NetBenchmarkingExtension { + public: + static v8::Extension* Get(); +}; + +} // namespace extensions_v8 + +#endif // CHROME_RENDERER_NET_BENCHMARKING_EXTENSION_H_ diff --git a/tools/telemetry/telemetry/desktop_browser_backend.py b/tools/telemetry/telemetry/desktop_browser_backend.py index cb4d7c92..31ccc3f 100644 --- a/tools/telemetry/telemetry/desktop_browser_backend.py +++ b/tools/telemetry/telemetry/desktop_browser_backend.py @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import os as os +import re import subprocess as subprocess import shutil import tempfile @@ -52,11 +53,15 @@ class DesktopBrowserBackend(browser_backend.BrowserBackend): def GetBrowserStartupArgs(self): args = super(DesktopBrowserBackend, self).GetBrowserStartupArgs() args.append('--remote-debugging-port=%i' % self._port) - args.append('--window-size=1280,1024') - args.append('--enable-benchmarking') - if not self.options.dont_override_profile: - self._tmpdir = tempfile.mkdtemp() - args.append('--user-data-dir=%s' % self._tmpdir) + if not self.is_content_shell: + args.append('--window-size=1280,1024') + if self._GetChromeBranchNumber() >= 1404: + args.append('--enable-net-benchmarking') + else: + args.append('--enable-benchmarking') + if not self.options.dont_override_profile: + self._tmpdir = tempfile.mkdtemp() + args.append('--user-data-dir=%s' % self._tmpdir) return args def IsBrowserRunning(self): @@ -113,6 +118,12 @@ class DesktopBrowserBackend(browser_backend.BrowserBackend): def CreateForwarder(self, *port_pairs): return DoNothingForwarder(*port_pairs) + def _GetChromeBranchNumber(self): + version = subprocess.check_output([self._executable, '--version']) + match = re.match('[^\d]+\s+\d+\.\d+\.(\d+)\.\d+.*', version) + assert match + return int(match.group(1)) + class DoNothingForwarder(object): def __init__(self, *port_pairs): self._host_port = port_pairs[0].local_port |