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

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

Issue 207183003: Cleanup network event logging, add to ManagedNetworkConfigurationHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 9 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 | « no previous file | chromeos/network/network_configuration_handler.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/managed_network_configuration_handler_impl.h" 5 #include "chromeos/network/managed_network_configuration_handler_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const std::string& error_name) { 62 const std::string& error_name) {
63 std::string error_msg = "ManagedConfig Error: " + error_name; 63 std::string error_msg = "ManagedConfig Error: " + error_name;
64 NET_LOG_ERROR(error_msg, service_path); 64 NET_LOG_ERROR(error_msg, service_path);
65 network_handler::RunErrorCallback( 65 network_handler::RunErrorCallback(
66 error_callback, service_path, error_name, error_msg); 66 error_callback, service_path, error_name, error_msg);
67 } 67 }
68 68
69 void LogErrorWithDict(const tracked_objects::Location& from_where, 69 void LogErrorWithDict(const tracked_objects::Location& from_where,
70 const std::string& error_name, 70 const std::string& error_name,
71 scoped_ptr<base::DictionaryValue> error_data) { 71 scoped_ptr<base::DictionaryValue> error_data) {
72 LOG(ERROR) << from_where.ToString() << ": " << error_name; 72 network_event_log::internal::AddEntry(
73 from_where.file_name(), from_where.line_number(),
74 network_event_log::LOG_LEVEL_ERROR,
75 error_name, "");
73 } 76 }
74 77
75 const base::DictionaryValue* GetByGUID(const GuidToPolicyMap& policies, 78 const base::DictionaryValue* GetByGUID(const GuidToPolicyMap& policies,
76 const std::string& guid) { 79 const std::string& guid) {
77 GuidToPolicyMap::const_iterator it = policies.find(guid); 80 GuidToPolicyMap::const_iterator it = policies.find(guid);
78 if (it == policies.end()) 81 if (it == policies.end())
79 return NULL; 82 return NULL;
80 return it->second; 83 return it->second;
81 } 84 }
82 85
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 void ManagedNetworkConfigurationHandlerImpl::GetManagedPropertiesCallback( 139 void ManagedNetworkConfigurationHandlerImpl::GetManagedPropertiesCallback(
137 const network_handler::DictionaryResultCallback& callback, 140 const network_handler::DictionaryResultCallback& callback,
138 const network_handler::ErrorCallback& error_callback, 141 const network_handler::ErrorCallback& error_callback,
139 const std::string& service_path, 142 const std::string& service_path,
140 const base::DictionaryValue& shill_properties) { 143 const base::DictionaryValue& shill_properties) {
141 std::string profile_path; 144 std::string profile_path;
142 shill_properties.GetStringWithoutPathExpansion(shill::kProfileProperty, 145 shill_properties.GetStringWithoutPathExpansion(shill::kProfileProperty,
143 &profile_path); 146 &profile_path);
144 const NetworkProfile* profile = 147 const NetworkProfile* profile =
145 network_profile_handler_->GetProfileForPath(profile_path); 148 network_profile_handler_->GetProfileForPath(profile_path);
146 if (!profile) { 149 if (!profile)
147 LOG(ERROR) << "No or no known profile received for service " 150 NET_LOG_ERROR("No profile for service: " + profile_path, service_path);
148 << service_path << ".";
149 }
150 151
151 scoped_ptr<NetworkUIData> ui_data = 152 scoped_ptr<NetworkUIData> ui_data =
152 shill_property_util::GetUIDataFromProperties(shill_properties); 153 shill_property_util::GetUIDataFromProperties(shill_properties);
153 154
154 const base::DictionaryValue* user_settings = NULL; 155 const base::DictionaryValue* user_settings = NULL;
155 const base::DictionaryValue* shared_settings = NULL; 156 const base::DictionaryValue* shared_settings = NULL;
156 157
157 if (ui_data && profile) { 158 if (ui_data && profile) {
158 if (profile->type() == NetworkProfile::TYPE_SHARED) 159 if (profile->type() == NetworkProfile::TYPE_SHARED)
159 shared_settings = ui_data->user_settings(); 160 shared_settings = ui_data->user_settings();
160 else if (profile->type() == NetworkProfile::TYPE_USER) 161 else if (profile->type() == NetworkProfile::TYPE_USER)
161 user_settings = ui_data->user_settings(); 162 user_settings = ui_data->user_settings();
162 else 163 else
163 NOTREACHED(); 164 NOTREACHED();
164 } else if (profile) { 165 } else if (profile) {
165 LOG(WARNING) << "Service " << service_path << " of profile " 166 NET_LOG_ERROR("Service contains empty or invalid UIData", service_path);
166 << profile_path << " contains no or no valid UIData.";
167 // TODO(pneubeck): add a conversion of user configured entries of old 167 // TODO(pneubeck): add a conversion of user configured entries of old
168 // ChromeOS versions. We will have to use a heuristic to determine which 168 // ChromeOS versions. We will have to use a heuristic to determine which
169 // properties _might_ be user configured. 169 // properties _might_ be user configured.
170 } 170 }
171 171
172 scoped_ptr<base::DictionaryValue> active_settings( 172 scoped_ptr<base::DictionaryValue> active_settings(
173 onc::TranslateShillServiceToONCPart( 173 onc::TranslateShillServiceToONCPart(
174 shill_properties, 174 shill_properties,
175 &onc::kNetworkWithStateSignature)); 175 &onc::kNetworkWithStateSignature));
176 176
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 it != network_configs_onc.end(); ++it) { 370 it != network_configs_onc.end(); ++it) {
371 const base::DictionaryValue* network = NULL; 371 const base::DictionaryValue* network = NULL;
372 (*it)->GetAsDictionary(&network); 372 (*it)->GetAsDictionary(&network);
373 DCHECK(network); 373 DCHECK(network);
374 374
375 std::string guid; 375 std::string guid;
376 network->GetStringWithoutPathExpansion(::onc::network_config::kGUID, &guid); 376 network->GetStringWithoutPathExpansion(::onc::network_config::kGUID, &guid);
377 DCHECK(!guid.empty()); 377 DCHECK(!guid.empty());
378 378
379 if (policies->per_network_config.count(guid) > 0) { 379 if (policies->per_network_config.count(guid) > 0) {
380 LOG(ERROR) << "ONC from " << ToDebugString(onc_source, userhash) 380 NET_LOG_ERROR("ONC from " + ToDebugString(onc_source, userhash) +
381 << " contains several entries for the same GUID " 381 " contains several entries for the same GUID ", guid);
382 << guid << ".";
383 delete policies->per_network_config[guid]; 382 delete policies->per_network_config[guid];
384 } 383 }
385 const base::DictionaryValue* new_entry = network->DeepCopy(); 384 const base::DictionaryValue* new_entry = network->DeepCopy();
386 policies->per_network_config[guid] = new_entry; 385 policies->per_network_config[guid] = new_entry;
387 386
388 const base::DictionaryValue* old_entry = old_per_network_config[guid]; 387 const base::DictionaryValue* old_entry = old_per_network_config[guid];
389 if (!old_entry || !old_entry->Equals(new_entry)) 388 if (!old_entry || !old_entry->Equals(new_entry))
390 modified_policies.insert(guid); 389 modified_policies.insert(guid);
391 } 390 }
392 391
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 void ManagedNetworkConfigurationHandlerImpl:: 453 void ManagedNetworkConfigurationHandlerImpl::
455 UpdateExistingConfigurationWithPropertiesFromPolicy( 454 UpdateExistingConfigurationWithPropertiesFromPolicy(
456 const base::DictionaryValue& existing_properties, 455 const base::DictionaryValue& existing_properties,
457 const base::DictionaryValue& new_properties) { 456 const base::DictionaryValue& new_properties) {
458 base::DictionaryValue shill_properties; 457 base::DictionaryValue shill_properties;
459 458
460 std::string profile; 459 std::string profile;
461 existing_properties.GetStringWithoutPathExpansion(shill::kProfileProperty, 460 existing_properties.GetStringWithoutPathExpansion(shill::kProfileProperty,
462 &profile); 461 &profile);
463 if (profile.empty()) { 462 if (profile.empty()) {
464 LOG(ERROR) << "Missing profile property."; 463 NET_LOG_ERROR("Missing profile property",
464 shill_property_util::GetNetworkIdFromProperties(
465 existing_properties));
465 return; 466 return;
466 } 467 }
467 shill_properties.SetStringWithoutPathExpansion(shill::kProfileProperty, 468 shill_properties.SetStringWithoutPathExpansion(shill::kProfileProperty,
468 profile); 469 profile);
469 470
470 if (!shill_property_util::CopyIdentifyingProperties(existing_properties, 471 if (!shill_property_util::CopyIdentifyingProperties(existing_properties,
471 &shill_properties)) { 472 &shill_properties)) {
472 LOG(ERROR) << "Missing identifying properties."; 473 NET_LOG_ERROR("Missing identifying properties",
474 shill_property_util::GetNetworkIdFromProperties(
475 existing_properties));
473 } 476 }
474 477
475 shill_properties.MergeDictionary(&new_properties); 478 shill_properties.MergeDictionary(&new_properties);
476 479
477 network_configuration_handler_->CreateConfiguration( 480 network_configuration_handler_->CreateConfiguration(
478 shill_properties, 481 shill_properties,
479 base::Bind( 482 base::Bind(
480 &ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork, 483 &ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork,
481 weak_ptr_factory_.GetWeakPtr()), 484 weak_ptr_factory_.GetWeakPtr()),
482 base::Bind(&LogErrorWithDict, FROM_HERE)); 485 base::Bind(&LogErrorWithDict, FROM_HERE));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 532
530 return &policies->global_network_config; 533 return &policies->global_network_config;
531 } 534 }
532 const base::DictionaryValue* 535 const base::DictionaryValue*
533 ManagedNetworkConfigurationHandlerImpl::FindPolicyByGuidAndProfile( 536 ManagedNetworkConfigurationHandlerImpl::FindPolicyByGuidAndProfile(
534 const std::string& guid, 537 const std::string& guid,
535 const std::string& profile_path) const { 538 const std::string& profile_path) const {
536 const NetworkProfile* profile = 539 const NetworkProfile* profile =
537 network_profile_handler_->GetProfileForPath(profile_path); 540 network_profile_handler_->GetProfileForPath(profile_path);
538 if (!profile) { 541 if (!profile) {
539 LOG(ERROR) << "Profile path unknown: " << profile_path; 542 NET_LOG_ERROR("Profile path unknown:" + profile_path, guid);
540 return NULL; 543 return NULL;
541 } 544 }
542 545
543 const Policies* policies = GetPoliciesForProfile(*profile); 546 const Policies* policies = GetPoliciesForProfile(*profile);
544 if (!policies) 547 if (!policies)
545 return NULL; 548 return NULL;
546 549
547 return GetByGUID(policies->per_network_config, guid); 550 return GetByGUID(policies->per_network_config, guid);
548 } 551 }
549 552
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 590
588 void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork( 591 void ManagedNetworkConfigurationHandlerImpl::OnPolicyAppliedToNetwork(
589 const std::string& service_path) { 592 const std::string& service_path) {
590 if (service_path.empty()) 593 if (service_path.empty())
591 return; 594 return;
592 FOR_EACH_OBSERVER( 595 FOR_EACH_OBSERVER(
593 NetworkPolicyObserver, observers_, PolicyApplied(service_path)); 596 NetworkPolicyObserver, observers_, PolicyApplied(service_path));
594 } 597 }
595 598
596 } // namespace chromeos 599 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/network/network_configuration_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698