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

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

Issue 4169001: Rewritten parts of NetworkLibrary to work around memory corruption that prev... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/network_list.h" 5 #include "chrome/browser/chromeos/network_list.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/chromeos/cros/cros_library.h" 9 #include "chrome/browser/chromeos/cros/cros_library.h"
10 #include "grit/generated_resources.h" 10 #include "grit/generated_resources.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (!network_lib || !CrosLibrary::Get()->EnsureLoaded()) 58 if (!network_lib || !CrosLibrary::Get()->EnsureLoaded())
59 return; 59 return;
60 60
61 bool ethernet_connected = network_lib->ethernet_connected(); 61 bool ethernet_connected = network_lib->ethernet_connected();
62 bool ethernet_connecting = network_lib->ethernet_connecting(); 62 bool ethernet_connecting = network_lib->ethernet_connecting();
63 if (ethernet_connected || ethernet_connecting) { 63 if (ethernet_connected || ethernet_connecting) {
64 string16 label = l10n_util::GetStringUTF16( 64 string16 label = l10n_util::GetStringUTF16(
65 IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 65 IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
66 networks_.push_back(NetworkItem(NETWORK_ETHERNET, 66 networks_.push_back(NetworkItem(NETWORK_ETHERNET,
67 label, 67 label,
68 WifiNetwork(), 68 NULL,
69 CellularNetwork())); 69 NULL));
70 AddNetworkIndexToList(index++, ethernet_connected, ethernet_connecting); 70 AddNetworkIndexToList(index++, ethernet_connected, ethernet_connecting);
71 } 71 }
72 72
73 // TODO(nkostylev): Show public WiFi networks first. 73 // TODO(nkostylev): Show public WiFi networks first.
74 WifiNetworkVector wifi = network_lib->wifi_networks(); 74 const WifiNetworkVector& wifi = network_lib->wifi_networks();
75 for (WifiNetworkVector::const_iterator it = wifi.begin(); 75 for (WifiNetworkVector::const_iterator it = wifi.begin();
76 it != wifi.end(); ++it, ++index) { 76 it != wifi.end(); ++it, ++index) {
77 networks_.push_back(NetworkItem(NETWORK_WIFI, 77 networks_.push_back(NetworkItem(NETWORK_WIFI,
78 ASCIIToUTF16(it->name()), 78 ASCIIToUTF16((*it)->name()),
79 *it, 79 *it,
80 CellularNetwork())); 80 NULL));
81 if (network_lib->wifi_network().service_path() == it->service_path()) { 81 if (network_lib->wifi_network() &&
82 network_lib->wifi_network()->service_path() == (*it)->service_path()) {
82 AddNetworkIndexToList(index, 83 AddNetworkIndexToList(index,
83 network_lib->wifi_connected(), 84 network_lib->wifi_connected(),
84 network_lib->wifi_connecting()); 85 network_lib->wifi_connecting());
85 } 86 }
86 } 87 }
87 88
88 CellularNetworkVector cellular = network_lib->cellular_networks(); 89 const CellularNetworkVector& cellular = network_lib->cellular_networks();
89 for (CellularNetworkVector::const_iterator it = cellular.begin(); 90 for (CellularNetworkVector::const_iterator it = cellular.begin();
90 it != cellular.end(); ++it, ++index) { 91 it != cellular.end(); ++it, ++index) {
91 networks_.push_back(NetworkItem(NETWORK_CELLULAR, 92 networks_.push_back(NetworkItem(NETWORK_CELLULAR,
92 ASCIIToUTF16(it->name()), 93 ASCIIToUTF16((*it)->name()),
93 WifiNetwork(), 94 NULL,
94 *it)); 95 *it));
95 if (network_lib->cellular_network().service_path() == it->service_path()) { 96 if (network_lib->cellular_network() &&
97 network_lib->cellular_network()->service_path() ==
98 (*it)->service_path()) {
96 AddNetworkIndexToList(index, 99 AddNetworkIndexToList(index,
97 network_lib->cellular_connected(), 100 network_lib->cellular_connected(),
98 network_lib->cellular_connecting()); 101 network_lib->cellular_connecting());
99 } 102 }
100 } 103 }
101 } 104 }
102 105
103 //////////////////////////////////////////////////////////////////////////////// 106 ////////////////////////////////////////////////////////////////////////////////
104 // NetworkList, private: 107 // NetworkList, private:
105 108
(...skipping 13 matching lines...) Expand all
119 bool NetworkList::IsSameNetwork(const NetworkList::NetworkItem* network, 122 bool NetworkList::IsSameNetwork(const NetworkList::NetworkItem* network,
120 NetworkType type, 123 NetworkType type,
121 const std::string& id) const { 124 const std::string& id) const {
122 if (type != network->network_type) 125 if (type != network->network_type)
123 return false; 126 return false;
124 switch (type) { 127 switch (type) {
125 case NETWORK_ETHERNET: 128 case NETWORK_ETHERNET:
126 // Assuming that there's only single Ethernet network. 129 // Assuming that there's only single Ethernet network.
127 return true; 130 return true;
128 case NETWORK_WIFI: 131 case NETWORK_WIFI:
129 return id == network->wifi_network.name(); 132 return network->wifi_network && id == network->wifi_network->name();
130 break; 133 break;
131 case NETWORK_CELLULAR: 134 case NETWORK_CELLULAR:
132 return id == network->cellular_network.name(); 135 return network->cellular_network &&
136 id == network->cellular_network->name();
133 break; 137 break;
134 default: 138 default:
135 return false; 139 return false;
136 break; 140 break;
137 } 141 }
138 } 142 }
139 143
140 void NetworkList::AddNetworkIndexToList(size_t index, 144 void NetworkList::AddNetworkIndexToList(size_t index,
141 bool connected, 145 bool connected,
142 bool connecting) { 146 bool connecting) {
143 if (connected) { 147 if (connected) {
144 connected_networks_.push_back(index); 148 connected_networks_.push_back(index);
145 } else if (connecting) { 149 } else if (connecting) {
146 connecting_networks_.push_back(index); 150 connecting_networks_.push_back(index);
147 } 151 }
148 } 152 }
149 153
150 } // namespace chromeos 154 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/network_list.h ('k') | chrome/browser/chromeos/network_message_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698