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

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: DLOG 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..31fd12248ddffe5db3ba134c07c2db6aa87bfb05 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();
}
@@ -59,10 +59,14 @@ void WebSocketProxyPrivateGetURLForTCPFunction::Observe(
}
void WebSocketProxyPrivateGetURLForTCPFunction::Finalize() {
+#if defined(OS_CHROMEOS)
StringValue* url = Value::CreateStringValue(std::string(
"ws://127.0.0.1:" + base::IntToString(listening_port_) +
"/tcpproxy?" + query_));
result_.reset(url);
+ if (listening_port_ < 1)
+ listening_port_ = chromeos::WebSocketProxyController::GetPort();
+#endif
WebSocketProxyPrivate::Finalize();
}
@@ -80,12 +84,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 +136,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 +159,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