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

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: Fix chromeos_unittests 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 "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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 } // namespace 65 } // namespace
66 66
67 namespace chromeos { 67 namespace chromeos {
68 68
69 const char NetworkStateHandler::kMatchTypeDefault[] = "default"; 69 const char NetworkStateHandler::kMatchTypeDefault[] = "default";
70 const char NetworkStateHandler::kMatchTypeWireless[] = "wireless"; 70 const char NetworkStateHandler::kMatchTypeWireless[] = "wireless";
71 const char NetworkStateHandler::kMatchTypeMobile[] = "mobile"; 71 const char NetworkStateHandler::kMatchTypeMobile[] = "mobile";
72 const char NetworkStateHandler::kMatchTypeNonVirtual[] = "non-virtual"; 72 const char NetworkStateHandler::kMatchTypeNonVirtual[] = "non-virtual";
73 73
74 static NetworkStateHandler* g_network_state_handler = NULL;
75
76 NetworkStateHandler::NetworkStateHandler() { 74 NetworkStateHandler::NetworkStateHandler() {
77 } 75 }
78 76
79 NetworkStateHandler::~NetworkStateHandler() { 77 NetworkStateHandler::~NetworkStateHandler() {
80 STLDeleteContainerPointers(network_list_.begin(), network_list_.end()); 78 STLDeleteContainerPointers(network_list_.begin(), network_list_.end());
81 STLDeleteContainerPointers(device_list_.begin(), device_list_.end()); 79 STLDeleteContainerPointers(device_list_.begin(), device_list_.end());
82 } 80 }
83 81
84 void NetworkStateHandler::InitShillPropertyHandler() { 82 void NetworkStateHandler::InitShillPropertyHandler() {
85 shill_property_handler_.reset(new internal::ShillPropertyHandler(this)); 83 shill_property_handler_.reset(new internal::ShillPropertyHandler(this));
86 shill_property_handler_->Init(); 84 shill_property_handler_->Init();
87 } 85 }
88 86
89 // static 87 // static
90 void NetworkStateHandler::Initialize() { 88 NetworkStateHandler* NetworkStateHandler::InitializeForTest() {
91 CHECK(!g_network_state_handler); 89 NetworkStateHandler* handler = new NetworkStateHandler();
92 g_network_state_handler = new NetworkStateHandler(); 90 handler->InitShillPropertyHandler();
93 g_network_state_handler->InitShillPropertyHandler(); 91 return handler;
94 }
95
96 // static
97 bool NetworkStateHandler::IsInitialized() {
98 return g_network_state_handler != NULL;
99 }
100
101 // static
102 void NetworkStateHandler::Shutdown() {
103 CHECK(g_network_state_handler);
104 delete g_network_state_handler;
105 g_network_state_handler = NULL;
106 }
107
108 // static
109 NetworkStateHandler* NetworkStateHandler::Get() {
110 CHECK(g_network_state_handler)
111 << "NetworkStateHandler::Get() called before Initialize()";
112 return g_network_state_handler;
113 } 92 }
114 93
115 void NetworkStateHandler::AddObserver(NetworkStateHandlerObserver* observer) { 94 void NetworkStateHandler::AddObserver(NetworkStateHandlerObserver* observer) {
116 observers_.AddObserver(observer); 95 observers_.AddObserver(observer);
117 } 96 }
118 97
119 void NetworkStateHandler::RemoveObserver( 98 void NetworkStateHandler::RemoveObserver(
120 NetworkStateHandlerObserver* observer) { 99 NetworkStateHandlerObserver* observer) {
121 observers_.RemoveObserver(observer); 100 observers_.RemoveObserver(observer);
122 } 101 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 } 603 }
625 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual || 604 if (type == kMatchTypeDefault || type == kMatchTypeNonVirtual ||
626 type == kMatchTypeWireless) { 605 type == kMatchTypeWireless) {
627 NOTREACHED(); 606 NOTREACHED();
628 return flimflam::kTypeWifi; 607 return flimflam::kTypeWifi;
629 } 608 }
630 return type; 609 return type;
631 } 610 }
632 611
633 } // namespace chromeos 612 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_state_handler.h ('k') | content/browser/geolocation/wifi_data_provider_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698