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

Side by Side Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 7011023: Really fix chromium-os:14180 this time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made a change suggested in review, and fixed an unrelated chrome crasher Created 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/cros/network_library.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
(...skipping 3323 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 // Set active_virtual_ to the first connected or connecting vpn service. 3334 // Set active_virtual_ to the first connected or connecting vpn service.
3335 if (active_virtual_ == NULL && network->connecting_or_connected()) 3335 if (active_virtual_ == NULL && network->connecting_or_connected())
3336 active_virtual_ = static_cast<VirtualNetwork*>(network); 3336 active_virtual_ = static_cast<VirtualNetwork*>(network);
3337 } 3337 }
3338 } 3338 }
3339 3339
3340 void AddNetwork(Network* network) { 3340 void AddNetwork(Network* network) {
3341 std::pair<NetworkMap::iterator,bool> result = 3341 std::pair<NetworkMap::iterator,bool> result =
3342 network_map_.insert(std::make_pair(network->service_path(), network)); 3342 network_map_.insert(std::make_pair(network->service_path(), network));
3343 DCHECK(result.second); // Should only get called with new network. 3343 DCHECK(result.second); // Should only get called with new network.
3344 VLOG(2) << "Adding Network: " << network->name(); 3344 VLOG(2) << "Adding Network: " << network->service_path()
3345 << " (" << network->name() << ")";
3345 ConnectionType type(network->type()); 3346 ConnectionType type(network->type());
3346 if (type == TYPE_WIFI) { 3347 if (type == TYPE_WIFI) {
3347 if (wifi_enabled()) 3348 if (wifi_enabled())
3348 wifi_networks_.push_back(static_cast<WifiNetwork*>(network)); 3349 wifi_networks_.push_back(static_cast<WifiNetwork*>(network));
3349 } else if (type == TYPE_CELLULAR) { 3350 } else if (type == TYPE_CELLULAR) {
3350 if (cellular_enabled()) 3351 if (cellular_enabled())
3351 cellular_networks_.push_back(static_cast<CellularNetwork*>(network)); 3352 cellular_networks_.push_back(static_cast<CellularNetwork*>(network));
3352 } else if (type == TYPE_VPN) { 3353 } else if (type == TYPE_VPN) {
3353 virtual_networks_.push_back(static_cast<VirtualNetwork*>(network)); 3354 virtual_networks_.push_back(static_cast<VirtualNetwork*>(network));
3354 } 3355 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3475 if (!service_path.empty()) { 3476 if (!service_path.empty()) {
3476 VLOG(1) << "Watched Service: " << service_path; 3477 VLOG(1) << "Watched Service: " << service_path;
3477 RequestNetworkServiceInfo( 3478 RequestNetworkServiceInfo(
3478 service_path.c_str(), &NetworkServiceUpdate, this); 3479 service_path.c_str(), &NetworkServiceUpdate, this);
3479 } 3480 }
3480 } 3481 }
3481 } 3482 }
3482 3483
3483 // Request the active profile which lists the remembered networks. 3484 // Request the active profile which lists the remembered networks.
3484 void RequestRememberedNetworksUpdate() { 3485 void RequestRememberedNetworksUpdate() {
3485 RequestNetworkProfile( 3486 if (!active_profile_path_.empty())
3486 active_profile_path_.c_str(), &ProfileUpdate, this); 3487 RequestNetworkProfile(
3488 active_profile_path_.c_str(), &ProfileUpdate, this);
stevenjb 2011/05/13 22:15:39 nit: { }
Eric Shienbrood 2011/05/13 22:29:24 Done.
3487 } 3489 }
3488 3490
3489 // Update the list of remembered (profile) networks, and request associated 3491 // Update the list of remembered (profile) networks, and request associated
3490 // service updates. 3492 // service updates.
3491 void UpdateRememberedServiceList(const char* profile_path, 3493 void UpdateRememberedServiceList(const char* profile_path,
3492 const ListValue* profile_entries) { 3494 const ListValue* profile_entries) {
3493 // Copy the list of existing networks to "old" and clear the map and list. 3495 // Copy the list of existing networks to "old" and clear the map and list.
3494 NetworkMap old_network_map = remembered_network_map_; 3496 NetworkMap old_network_map = remembered_network_map_;
3495 ClearRememberedNetworks(false /*don't delete*/); 3497 ClearRememberedNetworks(false /*don't delete*/);
3496 // |profile_entries| represents a complete list of remembered networks. 3498 // |profile_entries| represents a complete list of remembered networks.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3659 NetworkDeviceMap old_device_map = device_map_; 3661 NetworkDeviceMap old_device_map = device_map_;
3660 device_map_.clear(); 3662 device_map_.clear();
3661 VLOG(2) << "Updating Device List."; 3663 VLOG(2) << "Updating Device List.";
3662 for (ListValue::const_iterator iter = devices->begin(); 3664 for (ListValue::const_iterator iter = devices->begin();
3663 iter != devices->end(); ++iter) { 3665 iter != devices->end(); ++iter) {
3664 std::string device_path; 3666 std::string device_path;
3665 (*iter)->GetAsString(&device_path); 3667 (*iter)->GetAsString(&device_path);
3666 if (!device_path.empty()) { 3668 if (!device_path.empty()) {
3667 NetworkDeviceMap::iterator found = old_device_map.find(device_path); 3669 NetworkDeviceMap::iterator found = old_device_map.find(device_path);
3668 if (found != old_device_map.end()) { 3670 if (found != old_device_map.end()) {
3669 VLOG(2) << " Adding device: " << device_path; 3671 VLOG(2) << " Adding existing device: " << device_path;
3670 device_map_[device_path] = found->second; 3672 device_map_[device_path] = found->second;
3671 old_device_map.erase(found); 3673 old_device_map.erase(found);
3672 // Add device property monitor before we request the
3673 // full property list, to ensure that we won't miss any
3674 // property changes.
3675 network_device_observers_[device_path] =
3676 new NetworkDeviceObserverList(this, device_path);
3677
3678 } 3674 }
3679 RequestNetworkDeviceInfo( 3675 RequestNetworkDeviceInfo(
3680 device_path.c_str(), &NetworkDeviceUpdate, this); 3676 device_path.c_str(), &NetworkDeviceUpdate, this);
3681 } 3677 }
3682 } 3678 }
3683 // Delete any old devices that no longer exist. 3679 // Delete any old devices that no longer exist.
3684 for (NetworkDeviceMap::iterator iter = old_device_map.begin(); 3680 for (NetworkDeviceMap::iterator iter = old_device_map.begin();
3685 iter != old_device_map.end(); ++iter) { 3681 iter != old_device_map.end(); ++iter) {
3686 DeleteDeviceFromDeviceObserversMap(iter->first); 3682 DeleteDeviceFromDeviceObserversMap(iter->first);
3687 // Delete device. 3683 // Delete device.
(...skipping 28 matching lines...) Expand all
3716 void ParseNetworkDevice(const std::string& device_path, 3712 void ParseNetworkDevice(const std::string& device_path,
3717 const DictionaryValue* info) { 3713 const DictionaryValue* info) {
3718 NetworkDeviceMap::iterator found = device_map_.find(device_path); 3714 NetworkDeviceMap::iterator found = device_map_.find(device_path);
3719 NetworkDevice* device; 3715 NetworkDevice* device;
3720 if (found != device_map_.end()) { 3716 if (found != device_map_.end()) {
3721 device = found->second; 3717 device = found->second;
3722 } else { 3718 } else {
3723 device = new NetworkDevice(device_path); 3719 device = new NetworkDevice(device_path);
3724 VLOG(2) << " Adding device: " << device_path; 3720 VLOG(2) << " Adding device: " << device_path;
3725 device_map_[device_path] = device; 3721 device_map_[device_path] = device;
3722 if (network_device_observers_.find(device_path) ==
3723 network_device_observers_.end()) {
3724 network_device_observers_[device_path] =
3725 new NetworkDeviceObserverList(this, device_path);
3726 }
3726 } 3727 }
3727 device->ParseInfo(info); 3728 device->ParseInfo(info);
3728 VLOG(1) << "ParseNetworkDevice:" << device->name(); 3729 VLOG(1) << "ParseNetworkDevice:" << device->name();
3729 NotifyNetworkManagerChanged(false); // Not forced. 3730 NotifyNetworkManagerChanged(false); // Not forced.
3730 } 3731 }
3731 3732
3732 //////////////////////////////////////////////////////////////////////////// 3733 ////////////////////////////////////////////////////////////////////////////
3733 3734
3734 void EnableNetworkDeviceType(ConnectionType device, bool enable) { 3735 void EnableNetworkDeviceType(ConnectionType device, bool enable) {
3735 if (!EnsureCrosLoaded()) 3736 if (!EnsureCrosLoaded())
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
4443 return new NetworkLibraryStubImpl(); 4444 return new NetworkLibraryStubImpl();
4444 else 4445 else
4445 return new NetworkLibraryImpl(); 4446 return new NetworkLibraryImpl();
4446 } 4447 }
4447 4448
4448 } // namespace chromeos 4449 } // namespace chromeos
4449 4450
4450 // Allows InvokeLater without adding refcounting. This class is a Singleton and 4451 // Allows InvokeLater without adding refcounting. This class is a Singleton and
4451 // won't be deleted until it's last InvokeLater is run. 4452 // won't be deleted until it's last InvokeLater is run.
4452 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl); 4453 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698