OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "web_socket_proxy_controller.h" | 5 #include "web_socket_proxy_controller.h" |
6 | 6 |
7 #include <netinet/in.h> | 7 #include <netinet/in.h> |
8 #include <sys/wait.h> | 8 #include <sys/wait.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 base::Lock shutdown_lock; | 37 base::Lock shutdown_lock; |
38 }; | 38 }; |
39 | 39 |
40 base::LazyInstance<ProxyLifetime> g_proxy_lifetime(base::LINKER_INITIALIZED); | 40 base::LazyInstance<ProxyLifetime> g_proxy_lifetime(base::LINKER_INITIALIZED); |
41 | 41 |
42 void ProxyTask::Run() { | 42 void ProxyTask::Run() { |
43 LOG(INFO) << "Attempt to run web socket proxy task"; | 43 LOG(INFO) << "Attempt to run web socket proxy task"; |
44 const int kPort = 10101; | 44 const int kPort = 10101; |
45 | 45 |
46 // Configure allowed origins. Empty vector allows any origin. | 46 // Configure allowed origins. Empty vector allows any origin. |
Dmitry Polukhin
2011/05/16 09:41:39
Perhaps it make sense to add command line option t
Denis Lagno
2011/05/17 22:15:07
Done.
| |
47 std::vector<std::string> allowed_origins; | 47 std::vector<std::string> allowed_origins; |
48 allowed_origins.push_back( | 48 allowed_origins.push_back( |
49 "chrome-extension://haiffjcadagjlijoggckpgfnoeiflnem"); | 49 "chrome-extension://haiffjcadagjlijoggckpgfnoeiflnem"); |
50 allowed_origins.push_back( // For apitest. | |
51 "chrome-extension://mknjjldhaihcdajjbihghhiehamnpcak"); | |
50 | 52 |
51 struct sockaddr_in sa; | 53 struct sockaddr_in sa; |
52 memset(&sa, 0, sizeof(sa)); | 54 memset(&sa, 0, sizeof(sa)); |
53 sa.sin_family = AF_INET; | 55 sa.sin_family = AF_INET; |
54 sa.sin_port = htons(kPort); | 56 sa.sin_port = htons(kPort); |
55 sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | 57 sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
56 | 58 |
57 chromeos::WebSocketProxy* server = new chromeos::WebSocketProxy( | 59 chromeos::WebSocketProxy* server = new chromeos::WebSocketProxy( |
58 allowed_origins, reinterpret_cast<sockaddr*>(&sa), sizeof(sa)); | 60 allowed_origins, reinterpret_cast<sockaddr*>(&sa), sizeof(sa)); |
59 { | 61 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 LOG(INFO) << "WebSocketProxyController shutdown"; | 103 LOG(INFO) << "WebSocketProxyController shutdown"; |
102 base::AutoLock alk(g_proxy_lifetime.Get().shutdown_lock); | 104 base::AutoLock alk(g_proxy_lifetime.Get().shutdown_lock); |
103 g_proxy_lifetime.Get().shutdown_requested = true; | 105 g_proxy_lifetime.Get().shutdown_requested = true; |
104 if (g_proxy_lifetime.Get().server) | 106 if (g_proxy_lifetime.Get().server) |
105 g_proxy_lifetime.Get().server->Shutdown(); | 107 g_proxy_lifetime.Get().server->Shutdown(); |
106 } | 108 } |
107 } | 109 } |
108 | 110 |
109 } // namespace chromeos | 111 } // namespace chromeos |
110 | 112 |
OLD | NEW |