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

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: . 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
106 void NetworkStateHandler::Initialize() {
107 CHECK(!g_network_state_handler);
108 g_network_state_handler = new NetworkStateHandler();
109 g_network_state_handler->InitShillPropertyHandler();
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 }
130
131 void NetworkStateHandler::AddObserver(NetworkStateHandlerObserver* observer) { 103 void NetworkStateHandler::AddObserver(NetworkStateHandlerObserver* observer) {
132 observers_.AddObserver(observer); 104 observers_.AddObserver(observer);
133 } 105 }
134 106
135 void NetworkStateHandler::RemoveObserver( 107 void NetworkStateHandler::RemoveObserver(
136 NetworkStateHandlerObserver* observer) { 108 NetworkStateHandlerObserver* observer) {
137 observers_.RemoveObserver(observer); 109 observers_.RemoveObserver(observer);
138 } 110 }
139 111
140 NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState( 112 NetworkStateHandler::TechnologyState NetworkStateHandler::GetTechnologyState(
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 } 593 }
622 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || 594 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual ||
623 type == kMatchTypeWireless) { 595 type == kMatchTypeWireless) {
624 NOTREACHED(); 596 NOTREACHED();
625 return flimflam::kTypeWifi; 597 return flimflam::kTypeWifi;
626 } 598 }
627 return type; 599 return type;
628 } 600 }
629 601
630 } // namespace chromeos 602 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698