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

Side by Side Diff: chromeos/network/network_configuration_handler.cc

Issue 708563005: Use setProperties for IP Config. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_430113_internet_options_1
Patch Set: Add managed indicator to userNameServers, feedback, fix tests Created 5 years, 11 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
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_configuration_handler.h" 5 #include "chromeos/network/network_configuration_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chromeos/dbus/dbus_thread_manager.h" 19 #include "chromeos/dbus/dbus_thread_manager.h"
20 #include "chromeos/dbus/shill_manager_client.h" 20 #include "chromeos/dbus/shill_manager_client.h"
21 #include "chromeos/dbus/shill_profile_client.h" 21 #include "chromeos/dbus/shill_profile_client.h"
22 #include "chromeos/dbus/shill_service_client.h" 22 #include "chromeos/dbus/shill_service_client.h"
23 #include "chromeos/network/network_device_handler.h"
23 #include "chromeos/network/network_event_log.h" 24 #include "chromeos/network/network_event_log.h"
24 #include "chromeos/network/network_state.h" 25 #include "chromeos/network/network_state.h"
25 #include "chromeos/network/network_state_handler.h" 26 #include "chromeos/network/network_state_handler.h"
26 #include "chromeos/network/shill_property_util.h" 27 #include "chromeos/network/shill_property_util.h"
27 #include "dbus/object_path.h" 28 #include "dbus/object_path.h"
28 #include "third_party/cros_system_api/dbus/service_constants.h" 29 #include "third_party/cros_system_api/dbus/service_constants.h"
29 30
30 namespace chromeos { 31 namespace chromeos {
31 32
32 namespace { 33 namespace {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 LogConfigProperties("SetProperty", service_path, properties); 252 LogConfigProperties("SetProperty", service_path, properties);
252 253
253 scoped_ptr<base::DictionaryValue> properties_copy(properties.DeepCopy()); 254 scoped_ptr<base::DictionaryValue> properties_copy(properties.DeepCopy());
254 DBusThreadManager::Get()->GetShillServiceClient()->SetProperties( 255 DBusThreadManager::Get()->GetShillServiceClient()->SetProperties(
255 dbus::ObjectPath(service_path), properties, 256 dbus::ObjectPath(service_path), properties,
256 base::Bind(&NetworkConfigurationHandler::SetPropertiesSuccessCallback, 257 base::Bind(&NetworkConfigurationHandler::SetPropertiesSuccessCallback,
257 AsWeakPtr(), service_path, base::Passed(&properties_copy), 258 AsWeakPtr(), service_path, base::Passed(&properties_copy),
258 source, callback), 259 source, callback),
259 base::Bind(&NetworkConfigurationHandler::SetPropertiesErrorCallback, 260 base::Bind(&NetworkConfigurationHandler::SetPropertiesErrorCallback,
260 AsWeakPtr(), service_path, error_callback)); 261 AsWeakPtr(), service_path, error_callback));
262
263 // If we set the StaticIPConfig property, request an IP config refresh
264 // after calling SetProperties.
265 if (properties.HasKey(shill::kStaticIPConfigProperty))
266 RequestRefreshIPConfigs(service_path);
261 } 267 }
262 268
263 void NetworkConfigurationHandler::ClearProperties( 269 void NetworkConfigurationHandler::ClearProperties(
264 const std::string& service_path, 270 const std::string& service_path,
265 const std::vector<std::string>& names, 271 const std::vector<std::string>& names,
266 const base::Closure& callback, 272 const base::Closure& callback,
267 const network_handler::ErrorCallback& error_callback) { 273 const network_handler::ErrorCallback& error_callback) {
268 if (names.empty()) { 274 if (names.empty()) {
269 if (!callback.is_null()) 275 if (!callback.is_null())
270 callback.Run(); 276 callback.Run();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 NetworkConfigurationHandler::NetworkConfigurationHandler() 373 NetworkConfigurationHandler::NetworkConfigurationHandler()
368 : network_state_handler_(NULL) { 374 : network_state_handler_(NULL) {
369 } 375 }
370 376
371 NetworkConfigurationHandler::~NetworkConfigurationHandler() { 377 NetworkConfigurationHandler::~NetworkConfigurationHandler() {
372 STLDeleteContainerPairSecondPointers( 378 STLDeleteContainerPairSecondPointers(
373 profile_entry_deleters_.begin(), profile_entry_deleters_.end()); 379 profile_entry_deleters_.begin(), profile_entry_deleters_.end());
374 } 380 }
375 381
376 void NetworkConfigurationHandler::Init( 382 void NetworkConfigurationHandler::Init(
377 NetworkStateHandler* network_state_handler) { 383 NetworkStateHandler* network_state_handler,
384 NetworkDeviceHandler* network_device_handler) {
378 network_state_handler_ = network_state_handler; 385 network_state_handler_ = network_state_handler;
386 network_device_handler_ = network_device_handler;
379 } 387 }
380 388
381 void NetworkConfigurationHandler::RunCreateNetworkCallback( 389 void NetworkConfigurationHandler::RunCreateNetworkCallback(
382 const std::string& profile_path, 390 const std::string& profile_path,
383 NetworkConfigurationObserver::Source source, 391 NetworkConfigurationObserver::Source source,
384 scoped_ptr<base::DictionaryValue> configure_properties, 392 scoped_ptr<base::DictionaryValue> configure_properties,
385 const network_handler::StringResultCallback& callback, 393 const network_handler::StringResultCallback& callback,
386 const dbus::ObjectPath& service_path) { 394 const dbus::ObjectPath& service_path) {
387 if (!callback.is_null()) 395 if (!callback.is_null())
388 callback.Run(service_path.value()); 396 callback.Run(service_path.value());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 const std::string& dbus_error_name, 493 const std::string& dbus_error_name,
486 const std::string& dbus_error_message) { 494 const std::string& dbus_error_message) {
487 network_handler::ShillErrorCallbackFunction( 495 network_handler::ShillErrorCallbackFunction(
488 "Config.ClearProperties Failed", 496 "Config.ClearProperties Failed",
489 service_path, error_callback, 497 service_path, error_callback,
490 dbus_error_name, dbus_error_message); 498 dbus_error_name, dbus_error_message);
491 // Some properties may have changed so request an update regardless. 499 // Some properties may have changed so request an update regardless.
492 network_state_handler_->RequestUpdateForNetwork(service_path); 500 network_state_handler_->RequestUpdateForNetwork(service_path);
493 } 501 }
494 502
503 void NetworkConfigurationHandler::RequestRefreshIPConfigs(
504 const std::string& service_path) {
505 if (!network_device_handler_)
506 return;
507 const NetworkState* network_state =
508 network_state_handler_->GetNetworkState(service_path);
509 if (!network_state || network_state->device_path().empty())
510 return;
511 network_device_handler_->RequestRefreshIPConfigs(
512 network_state->device_path(), base::Bind(&base::DoNothing),
513 network_handler::ErrorCallback());
514 }
515
495 // static 516 // static
496 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest( 517 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest(
497 NetworkStateHandler* network_state_handler) { 518 NetworkStateHandler* network_state_handler,
519 NetworkDeviceHandler* network_device_handler) {
498 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler(); 520 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler();
499 handler->Init(network_state_handler); 521 handler->Init(network_state_handler, network_device_handler);
500 return handler; 522 return handler;
501 } 523 }
502 524
503 } // namespace chromeos 525 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698