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

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

Issue 7969009: Removed chromeos::NetworkStateNotifier and redirected all related code to use (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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) 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>
11 #include <unistd.h> 11 #include <unistd.h>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "base/string_tokenizer.h" 16 #include "base/string_tokenizer.h"
17 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/web_socket_proxy.h" 19 #include "chrome/browser/chromeos/web_socket_proxy.h"
20 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
23 #include "content/browser/browser_thread.h" 23 #include "content/browser/browser_thread.h"
24 #include "content/common/notification_observer.h" 24 #include "content/common/notification_observer.h"
25 #include "content/common/notification_registrar.h" 25 #include "content/common/notification_registrar.h"
26 #include "content/common/notification_service.h" 26 #include "content/common/notification_service.h"
27 #include "content/common/url_constants.h" 27 #include "content/common/url_constants.h"
28 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
29 #include "net/base/network_change_notifier.h"
29 30
30 namespace { 31 namespace {
31 32
32 const char* kAllowedIds[] = { 33 const char* kAllowedIds[] = {
33 "haiffjcadagjlijoggckpgfnoeiflnem", 34 "haiffjcadagjlijoggckpgfnoeiflnem",
34 "gnedhmakppccajfpfiihfcdlnpgomkcf", 35 "gnedhmakppccajfpfiihfcdlnpgomkcf",
35 "fjcibdnjlbfnbfdjneajpipnlcppleek", 36 "fjcibdnjlbfnbfdjneajpipnlcppleek",
36 "okddffdblfhhnmhodogpojmfkjmhinfp" 37 "okddffdblfhhnmhodogpojmfkjmhinfp"
37 }; 38 };
38 39
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 std::vector<std::string> allowed_ids_; 96 std::vector<std::string> allowed_ids_;
96 std::vector<std::string> allowed_origins_; 97 std::vector<std::string> allowed_origins_;
97 }; 98 };
98 99
99 base::LazyInstance<OriginValidator> g_validator(base::LINKER_INITIALIZED); 100 base::LazyInstance<OriginValidator> g_validator(base::LINKER_INITIALIZED);
100 101
101 class ProxyTask : public Task { 102 class ProxyTask : public Task {
102 virtual void Run() OVERRIDE; 103 virtual void Run() OVERRIDE;
103 }; 104 };
104 105
105 class ProxyLifetime : public NotificationObserver { 106 class ProxyLifetime : public net::NetworkChangeNotifier::OnlineStateObserver {
106 public: 107 public:
107 ProxyLifetime() : delay_ms_(1000), shutdown_requested_(false) { 108 ProxyLifetime() : delay_ms_(1000), shutdown_requested_(false) {
108 BrowserThread::PostTask( 109 BrowserThread::PostTask(
109 BrowserThread::WEB_SOCKET_PROXY, FROM_HERE, new ProxyTask()); 110 BrowserThread::WEB_SOCKET_PROXY, FROM_HERE, new ProxyTask());
110 registrar_.Add(this, chrome::NOTIFICATION_NETWORK_STATE_CHANGED, 111 net::NetworkChangeNotifier::AddOnlineStateObserver(this);
111 NotificationService::AllSources()); 112 }
113
114 virtual ~ProxyLifetime() {
115 net::NetworkChangeNotifier::RemoveOnlineStateObserver(this);
112 } 116 }
113 117
114 private: 118 private:
115 virtual void Observe(int type, 119 // net::NetworkChangeNotifier::OnlineStateObserver overrides.
116 const NotificationSource& source, 120 virtual void OnOnlineStateChanged(bool online) OVERRIDE {
117 const NotificationDetails& details) { 121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
118 DCHECK_EQ(type, chrome::NOTIFICATION_NETWORK_STATE_CHANGED);
119 DCHECK(chromeos::WebSocketProxyController::IsInitiated()); 122 DCHECK(chromeos::WebSocketProxyController::IsInitiated());
120 base::AutoLock alk(lock_); 123 base::AutoLock alk(lock_);
121 if (server_) 124 if (server_)
122 server_->OnNetworkChange(); 125 server_->OnNetworkChange();
123 } 126 }
124 127
125 // Delay between next attempt to run proxy. 128 // Delay between next attempt to run proxy.
126 int delay_ms_; 129 int delay_ms_;
127 130
128 chromeos::WebSocketProxy* volatile server_; 131 chromeos::WebSocketProxy* volatile server_;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 bool WebSocketProxyController::CheckCredentials( 211 bool WebSocketProxyController::CheckCredentials(
209 const std::string& extension_id, 212 const std::string& extension_id,
210 const std::string& hostname, 213 const std::string& hostname,
211 unsigned short port, 214 unsigned short port,
212 ConnectionFlags flags) { 215 ConnectionFlags flags) {
213 return g_validator.Get().CheckCredentials( 216 return g_validator.Get().CheckCredentials(
214 extension_id, hostname, port, flags); 217 extension_id, hostname, port, flags);
215 } 218 }
216 219
217 } // namespace chromeos 220 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/offline/offline_load_page.cc ('k') | chrome/browser/renderer_host/offline_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698