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

Unified Diff: chrome/browser/extensions/extension_web_socket_proxy_private_api.cc

Issue 8362027: websocket-to-TCP proxy: observe value of listening port in right place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reflected comments + rebased Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_web_socket_proxy_private_api.cc
diff --git a/chrome/browser/extensions/extension_web_socket_proxy_private_api.cc b/chrome/browser/extensions/extension_web_socket_proxy_private_api.cc
index bda21c7352e467bb092866d7e0020d0b6b7756c7..eda9a469e809ae72a6862046d195bdf8695c0f79 100644
--- a/chrome/browser/extensions/extension_web_socket_proxy_private_api.cc
+++ b/chrome/browser/extensions/extension_web_socket_proxy_private_api.cc
@@ -41,7 +41,7 @@ void WebSocketProxyPrivate::Finalize() {
if (is_finalized_)
return;
is_finalized_ = true;
- SendResponse(true);
+ SendResponse(listening_port_ > 0);
Release();
}
@@ -63,6 +63,8 @@ void WebSocketProxyPrivateGetURLForTCPFunction::Finalize() {
"ws://127.0.0.1:" + base::IntToString(listening_port_) +
"/tcpproxy?" + query_));
result_.reset(url);
+ if (listening_port_ < 1)
+ listening_port_ = chromeos::WebSocketProxyController::GetPort();
WebSocketProxyPrivate::Finalize();
}
@@ -80,12 +82,12 @@ bool WebSocketProxyPrivateGetPassportForTCPFunction::RunImpl() {
if (chromeos::WebSocketProxyController::CheckCredentials(
extension_id(), hostname, port,
chromeos::WebSocketProxyController::PLAIN_TCP)) {
- if (!chromeos::WebSocketProxyController::IsInitiated()) {
+ listening_port_ = chromeos::WebSocketProxyController::GetPort();
+ if (listening_port_ < 1) {
delay_response = true;
registrar_.Add(
this, chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED,
content::NotificationService::AllSources());
- chromeos::WebSocketProxyController::Initiate();
}
std::map<std::string, std::string> map;
@@ -132,12 +134,12 @@ bool WebSocketProxyPrivateGetURLForTCPFunction::RunImpl() {
extension_id(), hostname, port,
do_tls ? chromeos::WebSocketProxyController::TLS_OVER_TCP :
chromeos::WebSocketProxyController::PLAIN_TCP)) {
- if (!chromeos::WebSocketProxyController::IsInitiated()) {
+ listening_port_ = chromeos::WebSocketProxyController::GetPort();
+ if (listening_port_ < 1) {
delay_response = true;
registrar_.Add(
this, chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED,
content::NotificationService::AllSources());
- chromeos::WebSocketProxyController::Initiate();
}
std::map<std::string, std::string> map;
@@ -155,7 +157,7 @@ bool WebSocketProxyPrivateGetURLForTCPFunction::RunImpl() {
#endif // defined(OS_CHROMEOS)
if (delay_response) {
- const int kTimeout = 3;
+ const int kTimeout = 12;
timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeout),
this, &WebSocketProxyPrivate::Finalize);
} else {

Powered by Google App Engine
This is Rietveld 408576698