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

Side by Side Diff: chromeos/network/network_connection_handler.cc

Issue 14876021: Re-factor network_event_log (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address final nits Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/network/network_configuration_handler.cc ('k') | chromeos/network/network_event_log.h » ('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 (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/network/network_connection_handler.h" 5 #include "chromeos/network/network_connection_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "chromeos/dbus/dbus_thread_manager.h" 9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/dbus/shill_manager_client.h" 10 #include "chromeos/dbus/shill_manager_client.h"
11 #include "chromeos/dbus/shill_service_client.h" 11 #include "chromeos/dbus/shill_service_client.h"
12 #include "chromeos/network/cert_loader.h" 12 #include "chromeos/network/cert_loader.h"
13 #include "chromeos/network/certificate_pattern_matcher.h" 13 #include "chromeos/network/certificate_pattern_matcher.h"
14 #include "chromeos/network/managed_network_configuration_handler.h" 14 #include "chromeos/network/managed_network_configuration_handler.h"
15 #include "chromeos/network/network_configuration_handler.h" 15 #include "chromeos/network/network_configuration_handler.h"
16 #include "chromeos/network/network_event_log.h" 16 #include "chromeos/network/network_event_log.h"
17 #include "chromeos/network/network_handler_callbacks.h" 17 #include "chromeos/network/network_handler_callbacks.h"
18 #include "chromeos/network/network_state.h" 18 #include "chromeos/network/network_state.h"
19 #include "chromeos/network/network_state_handler.h" 19 #include "chromeos/network/network_state_handler.h"
20 #include "chromeos/network/network_ui_data.h" 20 #include "chromeos/network/network_ui_data.h"
21 #include "dbus/object_path.h" 21 #include "dbus/object_path.h"
22 #include "net/cert/x509_certificate.h" 22 #include "net/cert/x509_certificate.h"
23 #include "third_party/cros_system_api/dbus/service_constants.h" 23 #include "third_party/cros_system_api/dbus/service_constants.h"
24 24
25 namespace chromeos { 25 namespace chromeos {
26 26
27 namespace { 27 namespace {
28 28
29 const char kLogModule[] = "NetworkConnectionHandler";
30
31 void InvokeErrorCallback( 29 void InvokeErrorCallback(
32 const std::string& service_path, 30 const std::string& service_path,
33 const network_handler::ErrorCallback& error_callback, 31 const network_handler::ErrorCallback& error_callback,
34 const std::string& error_name) { 32 const std::string& error_name) {
35 network_handler::ShillErrorCallbackFunction( 33 network_handler::ShillErrorCallbackFunction(
36 kLogModule, service_path, error_callback, error_name, "Connect Error"); 34 service_path, error_callback, error_name, "Connect Error");
37 } 35 }
38 36
39 bool NetworkMayNeedCredentials(const NetworkState* network) { 37 bool NetworkMayNeedCredentials(const NetworkState* network) {
40 if (network->type() == flimflam::kTypeWifi && 38 if (network->type() == flimflam::kTypeWifi &&
41 (network->security() == flimflam::kSecurity8021x || 39 (network->security() == flimflam::kSecurity8021x ||
42 network->security() == flimflam::kSecurityWep /* For dynamic WEP*/)) 40 network->security() == flimflam::kSecurityWep /* For dynamic WEP*/))
43 return true; 41 return true;
44 if (network->type() == flimflam::kTypeVPN) 42 if (network->type() == flimflam::kTypeVPN)
45 return true; 43 return true;
46 return false; 44 return false;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 CallShillDisconnect(service_path, success_callback, error_callback); 209 CallShillDisconnect(service_path, success_callback, error_callback);
212 } 210 }
213 211
214 void NetworkConnectionHandler::CallShillConnect( 212 void NetworkConnectionHandler::CallShillConnect(
215 const std::string& service_path, 213 const std::string& service_path,
216 const base::Closure& success_callback, 214 const base::Closure& success_callback,
217 const network_handler::ErrorCallback& error_callback) { 215 const network_handler::ErrorCallback& error_callback) {
218 // TODO(stevenjb): Remove SetConnectingNetwork and use this class to maintain 216 // TODO(stevenjb): Remove SetConnectingNetwork and use this class to maintain
219 // the connecting network(s) once NetworkLibrary path is eliminated. 217 // the connecting network(s) once NetworkLibrary path is eliminated.
220 NetworkStateHandler::Get()->SetConnectingNetwork(service_path); 218 NetworkStateHandler::Get()->SetConnectingNetwork(service_path);
221 network_event_log::AddEntry(kLogModule, "Connect Request", service_path); 219 NET_LOG_EVENT("Connect Request", service_path);
222 DBusThreadManager::Get()->GetShillServiceClient()->Connect( 220 DBusThreadManager::Get()->GetShillServiceClient()->Connect(
223 dbus::ObjectPath(service_path), 221 dbus::ObjectPath(service_path),
224 base::Bind(&NetworkConnectionHandler::HandleShillSuccess, 222 base::Bind(&NetworkConnectionHandler::HandleShillSuccess,
225 AsWeakPtr(), service_path, success_callback), 223 AsWeakPtr(), service_path, success_callback),
226 base::Bind(&NetworkConnectionHandler::HandleShillFailure, 224 base::Bind(&NetworkConnectionHandler::HandleShillFailure,
227 AsWeakPtr(), service_path, error_callback)); 225 AsWeakPtr(), service_path, error_callback));
228 } 226 }
229 227
230 void NetworkConnectionHandler::CallShillDisconnect( 228 void NetworkConnectionHandler::CallShillDisconnect(
231 const std::string& service_path, 229 const std::string& service_path,
232 const base::Closure& success_callback, 230 const base::Closure& success_callback,
233 const network_handler::ErrorCallback& error_callback) { 231 const network_handler::ErrorCallback& error_callback) {
234 network_event_log::AddEntry(kLogModule, "Disconnect Request", service_path); 232 NET_LOG_EVENT("Disconnect Request", service_path);
235 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect( 233 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect(
236 dbus::ObjectPath(service_path), 234 dbus::ObjectPath(service_path),
237 base::Bind(&NetworkConnectionHandler::HandleShillSuccess, 235 base::Bind(&NetworkConnectionHandler::HandleShillSuccess,
238 AsWeakPtr(), service_path, success_callback), 236 AsWeakPtr(), service_path, success_callback),
239 base::Bind(&NetworkConnectionHandler::HandleShillFailure, 237 base::Bind(&NetworkConnectionHandler::HandleShillFailure,
240 AsWeakPtr(), service_path, error_callback)); 238 AsWeakPtr(), service_path, error_callback));
241 } 239 }
242 240
243 void NetworkConnectionHandler::VerifyConfiguredAndConnect( 241 void NetworkConnectionHandler::VerifyConfiguredAndConnect(
244 const base::Closure& success_callback, 242 const base::Closure& success_callback,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 282
285 void NetworkConnectionHandler::HandleShillSuccess( 283 void NetworkConnectionHandler::HandleShillSuccess(
286 const std::string& service_path, 284 const std::string& service_path,
287 const base::Closure& success_callback) { 285 const base::Closure& success_callback) {
288 // TODO(stevenjb): Currently, this only indicates that the connect request 286 // TODO(stevenjb): Currently, this only indicates that the connect request
289 // succeeded. It might be preferable to wait for the actually connect 287 // succeeded. It might be preferable to wait for the actually connect
290 // attempt to succeed or fail here and only call |success_callback| at that 288 // attempt to succeed or fail here and only call |success_callback| at that
291 // point (or maybe call it twice, once indicating in-progress, then success 289 // point (or maybe call it twice, once indicating in-progress, then success
292 // or failure). 290 // or failure).
293 pending_requests_.erase(service_path); 291 pending_requests_.erase(service_path);
294 network_event_log::AddEntry(kLogModule, "Connected", service_path); 292 NET_LOG_EVENT("Connected", service_path);
295 success_callback.Run(); 293 success_callback.Run();
296 } 294 }
297 295
298 void NetworkConnectionHandler::HandleShillFailure( 296 void NetworkConnectionHandler::HandleShillFailure(
299 const std::string& service_path, 297 const std::string& service_path,
300 const network_handler::ErrorCallback& error_callback, 298 const network_handler::ErrorCallback& error_callback,
301 const std::string& error_name, 299 const std::string& error_name,
302 const std::string& error_message) { 300 const std::string& error_message) {
303 pending_requests_.erase(service_path); 301 pending_requests_.erase(service_path);
304 std::string error = "Connect Failure: " + error_name + ": " + error_message; 302 std::string error = "Connect Failure: " + error_name + ": " + error_message;
305 network_handler::ShillErrorCallbackFunction( 303 network_handler::ShillErrorCallbackFunction(
306 kLogModule, service_path, error_callback, error_name, error_message); 304 service_path, error_callback, error_name, error_message);
307 } 305 }
308 306
309 } // namespace chromeos 307 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_configuration_handler.cc ('k') | chromeos/network/network_event_log.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698