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

Side by Side Diff: chromeos/network/network_state_handler.cc

Issue 14729017: Add NetworkHandler to own network handlers in src/chromeos/network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Add NetworkConnectionHandler to NetworkHandler Created 7 years, 7 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 "chromeos/network/network_state_handler.h" 5 #include "chromeos/network/network_state_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 } // namespace 81 } // namespace
82 82
83 namespace chromeos { 83 namespace chromeos {
84 84
85 const char NetworkStateHandler::kMatchTypeDefault[] = "default"; 85 const char NetworkStateHandler::kMatchTypeDefault[] = "default";
86 const char NetworkStateHandler::kMatchTypeWireless[] = "wireless"; 86 const char NetworkStateHandler::kMatchTypeWireless[] = "wireless";
87 const char NetworkStateHandler::kMatchTypeMobile[] = "mobile"; 87 const char NetworkStateHandler::kMatchTypeMobile[] = "mobile";
88 const char NetworkStateHandler::kMatchTypeNonVirtual[] = "non-virtual"; 88 const char NetworkStateHandler::kMatchTypeNonVirtual[] = "non-virtual";
89 89
90 static NetworkStateHandler* g_network_state_handler = NULL;
91
92 NetworkStateHandler::NetworkStateHandler() { 90 NetworkStateHandler::NetworkStateHandler() {
93 } 91 }
94 92
95 NetworkStateHandler::~NetworkStateHandler() { 93 NetworkStateHandler::~NetworkStateHandler() {
96 STLDeleteContainerPointers(network_list_.begin(), network_list_.end()); 94 STLDeleteContainerPointers(network_list_.begin(), network_list_.end());
97 STLDeleteContainerPointers(device_list_.begin(), device_list_.end()); 95 STLDeleteContainerPointers(device_list_.begin(), device_list_.end());
98 } 96 }
99 97
100 void NetworkStateHandler::InitShillPropertyHandler() { 98 void NetworkStateHandler::InitShillPropertyHandler() {
101 shill_property_handler_.reset(new internal::ShillPropertyHandler(this)); 99 shill_property_handler_.reset(new internal::ShillPropertyHandler(this));
102 shill_property_handler_->Init(); 100 shill_property_handler_->Init();
103 } 101 }
104 102
105 // static 103 // static
106 void NetworkStateHandler::Initialize() { 104 NetworkStateHandler* NetworkStateHandler::InitializeForTest() {
107 CHECK(!g_network_state_handler); 105 NetworkStateHandler* handler = new NetworkStateHandler();
108 g_network_state_handler = new NetworkStateHandler(); 106 handler->InitShillPropertyHandler();
109 g_network_state_handler->InitShillPropertyHandler(); 107 return handler;
110 }
111
112 // static
113 bool NetworkStateHandler::IsInitialized() {
114 return g_network_state_handler != NULL;
115 }
116
117 // static
118 void NetworkStateHandler::Shutdown() {
119 CHECK(g_network_state_handler);
120 delete g_network_state_handler;
121 g_network_state_handler = NULL;
122 }
123
124 // static
125 NetworkStateHandler* NetworkStateHandler::Get() {
126 CHECK(g_network_state_handler)
127 << "NetworkStateHandler::Get() called before Initialize()";
128 return g_network_state_handler;
129 } 108 }
130 109
131 void NetworkStateHandler::AddObserver(NetworkStateHandlerObserver* observer) { 110 void NetworkStateHandler::AddObserver(NetworkStateHandlerObserver* observer) {
132 observers_.AddObserver(observer); 111 observers_.AddObserver(observer);
133 } 112 }
134 113
135 void NetworkStateHandler::RemoveObserver( 114 void NetworkStateHandler::RemoveObserver(
136 NetworkStateHandlerObserver* observer) { 115 NetworkStateHandlerObserver* observer) {
137 observers_.RemoveObserver(observer); 116 observers_.RemoveObserver(observer);
138 } 117 }
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 } 600 }
622 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || 601 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual ||
623 type == kMatchTypeWireless) { 602 type == kMatchTypeWireless) {
624 NOTREACHED(); 603 NOTREACHED();
625 return flimflam::kTypeWifi; 604 return flimflam::kTypeWifi;
626 } 605 }
627 return type; 606 return type;
628 } 607 }
629 608
630 } // namespace chromeos 609 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698