diff options
author | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-02 06:38:45 +0000 |
---|---|---|
committer | ukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-02 06:38:45 +0000 |
commit | 4b6bcfac8cd147db4650b7a88f6bc1fe17342e5b (patch) | |
tree | 5cefbb73506002fe2291125dc6afd6ad7b985f2e /chrome/browser | |
parent | e6157551f851cae2da7756976fd6a276142427ac (diff) | |
download | chromium_src-4b6bcfac8cd147db4650b7a88f6bc1fe17342e5b.zip chromium_src-4b6bcfac8cd147db4650b7a88f6bc1fe17342e5b.tar.gz chromium_src-4b6bcfac8cd147db4650b7a88f6bc1fe17342e5b.tar.bz2 |
Add --websocket-live-experiment-host flag to debug websocket live experiment.
If --websocket-live-experiment-host is specified, it is used for host of websocket live experiment in debug build.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1524005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43460 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc | 41 | ||||
-rw-r--r-- | chrome/browser/net/websocket_experiment/websocket_experiment_task.cc | 19 |
2 files changed, 45 insertions, 15 deletions
diff --git a/chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc b/chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc index c632e77..b9ea7c4 100644 --- a/chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc +++ b/chrome/browser/net/websocket_experiment/websocket_experiment_runner.cc @@ -4,11 +4,13 @@ #include "chrome/browser/net/websocket_experiment/websocket_experiment_runner.h" +#include "base/command_line.h" #include "base/compiler_specific.h" #include "base/field_trial.h" #include "base/message_loop.h" #include "base/task.h" #include "chrome/browser/chrome_thread.h" +#include "chrome/common/chrome_switches.h" #include "net/base/net_errors.h" #include "net/websockets/websocket.h" @@ -27,7 +29,15 @@ void WebSocketExperimentRunner::Start() { scoped_refptr<FieldTrial> trial = new FieldTrial("WebSocketExperiment", 1000); trial->AppendGroup("_active", 5); // 0.5% in _active group. - if (trial->group() == FieldTrial::kNotParticipating) + bool run_experiment = (trial->group() != FieldTrial::kNotParticipating); +#ifndef NDEBUG + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + std::string experiment_host = command_line.GetSwitchValueASCII( + switches::kWebSocketLiveExperimentHost); + if (!experiment_host.empty()) + run_experiment = true; +#endif + if (!run_experiment) return; runner = new WebSocketExperimentRunner; @@ -77,35 +87,46 @@ void WebSocketExperimentRunner::InitConfig() { config_.initial_delay_ms = 5 * 60 * 1000; // 5 mins config_.next_delay_ms = 12 * 60 * 60 * 1000; // 12 hours + std::string experiment_host = kExperimentHost; +#ifndef NDEBUG + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + std::string experiment_host_override = command_line.GetSwitchValueASCII( + switches::kWebSocketLiveExperimentHost); + if (!experiment_host_override.empty()) { + experiment_host = experiment_host_override; + config_.initial_delay_ms = 5 * 1000; // 5 secs. + } +#endif + WebSocketExperimentTask::Config task_config; task_config.protocol_version = net::WebSocket::DRAFT75; config_.ws_config = task_config; config_.ws_config.url = - GURL(StringPrintf("ws://%s/live_exp", kExperimentHost)); + GURL(StringPrintf("ws://%s/live_exp", experiment_host.c_str())); config_.ws_config.ws_location = - StringPrintf("ws://%s/live_exp", kExperimentHost); + StringPrintf("ws://%s/live_exp", experiment_host.c_str()); config_.ws_config.http_url = - GURL(StringPrintf("http://%s/", kExperimentHost)); + GURL(StringPrintf("http://%s/", experiment_host.c_str())); config_.wss_config = task_config; config_.wss_config.url = - GURL(StringPrintf("wss://%s/live_exp", kExperimentHost)); + GURL(StringPrintf("wss://%s/live_exp", experiment_host.c_str())); config_.wss_config.ws_location = - StringPrintf("wss://%s/live_exp", kExperimentHost); + StringPrintf("wss://%s/live_exp", experiment_host.c_str()); config_.wss_config.http_url = - GURL(StringPrintf("https://%s/", kExperimentHost)); + GURL(StringPrintf("https://%s/", experiment_host.c_str())); config_.ws_nondefault_config = task_config; config_.ws_nondefault_config.url = GURL(StringPrintf("ws://%s:%d/live_exp", - kExperimentHost, kAlternativePort)); + experiment_host.c_str(), kAlternativePort)); config_.ws_nondefault_config.ws_location = StringPrintf("ws://%s:%d/live_exp", - kExperimentHost, kAlternativePort); + experiment_host.c_str(), kAlternativePort); config_.ws_nondefault_config.http_url = GURL(StringPrintf("http://%s:%d/", - kExperimentHost, kAlternativePort)); + experiment_host.c_str(), kAlternativePort)); } void WebSocketExperimentRunner::DoLoop() { diff --git a/chrome/browser/net/websocket_experiment/websocket_experiment_task.cc b/chrome/browser/net/websocket_experiment/websocket_experiment_task.cc index 1dc468a..174c6d8 100644 --- a/chrome/browser/net/websocket_experiment/websocket_experiment_task.cc +++ b/chrome/browser/net/websocket_experiment/websocket_experiment_task.cc @@ -208,6 +208,7 @@ void WebSocketExperimentTask::ReleaseHistogram() { } void WebSocketExperimentTask::Run() { + DLOG(INFO) << "Run WebSocket experiment for " << config_.url; next_state_ = STATE_URL_FETCH; DoLoop(net::OK); } @@ -272,7 +273,8 @@ void WebSocketExperimentTask::OnURLFetchComplete( RevokeTimeoutTimer(); int result = net::ERR_FAILED; if (next_state_ != STATE_URL_FETCH_COMPLETE) { - DLOG(INFO) << "unexpected state=" << next_state_; + DLOG(INFO) << "unexpected state=" << next_state_ + << " at OnURLFetchComplete for " << config_.http_url; result = net::ERR_UNEXPECTED; } else if (response_code == 200 || response_code == 304) { result = net::OK; @@ -289,7 +291,8 @@ void WebSocketExperimentTask::OnOpen(net::WebSocket* websocket) { if (next_state_ == STATE_WEBSOCKET_CONNECT_COMPLETE) result = net::OK; else - DLOG(INFO) << "unexpected state=" << next_state_; + DLOG(INFO) << "unexpected state=" << next_state_ + << " at OnOpen for " << config_.url; DoLoop(result); } @@ -312,7 +315,8 @@ void WebSocketExperimentTask::OnMessage( result = net::OK; break; default: - DLOG(INFO) << "unexpected state=" << next_state_; + DLOG(INFO) << "unexpected state=" << next_state_ + << " at OnMessage for " << config_.url; break; } DoLoop(result); @@ -333,7 +337,9 @@ void WebSocketExperimentTask::OnClose(net::WebSocket* websocket) { void WebSocketExperimentTask::OnError( const net::WebSocket* websocket, int error) { - DLOG(INFO) << "WebSocket error=" << net::ErrorToString(error); + DLOG(INFO) << "WebSocket error=" << net::ErrorToString(error) + << " next_state=" << next_state_ + << " for " << config_.url; last_websocket_error_ = error; } @@ -342,7 +348,8 @@ void WebSocketExperimentTask::SetContext(Context* context) { } void WebSocketExperimentTask::OnTimedOut() { - DLOG(INFO) << "OnTimedOut"; + DLOG(INFO) << "OnTimedOut next_state=" << next_state_ + << " for " << config_.url; RevokeTimeoutTimer(); DoLoop(net::ERR_TIMED_OUT); } @@ -590,6 +597,8 @@ void WebSocketExperimentTask::Finish(int result) { callback_->Run(result); if (websocket) websocket->DetachDelegate(); + DLOG(INFO) << "Finish WebSocket experiment for " << config_.url + << " result=" << result; } } // namespace chrome_browser_net |