blob: 5661e5b8da69b99445540ca3672a60c534037e3b [file] [log] [blame]
Paul Stewart35eff132013-04-12 12:08:40 -07001// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "shill/ethernet_eap_provider.h"
6
7#include <string>
8
9#include "shill/ethernet_eap_service.h"
10#include "shill/manager.h"
11
12using std::string;
13
14namespace shill {
15
16EthernetEapProvider::EthernetEapProvider(ControlInterface *control_interface,
17 EventDispatcher *dispatcher,
18 Metrics *metrics,
19 Manager *manager)
20 : control_interface_(control_interface),
21 dispatcher_(dispatcher),
22 metrics_(metrics),
23 manager_(manager) {}
24
Paul Stewart93e00f42013-04-19 15:45:23 -070025EthernetEapProvider::~EthernetEapProvider() {}
Paul Stewart35eff132013-04-12 12:08:40 -070026
27void EthernetEapProvider::Start() {
28 if (!service_) {
29 service_ = new EthernetEapService(control_interface_,
30 dispatcher_,
31 metrics_,
32 manager_);
33 }
34 manager_->RegisterService(service_);
35}
36
37void EthernetEapProvider::Stop() {
38 if (service_) {
39 manager_->DeregisterService(service_);
40 }
41 // Do not destroy the service, since devices may or may not have been
42 // removed as the provider is stopped, and we'd like them to continue
43 // to refer to the same service on restart.
44}
45
46void EthernetEapProvider::SetCredentialChangeCallback(
47 Ethernet *device, CredentialChangeCallback callback) {
48 callback_map_[device] = callback;
49}
50
51void EthernetEapProvider::ClearCredentialChangeCallback(Ethernet *device) {
52 CallbackMap::iterator it = callback_map_.find(device);
53 if (it != callback_map_.end()) {
54 callback_map_.erase(it);
55 }
56}
57
58void EthernetEapProvider::OnCredentialsChanged() const {
59 CallbackMap::const_iterator it;
60 for (it = callback_map_.begin(); it != callback_map_.end(); ++it) {
61 CHECK(!it->second.is_null());
62 it->second.Run();
63 }
64}
65
66} // namespace shill