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

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

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/chromeos/system/udev_info_provider.cc ('k') | chrome/browser/chromeos/wm_ipc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 allowed_ids_.begin(), allowed_ids_.end(), extension_id); 89 allowed_ids_.begin(), allowed_ids_.end(), extension_id);
90 } 90 }
91 91
92 const std::vector<std::string>& allowed_origins() { return allowed_origins_; } 92 const std::vector<std::string>& allowed_origins() { return allowed_origins_; }
93 93
94 private: 94 private:
95 std::vector<std::string> allowed_ids_; 95 std::vector<std::string> allowed_ids_;
96 std::vector<std::string> allowed_origins_; 96 std::vector<std::string> allowed_origins_;
97 }; 97 };
98 98
99 base::LazyInstance<OriginValidator> g_validator(base::LINKER_INITIALIZED); 99 base::LazyInstance<OriginValidator> g_validator = LAZY_INSTANCE_INITIALIZER;
100 100
101 class ProxyTask : public Task { 101 class ProxyTask : public Task {
102 virtual void Run() OVERRIDE; 102 virtual void Run() OVERRIDE;
103 }; 103 };
104 104
105 class ProxyLifetime 105 class ProxyLifetime
106 : public net::NetworkChangeNotifier::OnlineStateObserver, 106 : public net::NetworkChangeNotifier::OnlineStateObserver,
107 public content::NotificationObserver { 107 public content::NotificationObserver {
108 public: 108 public:
109 ProxyLifetime() : delay_ms_(1000), port_(-1), shutdown_requested_(false) { 109 ProxyLifetime() : delay_ms_(1000), port_(-1), shutdown_requested_(false) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 int volatile port_; 147 int volatile port_;
148 148
149 chromeos::WebSocketProxy* volatile server_; 149 chromeos::WebSocketProxy* volatile server_;
150 volatile bool shutdown_requested_; 150 volatile bool shutdown_requested_;
151 base::Lock lock_; 151 base::Lock lock_;
152 content::NotificationRegistrar registrar_; 152 content::NotificationRegistrar registrar_;
153 friend class ProxyTask; 153 friend class ProxyTask;
154 friend class chromeos::WebSocketProxyController; 154 friend class chromeos::WebSocketProxyController;
155 }; 155 };
156 156
157 base::LazyInstance<ProxyLifetime> g_proxy_lifetime(base::LINKER_INITIALIZED); 157 base::LazyInstance<ProxyLifetime> g_proxy_lifetime = LAZY_INSTANCE_INITIALIZER;
158 158
159 void ProxyTask::Run() { 159 void ProxyTask::Run() {
160 LOG(INFO) << "Attempt to run web socket proxy task"; 160 LOG(INFO) << "Attempt to run web socket proxy task";
161 chromeos::WebSocketProxy* server = new chromeos::WebSocketProxy( 161 chromeos::WebSocketProxy* server = new chromeos::WebSocketProxy(
162 g_validator.Get().allowed_origins()); 162 g_validator.Get().allowed_origins());
163 { 163 {
164 base::AutoLock alk(g_proxy_lifetime.Get().lock_); 164 base::AutoLock alk(g_proxy_lifetime.Get().lock_);
165 if (g_proxy_lifetime.Get().shutdown_requested_) 165 if (g_proxy_lifetime.Get().shutdown_requested_)
166 return; 166 return;
167 delete g_proxy_lifetime.Get().server_; 167 delete g_proxy_lifetime.Get().server_;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 bool WebSocketProxyController::CheckCredentials( 226 bool WebSocketProxyController::CheckCredentials(
227 const std::string& extension_id, 227 const std::string& extension_id,
228 const std::string& hostname, 228 const std::string& hostname,
229 unsigned short port, 229 unsigned short port,
230 ConnectionFlags flags) { 230 ConnectionFlags flags) {
231 return g_validator.Get().CheckCredentials( 231 return g_validator.Get().CheckCredentials(
232 extension_id, hostname, port, flags); 232 extension_id, hostname, port, flags);
233 } 233 }
234 234
235 } // namespace chromeos 235 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/udev_info_provider.cc ('k') | chrome/browser/chromeos/wm_ipc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698