Chromium Code Reviews| 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 |
| + |