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

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

Issue 243103004: Don't treat Shill ClearProperty errors as failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 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 | « chromeos/network/network_configuration_handler.h ('k') | 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) 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"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 249 }
250 NET_LOG_USER("ClearProperties", service_path); 250 NET_LOG_USER("ClearProperties", service_path);
251 for (std::vector<std::string>::const_iterator iter = names.begin(); 251 for (std::vector<std::string>::const_iterator iter = names.begin();
252 iter != names.end(); ++iter) { 252 iter != names.end(); ++iter) {
253 NET_LOG_DEBUG("ClearProperty", service_path + "." + *iter); 253 NET_LOG_DEBUG("ClearProperty", service_path + "." + *iter);
254 } 254 }
255 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperties( 255 DBusThreadManager::Get()->GetShillServiceClient()->ClearProperties(
256 dbus::ObjectPath(service_path), 256 dbus::ObjectPath(service_path),
257 names, 257 names,
258 base::Bind(&NetworkConfigurationHandler::ClearPropertiesSuccessCallback, 258 base::Bind(&NetworkConfigurationHandler::ClearPropertiesSuccessCallback,
259 AsWeakPtr(), service_path, names, callback, error_callback), 259 AsWeakPtr(), service_path, names, callback),
260 base::Bind(&NetworkConfigurationHandler::ClearPropertiesErrorCallback, 260 base::Bind(&NetworkConfigurationHandler::ClearPropertiesErrorCallback,
261 AsWeakPtr(), service_path, error_callback)); 261 AsWeakPtr(), service_path, error_callback));
262 } 262 }
263 263
264 void NetworkConfigurationHandler::CreateConfiguration( 264 void NetworkConfigurationHandler::CreateConfiguration(
265 const base::DictionaryValue& properties, 265 const base::DictionaryValue& properties,
266 const network_handler::StringResultCallback& callback, 266 const network_handler::StringResultCallback& callback,
267 const network_handler::ErrorCallback& error_callback) { 267 const network_handler::ErrorCallback& error_callback) {
268 ShillManagerClient* manager = 268 ShillManagerClient* manager =
269 DBusThreadManager::Get()->GetShillManagerClient(); 269 DBusThreadManager::Get()->GetShillManagerClient();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 service_path, error_callback, 387 service_path, error_callback,
388 dbus_error_name, dbus_error_message); 388 dbus_error_name, dbus_error_message);
389 // Some properties may have changed so request an update regardless. 389 // Some properties may have changed so request an update regardless.
390 network_state_handler_->RequestUpdateForNetwork(service_path); 390 network_state_handler_->RequestUpdateForNetwork(service_path);
391 } 391 }
392 392
393 void NetworkConfigurationHandler::ClearPropertiesSuccessCallback( 393 void NetworkConfigurationHandler::ClearPropertiesSuccessCallback(
394 const std::string& service_path, 394 const std::string& service_path,
395 const std::vector<std::string>& names, 395 const std::vector<std::string>& names,
396 const base::Closure& callback, 396 const base::Closure& callback,
397 const network_handler::ErrorCallback& error_callback,
398 const base::ListValue& result) { 397 const base::ListValue& result) {
399 const std::string kClearPropertiesFailedError("Error.ClearPropertiesFailed"); 398 const std::string kClearPropertiesFailedError("Error.ClearPropertiesFailed");
pneubeck (no reviews) 2014/04/22 20:16:59 unused. (didn't see it earlier)
400 DCHECK(names.size() == result.GetSize()) 399 DCHECK(names.size() == result.GetSize())
401 << "Incorrect result size from ClearProperties."; 400 << "Incorrect result size from ClearProperties.";
402 401
403 bool some_failed = false;
404 for (size_t i = 0; i < result.GetSize(); ++i) { 402 for (size_t i = 0; i < result.GetSize(); ++i) {
405 bool success = false; 403 bool success = false;
406 result.GetBoolean(i, &success); 404 result.GetBoolean(i, &success);
407 if (!success) { 405 if (!success) {
406 // If a property was cleared that has never been set, the clear will fail.
407 // We do not track which properties have been set, so just log the error.
408 NET_LOG_ERROR("ClearProperties Failed: " + names[i], service_path); 408 NET_LOG_ERROR("ClearProperties Failed: " + names[i], service_path);
409 some_failed = true;
410 } 409 }
411 } 410 }
412 411
413 if (some_failed) { 412 if (!callback.is_null())
414 if (!error_callback.is_null()) {
415 scoped_ptr<base::DictionaryValue> error_data(
416 network_handler::CreateErrorData(
417 service_path, kClearPropertiesFailedError,
418 base::StringPrintf("Errors: %" PRIuS, result.GetSize())));
419 error_data->Set("errors", result.DeepCopy());
420 scoped_ptr<base::ListValue> name_list(new base::ListValue);
421 name_list->AppendStrings(names);
422 error_data->Set("names", name_list.release());
423 error_callback.Run(kClearPropertiesFailedError, error_data.Pass());
424 }
425 } else if (!callback.is_null()) {
426 callback.Run(); 413 callback.Run();
427 }
428 network_state_handler_->RequestUpdateForNetwork(service_path); 414 network_state_handler_->RequestUpdateForNetwork(service_path);
429 } 415 }
430 416
431 void NetworkConfigurationHandler::ClearPropertiesErrorCallback( 417 void NetworkConfigurationHandler::ClearPropertiesErrorCallback(
432 const std::string& service_path, 418 const std::string& service_path,
433 const network_handler::ErrorCallback& error_callback, 419 const network_handler::ErrorCallback& error_callback,
434 const std::string& dbus_error_name, 420 const std::string& dbus_error_name,
435 const std::string& dbus_error_message) { 421 const std::string& dbus_error_message) {
436 network_handler::ShillErrorCallbackFunction( 422 network_handler::ShillErrorCallbackFunction(
437 "Config.ClearProperties Failed", 423 "Config.ClearProperties Failed",
438 service_path, error_callback, 424 service_path, error_callback,
439 dbus_error_name, dbus_error_message); 425 dbus_error_name, dbus_error_message);
440 // Some properties may have changed so request an update regardless. 426 // Some properties may have changed so request an update regardless.
441 network_state_handler_->RequestUpdateForNetwork(service_path); 427 network_state_handler_->RequestUpdateForNetwork(service_path);
442 } 428 }
443 429
444 // static 430 // static
445 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest( 431 NetworkConfigurationHandler* NetworkConfigurationHandler::InitializeForTest(
446 NetworkStateHandler* network_state_handler) { 432 NetworkStateHandler* network_state_handler) {
447 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler(); 433 NetworkConfigurationHandler* handler = new NetworkConfigurationHandler();
448 handler->Init(network_state_handler); 434 handler->Init(network_state_handler);
449 return handler; 435 return handler;
450 } 436 }
451 437
452 } // namespace chromeos 438 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_configuration_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698