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

Side by Side Diff: chrome/browser/chromeos/web_socket_proxy_controller.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 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_controller.h" 5 #include "chrome/browser/chromeos/web_socket_proxy_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include <netinet/in.h> 9 #include <netinet/in.h>
10 #include <sys/wait.h> 10 #include <sys/wait.h>
(...skipping 23 matching lines...) Expand all
34 class ProxyLifetime 34 class ProxyLifetime
35 : public net::NetworkChangeNotifier::ConnectionTypeObserver, 35 : public net::NetworkChangeNotifier::ConnectionTypeObserver,
36 public content::NotificationObserver { 36 public content::NotificationObserver {
37 public: 37 public:
38 ProxyLifetime() 38 ProxyLifetime()
39 : delay_ms_(1000), 39 : delay_ms_(1000),
40 port_(-1), 40 port_(-1),
41 shutdown_requested_(false), 41 shutdown_requested_(false),
42 web_socket_proxy_thread_("Chrome_WebSocketproxyThread") { 42 web_socket_proxy_thread_("Chrome_WebSocketproxyThread") {
43 DLOG(INFO) << "WebSocketProxyController initiation"; 43 DLOG(INFO) << "WebSocketProxyController initiation";
44 base::Thread::Options options(MessageLoop::TYPE_IO, 0); 44 base::Thread::Options options(base::MessageLoop::TYPE_IO, 0);
45 web_socket_proxy_thread_.StartWithOptions(options); 45 web_socket_proxy_thread_.StartWithOptions(options);
46 web_socket_proxy_thread_.message_loop()->PostTask( 46 web_socket_proxy_thread_.message_loop()->PostTask(
47 FROM_HERE, 47 FROM_HERE,
48 base::Bind(&ProxyLifetime::ProxyCallback, base::Unretained(this))); 48 base::Bind(&ProxyLifetime::ProxyCallback, base::Unretained(this)));
49 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 49 net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
50 registrar_.Add( 50 registrar_.Add(
51 this, chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED, 51 this, chrome::NOTIFICATION_WEB_SOCKET_PROXY_STARTED,
52 content::NotificationService::AllSources()); 52 content::NotificationService::AllSources());
53 } 53 }
54 54
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 { 91 {
92 base::AutoLock alk(lock_); 92 base::AutoLock alk(lock_);
93 delete server; 93 delete server;
94 server_ = NULL; 94 server_ = NULL;
95 if (!shutdown_requested_) { 95 if (!shutdown_requested_) {
96 // Proxy terminated unexpectedly or failed to start (it can happen due 96 // Proxy terminated unexpectedly or failed to start (it can happen due
97 // to a network problem). Keep trying. 97 // to a network problem). Keep trying.
98 if (delay_ms_ < 100 * 1000) 98 if (delay_ms_ < 100 * 1000)
99 (delay_ms_ *= 3) /= 2; 99 (delay_ms_ *= 3) /= 2;
100 100
101 MessageLoop::current()->PostDelayedTask( 101 base::MessageLoop::current()->PostDelayedTask(
102 FROM_HERE, 102 FROM_HERE,
103 base::Bind(&ProxyLifetime::ProxyCallback, base::Unretained(this)), 103 base::Bind(&ProxyLifetime::ProxyCallback, base::Unretained(this)),
104 base::TimeDelta::FromMilliseconds(delay_ms_)); 104 base::TimeDelta::FromMilliseconds(delay_ms_));
105 } 105 }
106 } 106 }
107 } 107 }
108 108
109 // Delay in milliseconds between next attempt to run proxy. 109 // Delay in milliseconds between next attempt to run proxy.
110 int volatile delay_ms_; 110 int volatile delay_ms_;
111 111
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 { 152 {
153 base::AutoLock alk(g_proxy_lifetime.Get().lock_); 153 base::AutoLock alk(g_proxy_lifetime.Get().lock_);
154 g_proxy_lifetime.Get().shutdown_requested_ = true; 154 g_proxy_lifetime.Get().shutdown_requested_ = true;
155 if (g_proxy_lifetime.Get().server_) 155 if (g_proxy_lifetime.Get().server_)
156 g_proxy_lifetime.Get().server_->Shutdown(); 156 g_proxy_lifetime.Get().server_->Shutdown();
157 } 157 }
158 g_proxy_lifetime.Get().web_socket_proxy_thread_.Stop(); 158 g_proxy_lifetime.Get().web_socket_proxy_thread_.Stop();
159 } 159 }
160 160
161 } // namespace chromeos 161 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/web_socket_proxy.cc ('k') | chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698