Skip to content

Commit

Permalink
Enable/Disable Spdy in benchmarking.
Browse files Browse the repository at this point in the history
Test=none
Bug=52624
Review URL: http://codereview.chromium.org/3169022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56704 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
lzheng@chromium.org committed Aug 19, 2010
1 parent 3695535 commit 12893c3
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 0 deletions.
12 changes: 12 additions & 0 deletions chrome/browser/renderer_host/resource_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
#include "net/base/net_errors.h"
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_cache.h"
#include "net/http/http_network_layer.h"
#include "net/http/http_transaction_factory.h"
#include "net/url_request/url_request_context.h"
#include "third_party/WebKit/WebKit/chromium/public/WebNotificationPresenter.h"
Expand Down Expand Up @@ -485,6 +486,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_ClearCache, OnClearCache)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidGenerateCacheableMetadata,
OnCacheableMetadataAvailable)
IPC_MESSAGE_HANDLER(ViewHostMsg_EnableSpdy, OnEnableSpdy)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileSize, OnGetFileSize)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetFileModificationTime,
OnGetFileModificationTime)
Expand Down Expand Up @@ -1368,6 +1370,16 @@ void ResourceMessageFilter::OnCacheableMetadataAvailable(
url, base::Time::FromDoubleT(expected_response_time), buf, data.size());
}

// TODO(lzheng): This only enables spdy over ssl. Enable spdy for http
// when needed.
void ResourceMessageFilter::OnEnableSpdy(bool enable) {
if (enable) {
net::HttpNetworkLayer::EnableSpdy("npn");
} else {
net::HttpNetworkLayer::EnableSpdy("npn-http");
}
}

void ResourceMessageFilter::OnGetFileSize(const FilePath& path,
IPC::Message* reply_msg) {
// Get file size only when the child process has been granted permission to
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/renderer_host/resource_message_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnCacheableMetadataAvailable(const GURL& url,
double expected_response_time,
const std::vector<char>& data);
void OnEnableSpdy(bool enable);
void OnGetFileSize(const FilePath& path, IPC::Message* reply_msg);
void OnGetFileModificationTime(const FilePath& path, IPC::Message* reply_msg);
void OnGetFileInfoOnFileThread(const FilePath& path,
Expand Down
5 changes: 5 additions & 0 deletions chrome/common/render_messages_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,11 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_SYNC_MESSAGE_CONTROL0_1(ViewHostMsg_ClearCache,
int /* result */)

// Message sent from the renderer to the browser to request that the browser
// enable or disable spdy. Used for debugging/testing/benchmarking.
IPC_MESSAGE_CONTROL1(ViewHostMsg_EnableSpdy,
bool /* enable */)

// Message sent from the renderer to the browser to request that the browser
// cache |data| associated with |url|.
IPC_MESSAGE_CONTROL3(ViewHostMsg_DidGenerateCacheableMetadata,
Expand Down
4 changes: 4 additions & 0 deletions chrome/renderer/render_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,10 @@ void RenderThread::ClearCache() {
Send(new ViewHostMsg_ClearCache(&rv));
}

void RenderThread::EnableSpdy(bool enable) {
Send(new ViewHostMsg_EnableSpdy(enable));
}

void RenderThread::UpdateActiveExtensions() {
// In single-process mode, the browser process reports the active extensions.
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
Expand Down
3 changes: 3 additions & 0 deletions chrome/renderer/render_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ class RenderThread : public RenderThreadBase,
// Sends a message to the browser to clear the disk cache.
void ClearCache();

// Sends a message to the browser to enable/disable spdy.
void EnableSpdy(bool enable);

// Update the list of active extensions that will be reported when we crash.
void UpdateActiveExtensions();

Expand Down
4 changes: 4 additions & 0 deletions chrome/renderer/renderer_glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ bool IsSingleProcess() {
return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess);
}

void EnableSpdy(bool enable) {
RenderThread::current()->EnableSpdy(enable);
}

#if defined(OS_LINUX)
int MatchFontWithFallback(const std::string& face, bool bold,
bool italic, int charset) {
Expand Down
15 changes: 15 additions & 0 deletions webkit/extensions/v8/benchmarking_extension.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "base/command_line.h"
#include "base/stats_table.h"
#include "net/http/http_network_layer.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCache.h"
#include "webkit/extensions/v8/benchmarking_extension.h"
#include "webkit/glue/webkit_glue.h"
Expand Down Expand Up @@ -36,6 +37,10 @@ class BenchmarkingWrapper : public v8::Extension {
" 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();"
Expand All @@ -48,6 +53,8 @@ class BenchmarkingWrapper : public v8::Extension {
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("EnableSpdy"))) {
return v8::FunctionTemplate::New(EnableSpdy);
} else if (name->Equals(v8::String::New("GetCounter"))) {
return v8::FunctionTemplate::New(GetCounter);
} else if (name->Equals(v8::String::New("IsSingleProcess"))) {
Expand All @@ -67,6 +74,14 @@ class BenchmarkingWrapper : public v8::Extension {
return v8::Undefined();
}

static v8::Handle<v8::Value> EnableSpdy(const v8::Arguments& args) {
if (!args.Length() || !args[0]->IsBoolean())
return v8::Undefined();

webkit_glue::EnableSpdy(args[0]->BooleanValue());
return v8::Undefined();
}

static v8::Handle<v8::Value> GetCounter(const v8::Arguments& args) {
if (!args.Length() || !args[0]->IsString() || !StatsTable::current())
return v8::Undefined();
Expand Down
3 changes: 3 additions & 0 deletions webkit/glue/webkit_glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ std::string GetProductVersion();
// Returns true if the embedder is running in single process mode.
bool IsSingleProcess();

// Enables/Disables Spdy for requests afterwards. Used for benchmarking.
void EnableSpdy(bool enable);

#if defined(OS_LINUX)
// Return a read-only file descriptor to the font which best matches the given
// properties or -1 on failure.
Expand Down
3 changes: 3 additions & 0 deletions webkit/support/webkit_support_glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ bool IsSingleProcess() {
return true;
}

void EnableSpdy(bool enable) {
}

#if defined(OS_LINUX)
int MatchFontWithFallback(const std::string& face, bool bold,
bool italic, int charset) {
Expand Down
4 changes: 4 additions & 0 deletions webkit/tools/test_shell/test_shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,10 @@ void ClearCache() {
// Used in benchmarking, Ignored for test_shell.
}

void EnableSpdy(bool enable) {
// Used in benchmarking, Ignored for test_shell.
}

std::string GetProductVersion() {
return std::string("Chrome/0.0.0.0");
}
Expand Down

0 comments on commit 12893c3

Please sign in to comment.