OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/vpn_provider/vpn_service.h" | 5 #include "extensions/browser/api/vpn_provider/vpn_service.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/guid.h" | 13 #include "base/guid.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" |
21 #include "base/values.h" | 22 #include "base/values.h" |
22 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" | 23 #include "chromeos/dbus/shill_third_party_vpn_driver_client.h" |
23 #include "chromeos/dbus/shill_third_party_vpn_observer.h" | 24 #include "chromeos/dbus/shill_third_party_vpn_observer.h" |
24 #include "chromeos/network/network_configuration_handler.h" | 25 #include "chromeos/network/network_configuration_handler.h" |
25 #include "chromeos/network/network_profile.h" | 26 #include "chromeos/network/network_profile.h" |
26 #include "chromeos/network/network_profile_handler.h" | 27 #include "chromeos/network/network_profile_handler.h" |
27 #include "chromeos/network/network_state.h" | 28 #include "chromeos/network/network_state.h" |
28 #include "chromeos/network/network_state_handler.h" | 29 #include "chromeos/network/network_state_handler.h" |
29 #include "chromeos/network/network_type_pattern.h" | 30 #include "chromeos/network/network_type_pattern.h" |
30 #include "crypto/sha2.h" | 31 #include "crypto/sha2.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 event_router_(event_router), | 149 event_router_(event_router), |
149 shill_client_(shill_client), | 150 shill_client_(shill_client), |
150 network_configuration_handler_(network_configuration_handler), | 151 network_configuration_handler_(network_configuration_handler), |
151 network_profile_handler_(network_profile_handler), | 152 network_profile_handler_(network_profile_handler), |
152 network_state_handler_(network_state_handler), | 153 network_state_handler_(network_state_handler), |
153 active_configuration_(nullptr), | 154 active_configuration_(nullptr), |
154 weak_factory_(this) { | 155 weak_factory_(this) { |
155 extension_registry_->AddObserver(this); | 156 extension_registry_->AddObserver(this); |
156 network_state_handler_->AddObserver(this, FROM_HERE); | 157 network_state_handler_->AddObserver(this, FROM_HERE); |
157 network_configuration_handler_->AddObserver(this); | 158 network_configuration_handler_->AddObserver(this); |
158 base::MessageLoop::current()->PostTask( | 159 base::ThreadTaskRunnerHandle::Get()->PostTask( |
159 FROM_HERE, | 160 FROM_HERE, |
160 base::Bind(&VpnService::NetworkListChanged, weak_factory_.GetWeakPtr())); | 161 base::Bind(&VpnService::NetworkListChanged, weak_factory_.GetWeakPtr())); |
161 } | 162 } |
162 | 163 |
163 VpnService::~VpnService() { | 164 VpnService::~VpnService() { |
164 network_configuration_handler_->RemoveObserver(this); | 165 network_configuration_handler_->RemoveObserver(this); |
165 network_state_handler_->RemoveObserver(this, FROM_HERE); | 166 network_state_handler_->RemoveObserver(this, FROM_HERE); |
166 extension_registry_->RemoveObserver(this); | 167 extension_registry_->RemoveObserver(this); |
167 STLDeleteContainerPairSecondPointers(key_to_configuration_map_.begin(), | 168 STLDeleteContainerPairSecondPointers(key_to_configuration_map_.begin(), |
168 key_to_configuration_map_.end()); | 169 key_to_configuration_map_.end()); |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 delete configuration; | 570 delete configuration; |
570 } | 571 } |
571 | 572 |
572 bool VpnService::DoesActiveConfigurationExistAndIsAccessAuthorized( | 573 bool VpnService::DoesActiveConfigurationExistAndIsAccessAuthorized( |
573 const std::string& extension_id) { | 574 const std::string& extension_id) { |
574 return active_configuration_ && | 575 return active_configuration_ && |
575 active_configuration_->extension_id() == extension_id; | 576 active_configuration_->extension_id() == extension_id; |
576 } | 577 } |
577 | 578 |
578 } // namespace chromeos | 579 } // namespace chromeos |
OLD | NEW |