OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/web_socket_proxy.h" | 5 #include "chrome/browser/chromeos/web_socket_proxy.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 bool do_tls_; | 429 bool do_tls_; |
430 | 430 |
431 // We try to DNS resolve hostname in both IPv4 and IPv6 domains. | 431 // We try to DNS resolve hostname in both IPv4 and IPv6 domains. |
432 // Track resolution failures here. | 432 // Track resolution failures here. |
433 bool destresolution_ipv4_failed_; | 433 bool destresolution_ipv4_failed_; |
434 bool destresolution_ipv6_failed_; | 434 bool destresolution_ipv6_failed_; |
435 | 435 |
436 // Used to schedule a timeout for initial phase of connection. | 436 // Used to schedule a timeout for initial phase of connection. |
437 scoped_ptr<struct event> destconnect_timeout_event_; | 437 scoped_ptr<struct event> destconnect_timeout_event_; |
438 | 438 |
439 static base::LazyInstance<EventKeyMap, | 439 static base::LazyInstance<EventKeyMap>::Leaky evkey_map_; |
440 base::LeakyLazyInstanceTraits<EventKeyMap> > | |
441 evkey_map_; | |
442 static EventKey last_evkey_; | 440 static EventKey last_evkey_; |
443 | 441 |
444 DISALLOW_COPY_AND_ASSIGN(Conn); | 442 DISALLOW_COPY_AND_ASSIGN(Conn); |
445 }; | 443 }; |
446 | 444 |
447 class SSLChan : public MessageLoopForIO::Watcher { | 445 class SSLChan : public MessageLoopForIO::Watcher { |
448 public: | 446 public: |
449 static void Start(const net::AddressList& address_list, | 447 static void Start(const net::AddressList& address_list, |
450 const net::HostPortPair& host_port_pair, | 448 const net::HostPortPair& host_port_pair, |
451 int read_pipe, | 449 int read_pipe, |
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 cs->master_->ZapConn(cs); | 1886 cs->master_->ZapConn(cs); |
1889 else | 1887 else |
1890 cs->Shut(WS_CLOSE_DESTINATION_ERROR, | 1888 cs->Shut(WS_CLOSE_DESTINATION_ERROR, |
1891 "Failure reported on destination channel"); | 1889 "Failure reported on destination channel"); |
1892 } | 1890 } |
1893 | 1891 |
1894 // static | 1892 // static |
1895 Conn::EventKey Conn::last_evkey_ = 0; | 1893 Conn::EventKey Conn::last_evkey_ = 0; |
1896 | 1894 |
1897 // static | 1895 // static |
1898 base::LazyInstance<Conn::EventKeyMap, | 1896 base::LazyInstance<Conn::EventKeyMap>::Leaky |
1899 base::LeakyLazyInstanceTraits<Conn::EventKeyMap> > | |
1900 Conn::evkey_map_ = LAZY_INSTANCE_INITIALIZER; | 1897 Conn::evkey_map_ = LAZY_INSTANCE_INITIALIZER; |
1901 | 1898 |
1902 } // namespace | 1899 } // namespace |
1903 | 1900 |
1904 WebSocketProxy::WebSocketProxy(const std::vector<std::string>& allowed_origins) | 1901 WebSocketProxy::WebSocketProxy(const std::vector<std::string>& allowed_origins) |
1905 : impl_(new Serv(allowed_origins)) { | 1902 : impl_(new Serv(allowed_origins)) { |
1906 } | 1903 } |
1907 | 1904 |
1908 WebSocketProxy::~WebSocketProxy() { | 1905 WebSocketProxy::~WebSocketProxy() { |
1909 delete static_cast<Serv*>(impl_); | 1906 delete static_cast<Serv*>(impl_); |
1910 impl_ = NULL; | 1907 impl_ = NULL; |
1911 } | 1908 } |
1912 | 1909 |
1913 void WebSocketProxy::Run() { | 1910 void WebSocketProxy::Run() { |
1914 static_cast<Serv*>(impl_)->Run(); | 1911 static_cast<Serv*>(impl_)->Run(); |
1915 } | 1912 } |
1916 | 1913 |
1917 void WebSocketProxy::Shutdown() { | 1914 void WebSocketProxy::Shutdown() { |
1918 static_cast<Serv*>(impl_)->Shutdown(); | 1915 static_cast<Serv*>(impl_)->Shutdown(); |
1919 } | 1916 } |
1920 | 1917 |
1921 void WebSocketProxy::OnNetworkChange() { | 1918 void WebSocketProxy::OnNetworkChange() { |
1922 static_cast<Serv*>(impl_)->OnNetworkChange(); | 1919 static_cast<Serv*>(impl_)->OnNetworkChange(); |
1923 } | 1920 } |
1924 | 1921 |
1925 } // namespace chromeos | 1922 } // namespace chromeos |
OLD | NEW |