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

Side by Side Diff: chromeos/dbus/fake_shill_service_client.cc

Issue 2843813002: Remove SetWithoutPathExpansion (Closed)
Patch Set: Fix CrOS Error Created 3 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
« no previous file with comments | « chromeos/dbus/fake_shill_profile_client.cc ('k') | chromeos/dbus/gsm_sms_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/dbus/fake_shill_service_client.h" 5 #include "chromeos/dbus/fake_shill_service_client.h"
6 6
7 #include <utility>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
9 #include "base/location.h" 11 #include "base/location.h"
10 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
11 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
12 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
13 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/values.h" 16 #include "base/values.h"
15 #include "chromeos/dbus/dbus_thread_manager.h" 17 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/dbus/shill_device_client.h" 18 #include "chromeos/dbus/shill_device_client.h"
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 315
314 std::string profile_path; 316 std::string profile_path;
315 if (properties->GetStringWithoutPathExpansion(shill::kProfileProperty, 317 if (properties->GetStringWithoutPathExpansion(shill::kProfileProperty,
316 &profile_path) && 318 &profile_path) &&
317 !profile_path.empty()) { 319 !profile_path.empty()) {
318 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()-> 320 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface()->
319 UpdateService(profile_path, service_path); 321 UpdateService(profile_path, service_path);
320 } 322 }
321 323
322 if (!ipconfig_path.empty()) { 324 if (!ipconfig_path.empty()) {
323 properties->SetWithoutPathExpansion(shill::kIPConfigProperty, 325 properties->SetStringWithoutPathExpansion(shill::kIPConfigProperty,
324 new base::Value(ipconfig_path)); 326 ipconfig_path);
325 } 327 }
326 328
327 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> 329 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()->
328 AddManagerService(service_path, true); 330 AddManagerService(service_path, true);
329 } 331 }
330 332
331 base::DictionaryValue* FakeShillServiceClient::SetServiceProperties( 333 base::DictionaryValue* FakeShillServiceClient::SetServiceProperties(
332 const std::string& service_path, 334 const std::string& service_path,
333 const std::string& guid, 335 const std::string& guid,
334 const std::string& name, 336 const std::string& name,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 if (base::StartsWith(property, "Provider.", case_sensitive) || 407 if (base::StartsWith(property, "Provider.", case_sensitive) ||
406 base::StartsWith(property, "OpenVPN.", case_sensitive) || 408 base::StartsWith(property, "OpenVPN.", case_sensitive) ||
407 base::StartsWith(property, "L2TPIPsec.", case_sensitive)) { 409 base::StartsWith(property, "L2TPIPsec.", case_sensitive)) {
408 // These properties are only nested within the Provider dictionary if read 410 // These properties are only nested within the Provider dictionary if read
409 // from Shill. Properties that start with "Provider" need to have that 411 // from Shill. Properties that start with "Provider" need to have that
410 // stripped off, other properties are nested in the "Provider" dictionary 412 // stripped off, other properties are nested in the "Provider" dictionary
411 // as-is. 413 // as-is.
412 std::string key = property; 414 std::string key = property;
413 if (base::StartsWith(property, "Provider.", case_sensitive)) 415 if (base::StartsWith(property, "Provider.", case_sensitive))
414 key = property.substr(strlen("Provider.")); 416 key = property.substr(strlen("Provider."));
415 base::DictionaryValue* provider = new base::DictionaryValue; 417 base::DictionaryValue* provider = nullptr;
416 provider->SetWithoutPathExpansion(key, value.DeepCopy()); 418 provider->SetWithoutPathExpansion(key, value.CreateDeepCopy());
417 new_properties.SetWithoutPathExpansion(shill::kProviderProperty, provider); 419 new_properties.SetWithoutPathExpansion(
420 shill::kProviderProperty, base::MakeUnique<base::DictionaryValue>());
421 new_properties.GetDictionaryWithoutPathExpansion(shill::kProviderProperty,
422 &provider);
418 changed_property = shill::kProviderProperty; 423 changed_property = shill::kProviderProperty;
419 } else if (value.GetType() == base::Value::Type::DICTIONARY) { 424 } else if (value.GetType() == base::Value::Type::DICTIONARY) {
420 const base::DictionaryValue* new_dict = NULL; 425 const base::DictionaryValue* new_dict = NULL;
421 value.GetAsDictionary(&new_dict); 426 value.GetAsDictionary(&new_dict);
422 CHECK(new_dict); 427 CHECK(new_dict);
423 std::unique_ptr<base::Value> cur_value; 428 std::unique_ptr<base::Value> cur_value;
424 base::DictionaryValue* cur_dict; 429 base::DictionaryValue* cur_dict;
425 if (dict->RemoveWithoutPathExpansion(property, &cur_value) && 430 if (dict->RemoveWithoutPathExpansion(property, &cur_value) &&
426 cur_value->GetAsDictionary(&cur_dict)) { 431 cur_value->GetAsDictionary(&cur_dict)) {
427 cur_dict->Clear(); 432 cur_dict->Clear();
428 cur_dict->MergeDictionary(new_dict); 433 cur_dict->MergeDictionary(new_dict);
429 new_properties.SetWithoutPathExpansion(property, cur_value.release()); 434 new_properties.SetWithoutPathExpansion(property, std::move(cur_value));
430 } else { 435 } else {
431 new_properties.SetWithoutPathExpansion(property, value.DeepCopy()); 436 new_properties.SetWithoutPathExpansion(property, value.CreateDeepCopy());
432 } 437 }
433 changed_property = property; 438 changed_property = property;
434 } else { 439 } else {
435 new_properties.SetWithoutPathExpansion(property, value.DeepCopy()); 440 new_properties.SetWithoutPathExpansion(property, value.CreateDeepCopy());
436 changed_property = property; 441 changed_property = property;
437 } 442 }
438 443
439 dict->MergeDictionary(&new_properties); 444 dict->MergeDictionary(&new_properties);
440 445
441 // Add or update the profile entry. 446 // Add or update the profile entry.
442 ShillProfileClient::TestInterface* profile_test = 447 ShillProfileClient::TestInterface* profile_test =
443 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); 448 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
444 if (property == shill::kProfileProperty) { 449 if (property == shill::kProfileProperty) {
445 std::string profile_path; 450 std::string profile_path;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 if (path == service_path) 565 if (path == service_path)
561 continue; 566 continue;
562 base::DictionaryValue* properties; 567 base::DictionaryValue* properties;
563 if (!stub_services_.GetDictionaryWithoutPathExpansion(path, &properties)) 568 if (!stub_services_.GetDictionaryWithoutPathExpansion(path, &properties))
564 NOTREACHED(); 569 NOTREACHED();
565 570
566 std::string type; 571 std::string type;
567 properties->GetString(shill::kTypeProperty, &type); 572 properties->GetString(shill::kTypeProperty, &type);
568 if (type != service_type) 573 if (type != service_type)
569 continue; 574 continue;
570 properties->SetWithoutPathExpansion(shill::kStateProperty, 575 properties->SetStringWithoutPathExpansion(shill::kStateProperty,
571 new base::Value(shill::kStateIdle)); 576 shill::kStateIdle);
572 } 577 }
573 } 578 }
574 579
575 void FakeShillServiceClient::SetCellularActivated( 580 void FakeShillServiceClient::SetCellularActivated(
576 const dbus::ObjectPath& service_path, 581 const dbus::ObjectPath& service_path,
577 const ErrorCallback& error_callback) { 582 const ErrorCallback& error_callback) {
578 SetProperty(service_path, shill::kActivationStateProperty, 583 SetProperty(service_path, shill::kActivationStateProperty,
579 base::Value(shill::kActivationStateActivated), 584 base::Value(shill::kActivationStateActivated),
580 base::Bind(&base::DoNothing), error_callback); 585 base::Bind(&base::DoNothing), error_callback);
581 SetProperty(service_path, shill::kConnectableProperty, base::Value(true), 586 SetProperty(service_path, shill::kConnectableProperty, base::Value(true),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 base::Value(shill::kErrorBadPassphrase))); 621 base::Value(shill::kErrorBadPassphrase)));
617 } else { 622 } else {
618 // Set Online. 623 // Set Online.
619 VLOG(1) << "Setting state to Online " << service_path; 624 VLOG(1) << "Setting state to Online " << service_path;
620 SetServiceProperty(service_path, shill::kStateProperty, 625 SetServiceProperty(service_path, shill::kStateProperty,
621 base::Value(shill::kStateOnline)); 626 base::Value(shill::kStateOnline));
622 } 627 }
623 } 628 }
624 629
625 } // namespace chromeos 630 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_shill_profile_client.cc ('k') | chromeos/dbus/gsm_sms_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698