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

Unified Diff: chrome/browser/chromeos/webproxy_task.cc

Issue 6801008: Websocket to TCP proxy running in a separate thread (only on ChromeOS). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: g Created 9 years, 8 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/chromeos/webproxy_task.cc
diff --git a/chrome/browser/chromeos/webproxy_task.cc b/chrome/browser/chromeos/webproxy_task.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cca60ea48731e7018afd75aae8a4927a1e0d3e55
--- /dev/null
+++ b/chrome/browser/chromeos/webproxy_task.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2011 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 "webproxy_task.h"
+
+#include <netinet/in.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include "base/threading/platform_thread.h"
+#include "chrome/browser/chromeos/net/webproxy/serv.h"
+
+namespace chromeos {
+
+void WebproxyTask::Run() {
+ const int kPort = 10101;
+
+ // Configure allowed origins.
+ std::vector<std::string> allowed_origins;
+ allowed_origins.push_back("chrome-extension://XXXXXXXXXXXXXXXXXXXXXX");
zel 2011/04/07 16:54:12 let's replace one of these with haiffjcadagjlijogg
Denis Lagno 2011/04/11 23:21:27 Done.
+ allowed_origins.push_back("chrome-extension://YYYYYYYYYYYYYYYYYYYYYY");
+
+ struct sockaddr_in sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(kPort);
+ sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ for (int sleep_ms = 1000;;) {
+ webproxy::Serv ws(
+ allowed_origins, reinterpret_cast<sockaddr*>(&sa), sizeof(sa));
+ ws.Run();
+ if (sleep_ms < 100 * 1000)
+ (sleep_ms *= 3) /= 2;
+ base::PlatformThread::Sleep(sleep_ms);
+ }
+}
+
+} // namespace chromeos
+

Powered by Google App Engine
This is Rietveld 408576698