1 // 2 // Copyright (C) 2015 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #include "dhcp_client/manager.h" 18 #include "dhcp_client/service.h" 19 20 #include "dhcp_client/message_loop_event_dispatcher.h" 21 22 namespace dhcp_client { 23 Manager()24Manager::Manager() 25 : service_identifier_(0), 26 event_dispatcher_(new MessageLoopEventDispatcher()) { 27 } 28 ~Manager()29Manager::~Manager() {} 30 StartService(const brillo::VariantDictionary & configs)31scoped_refptr<Service> Manager::StartService( 32 const brillo::VariantDictionary& configs) { 33 scoped_refptr<Service> service = new Service(this, 34 service_identifier_++, 35 event_dispatcher_.get(), 36 configs); 37 services_.push_back(service); 38 return service; 39 } 40 StopService(const scoped_refptr<Service> & service)41bool Manager::StopService(const scoped_refptr<Service>& service) { 42 for (auto it = services_.begin(); it != services_.end(); ++it) { 43 if (*it == service) { 44 services_.erase(it); 45 return true; 46 } 47 } 48 return false; 49 } 50 51 } // namespace dhcp_client 52 53