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

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: Remove extra blank line 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 3647 matching lines...) Expand 10 before | Expand all | Expand 10 after
3658 void UpdateNetworkDeviceList(const ListValue* devices) { 3658 void UpdateNetworkDeviceList(const ListValue* devices) {
3659 NetworkDeviceMap old_device_map = device_map_; 3659 NetworkDeviceMap old_device_map = device_map_;
3660 device_map_.clear(); 3660 device_map_.clear();
3661 VLOG(2) << "Updating Device List."; 3661 VLOG(2) << "Updating Device List.";
3662 for (ListValue::const_iterator iter = devices->begin(); 3662 for (ListValue::const_iterator iter = devices->begin();
3663 iter != devices->end(); ++iter) { 3663 iter != devices->end(); ++iter) {
3664 std::string device_path; 3664 std::string device_path;
3665 (*iter)->GetAsString(&device_path); 3665 (*iter)->GetAsString(&device_path);
3666 if (!device_path.empty()) { 3666 if (!device_path.empty()) {
3667 NetworkDeviceMap::iterator found = old_device_map.find(device_path); 3667 NetworkDeviceMap::iterator found = old_device_map.find(device_path);
3668 if (found != old_device_map.end()) { 3668 if (found == old_device_map.end()) {
3669 VLOG(2) << " Adding device: " << device_path; 3669 VLOG(2) << " New device: " << device_path;
3670 device_map_[device_path] = found->second;
3671 old_device_map.erase(found);
3672 // Add device property monitor before we request the 3670 // Add device property monitor before we request the
3673 // full property list, to ensure that we won't miss any 3671 // full property list, to ensure that we won't miss any
3674 // property changes. 3672 // property changes.
3675 network_device_observers_[device_path] = 3673 network_device_observers_[device_path] =
3676 new NetworkDeviceObserverList(this, device_path); 3674 new NetworkDeviceObserverList(this, device_path);
stevenjb 2011/05/12 22:33:06 I think that only adding the observer when creatin
Eric Shienbrood 2011/05/12 22:41:18 Since we're requesting device info immediately bel
stevenjb 2011/05/12 23:00:24 Well, since the device doesn't exist yet (i.e. it
Eric Shienbrood 2011/05/13 21:48:48 If they're not monitoring the manager, then they w
Eric Shienbrood 2011/05/13 21:48:48 I still think there's a theoretical window of vuln
3677 3675 } else {
3676 VLOG(2) << " Adding existing device: " << device_path;
3677 device_map_[device_path] = found->second;
3678 old_device_map.erase(found);
3678 } 3679 }
3679 RequestNetworkDeviceInfo( 3680 RequestNetworkDeviceInfo(
3680 device_path.c_str(), &NetworkDeviceUpdate, this); 3681 device_path.c_str(), &NetworkDeviceUpdate, this);
3681 } 3682 }
3682 } 3683 }
3683 // Delete any old devices that no longer exist. 3684 // Delete any old devices that no longer exist.
3684 for (NetworkDeviceMap::iterator iter = old_device_map.begin(); 3685 for (NetworkDeviceMap::iterator iter = old_device_map.begin();
3685 iter != old_device_map.end(); ++iter) { 3686 iter != old_device_map.end(); ++iter) {
3686 DeleteDeviceFromDeviceObserversMap(iter->first); 3687 DeleteDeviceFromDeviceObserversMap(iter->first);
3687 // Delete device. 3688 // Delete device.
(...skipping 28 matching lines...) Expand all
3716 void ParseNetworkDevice(const std::string& device_path, 3717 void ParseNetworkDevice(const std::string& device_path,
3717 const DictionaryValue* info) { 3718 const DictionaryValue* info) {
3718 NetworkDeviceMap::iterator found = device_map_.find(device_path); 3719 NetworkDeviceMap::iterator found = device_map_.find(device_path);
3719 NetworkDevice* device; 3720 NetworkDevice* device;
3720 if (found != device_map_.end()) { 3721 if (found != device_map_.end()) {
3721 device = found->second; 3722 device = found->second;
3722 } else { 3723 } else {
3723 device = new NetworkDevice(device_path); 3724 device = new NetworkDevice(device_path);
3724 VLOG(2) << " Adding device: " << device_path; 3725 VLOG(2) << " Adding device: " << device_path;
3725 device_map_[device_path] = device; 3726 device_map_[device_path] = device;
3727 if (network_device_observers_.find(device_path) ==
3728 network_device_observers_.end()) {
3729 network_device_observers_[device_path] =
3730 new NetworkDeviceObserverList(this, device_path);
3731 }
3726 } 3732 }
3727 device->ParseInfo(info); 3733 device->ParseInfo(info);
3728 VLOG(1) << "ParseNetworkDevice:" << device->name(); 3734 VLOG(1) << "ParseNetworkDevice:" << device->name();
3729 NotifyNetworkManagerChanged(false); // Not forced. 3735 NotifyNetworkManagerChanged(false); // Not forced.
stevenjb 2011/05/12 23:00:24 NotifyNetworkDeviceChanged(device); ?
3730 } 3736 }
3731 3737
3732 //////////////////////////////////////////////////////////////////////////// 3738 ////////////////////////////////////////////////////////////////////////////
3733 3739
3734 void EnableNetworkDeviceType(ConnectionType device, bool enable) { 3740 void EnableNetworkDeviceType(ConnectionType device, bool enable) {
3735 if (!EnsureCrosLoaded()) 3741 if (!EnsureCrosLoaded())
3736 return; 3742 return;
3737 3743
3738 // If network device is already enabled/disabled, then don't do anything. 3744 // If network device is already enabled/disabled, then don't do anything.
3739 if (enable && (enabled_devices_ & (1 << device))) { 3745 if (enable && (enabled_devices_ & (1 << device))) {
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
4443 return new NetworkLibraryStubImpl(); 4449 return new NetworkLibraryStubImpl();
4444 else 4450 else
4445 return new NetworkLibraryImpl(); 4451 return new NetworkLibraryImpl();
4446 } 4452 }
4447 4453
4448 } // namespace chromeos 4454 } // namespace chromeos
4449 4455
4450 // Allows InvokeLater without adding refcounting. This class is a Singleton and 4456 // Allows InvokeLater without adding refcounting. This class is a Singleton and
4451 // won't be deleted until it's last InvokeLater is run. 4457 // won't be deleted until it's last InvokeLater is run.
4452 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl); 4458 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