OLD | NEW |
---|---|
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/proxy_config_service_impl.h" | 5 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/json/json_value_serializer.h" | 9 #include "base/json/json_value_serializer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 NOTREACHED(); | 464 NOTREACHED(); |
465 VLOG(1) << "Cannot set bypass rules for proxy mode [" | 465 VLOG(1) << "Cannot set bypass rules for proxy mode [" |
466 << current_ui_config_.mode << "]"; | 466 << current_ui_config_.mode << "]"; |
467 return false; | 467 return false; |
468 } | 468 } |
469 current_ui_config_.bypass_rules = bypass_rules; | 469 current_ui_config_.bypass_rules = bypass_rules; |
470 OnUISetProxyConfig(); | 470 OnUISetProxyConfig(); |
471 return true; | 471 return true; |
472 } | 472 } |
473 | 473 |
474 void ProxyConfigServiceImpl::AddNotificationCallback(base::Closure callback) { | |
475 std::vector<base::Closure>::iterator iter = callbacks_.begin(); | |
476 for (; iter != callbacks_.end(); ++iter) { | |
477 if (callback.Equals(*iter)) | |
478 return; | |
479 } | |
Mattias Nissler (ping if slow)
2011/11/11 12:10:46
std::find
pastarmovj
2011/11/11 15:17:31
After spending an hour playing with templates and
| |
480 callbacks_.push_back(callback); | |
481 } | |
482 | |
483 void ProxyConfigServiceImpl::RemoveNotificationCallback( | |
484 base::Closure callback) { | |
485 std::vector<base::Closure>::iterator iter = callbacks_.begin(); | |
486 for (; iter != callbacks_.end(); ++iter) { | |
487 if (callback.Equals(*iter)) { | |
488 callbacks_.erase(iter); | |
489 return; | |
490 } | |
491 } | |
Mattias Nissler (ping if slow)
2011/11/11 12:10:46
std::find
pastarmovj
2011/11/11 15:17:31
Ditto.
| |
492 } | |
493 | |
474 void ProxyConfigServiceImpl::OnProxyConfigChanged( | 494 void ProxyConfigServiceImpl::OnProxyConfigChanged( |
475 ProxyPrefs::ConfigState config_state, | 495 ProxyPrefs::ConfigState config_state, |
476 const net::ProxyConfig& config) { | 496 const net::ProxyConfig& config) { |
477 VLOG(1) << this << ": got prefs change: " << ConfigStateToString(config_state) | 497 VLOG(1) << this << ": got prefs change: " << ConfigStateToString(config_state) |
478 << ", mode=" << config.proxy_rules().type; | 498 << ", mode=" << config.proxy_rules().type; |
479 Network* network = NULL; | 499 Network* network = NULL; |
480 if (!active_network_.empty()) { | 500 if (!active_network_.empty()) { |
481 network = CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath( | 501 network = CrosLibrary::Get()->GetNetworkLibrary()->FindNetworkByPath( |
482 active_network_); | 502 active_network_); |
483 if (!network) | 503 if (!network) |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
755 } | 775 } |
756 | 776 |
757 void ProxyConfigServiceImpl::OnUISetCurrentNetwork(const Network* network) { | 777 void ProxyConfigServiceImpl::OnUISetCurrentNetwork(const Network* network) { |
758 DetermineEffectiveConfig(network, false); | 778 DetermineEffectiveConfig(network, false); |
759 VLOG(1) << this << ": current ui network: " | 779 VLOG(1) << this << ": current ui network: " |
760 << (network->name().empty() ? | 780 << (network->name().empty() ? |
761 current_ui_network_ : network->name()) | 781 current_ui_network_ : network->name()) |
762 << ", " << ModeToString(current_ui_config_.mode) | 782 << ", " << ModeToString(current_ui_config_.mode) |
763 << ", " << ConfigStateToString(current_ui_config_.state) | 783 << ", " << ConfigStateToString(current_ui_config_.state) |
764 << ", modifiable:" << current_ui_config_.user_modifiable; | 784 << ", modifiable:" << current_ui_config_.user_modifiable; |
785 // Notify whoever is interested in this change. | |
786 std::vector<base::Closure>::iterator iter = callbacks_.begin(); | |
787 while (iter != callbacks_.end()) { | |
788 if (iter->is_null()) { | |
789 iter = callbacks_.erase(iter); | |
Mattias Nissler (ping if slow)
2011/11/11 12:10:46
You can't do that while still iterating.
pastarmovj
2011/11/11 15:17:31
All other iterators are invalidated true but the i
| |
790 } else { | |
791 iter->Run(); | |
792 ++iter; | |
793 } | |
794 } | |
765 } | 795 } |
766 | 796 |
767 void ProxyConfigServiceImpl::ResetUICache() { | 797 void ProxyConfigServiceImpl::ResetUICache() { |
768 current_ui_network_.clear(); | 798 current_ui_network_.clear(); |
769 current_ui_config_ = ProxyConfig(); | 799 current_ui_config_ = ProxyConfig(); |
770 } | 800 } |
771 | 801 |
772 } // namespace chromeos | 802 } // namespace chromeos |
OLD | NEW |