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

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

Issue 24150004: Refactor the setup of Shill*Stubs' default environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/shill_manager_client_stub.h" 5 #include "chromeos/dbus/shill_manager_client_stub.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } // namespace 77 } // namespace
78 78
79 ShillManagerClientStub::ShillManagerClientStub() 79 ShillManagerClientStub::ShillManagerClientStub()
80 : weak_ptr_factory_(this) { 80 : weak_ptr_factory_(this) {
81 } 81 }
82 82
83 ShillManagerClientStub::~ShillManagerClientStub() {} 83 ShillManagerClientStub::~ShillManagerClientStub() {}
84 84
85 // ShillManagerClient overrides. 85 // ShillManagerClient overrides.
86 86
87 void ShillManagerClientStub::Init(dbus::Bus* bus) { 87 void ShillManagerClientStub::Init(dbus::Bus* bus) {}
88 SetDefaultProperties();
89 }
90 88
91 void ShillManagerClientStub::AddPropertyChangedObserver( 89 void ShillManagerClientStub::AddPropertyChangedObserver(
92 ShillPropertyChangedObserver* observer) { 90 ShillPropertyChangedObserver* observer) {
93 observer_list_.AddObserver(observer); 91 observer_list_.AddObserver(observer);
94 } 92 }
95 93
96 void ShillManagerClientStub::RemovePropertyChangedObserver( 94 void ShillManagerClientStub::RemovePropertyChangedObserver(
97 ShillPropertyChangedObserver* observer) { 95 ShillPropertyChangedObserver* observer) {
98 observer_list_.RemoveObserver(observer); 96 observer_list_.RemoveObserver(observer);
99 } 97 }
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 const std::string& service_path) { 482 const std::string& service_path) {
485 // Remove and insert the service, moving it to the front of the watch list. 483 // Remove and insert the service, moving it to the front of the watch list.
486 GetListProperty(flimflam::kServiceWatchListProperty)->Remove( 484 GetListProperty(flimflam::kServiceWatchListProperty)->Remove(
487 base::StringValue(service_path), NULL); 485 base::StringValue(service_path), NULL);
488 GetListProperty(flimflam::kServiceWatchListProperty)->Insert( 486 GetListProperty(flimflam::kServiceWatchListProperty)->Insert(
489 0, base::Value::CreateStringValue(service_path)); 487 0, base::Value::CreateStringValue(service_path));
490 CallNotifyObserversPropertyChanged( 488 CallNotifyObserversPropertyChanged(
491 flimflam::kServiceWatchListProperty, 0); 489 flimflam::kServiceWatchListProperty, 0);
492 } 490 }
493 491
494 void ShillManagerClientStub::SetDefaultProperties() {
495 // Stub Technologies.
496 if (!CommandLine::ForCurrentProcess()->HasSwitch(
497 chromeos::switches::kDisableStubEthernet)) {
498 AddTechnology(flimflam::kTypeEthernet, true);
499 }
500 AddTechnology(flimflam::kTypeWifi, true);
501 AddTechnology(flimflam::kTypeCellular, true);
502 AddTechnology(flimflam::kTypeWimax, true);
503 }
504
505 void ShillManagerClientStub::PassStubProperties( 492 void ShillManagerClientStub::PassStubProperties(
506 const DictionaryValueCallback& callback) const { 493 const DictionaryValueCallback& callback) const {
507 scoped_ptr<base::DictionaryValue> stub_properties( 494 scoped_ptr<base::DictionaryValue> stub_properties(
508 stub_properties_.DeepCopy()); 495 stub_properties_.DeepCopy());
509 // Remove disabled services from the list. 496 // Remove disabled services from the list.
510 stub_properties->SetWithoutPathExpansion( 497 stub_properties->SetWithoutPathExpansion(
511 flimflam::kServicesProperty, 498 flimflam::kServicesProperty,
512 GetEnabledServiceList(flimflam::kServicesProperty)); 499 GetEnabledServiceList(flimflam::kServicesProperty));
513 stub_properties->SetWithoutPathExpansion( 500 stub_properties->SetWithoutPathExpansion(
514 flimflam::kServiceWatchListProperty, 501 flimflam::kServiceWatchListProperty,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 flimflam::kScanningProperty, 629 flimflam::kScanningProperty,
643 base::FundamentalValue(false)); 630 base::FundamentalValue(false));
644 } 631 }
645 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0); 632 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0);
646 CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, 633 CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty,
647 0); 634 0);
648 base::MessageLoop::current()->PostTask(FROM_HERE, callback); 635 base::MessageLoop::current()->PostTask(FROM_HERE, callback);
649 } 636 }
650 637
651 } // namespace chromeos 638 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698