| OLD | NEW |
| 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/system/statistics_provider.h" | 5 #include "chromeos/system/statistics_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 // Extracts known data from regional_data_; | 212 // Extracts known data from regional_data_; |
| 213 // Returns true on success; | 213 // Returns true on success; |
| 214 bool GetRegionalInformation(const std::string& name, | 214 bool GetRegionalInformation(const std::string& name, |
| 215 std::string* result) const; | 215 std::string* result) const; |
| 216 | 216 |
| 217 // Returns current region dictionary or NULL if not found. | 217 // Returns current region dictionary or NULL if not found. |
| 218 const base::DictionaryValue* GetRegionDictionary() const; | 218 const base::DictionaryValue* GetRegionDictionary() const; |
| 219 | 219 |
| 220 // Returns extractor from regional_data_extractors_ or nullptr. | 220 // Returns extractor from regional_data_extractors_ or nullptr. |
| 221 const RegionDataExtractor GetRegionalDataExtractor( | 221 RegionDataExtractor GetRegionalDataExtractor(const std::string& name) const; |
| 222 const std::string& name) const; | |
| 223 | 222 |
| 224 bool load_statistics_started_; | 223 bool load_statistics_started_; |
| 225 NameValuePairsParser::NameValueMap machine_info_; | 224 NameValuePairsParser::NameValueMap machine_info_; |
| 226 MachineFlags machine_flags_; | 225 MachineFlags machine_flags_; |
| 227 base::CancellationFlag cancellation_flag_; | 226 base::CancellationFlag cancellation_flag_; |
| 228 // |on_statistics_loaded_| protects |machine_info_| and |machine_flags_|. | 227 // |on_statistics_loaded_| protects |machine_info_| and |machine_flags_|. |
| 229 base::WaitableEvent on_statistics_loaded_; | 228 base::WaitableEvent on_statistics_loaded_; |
| 230 bool oem_manifest_loaded_; | 229 bool oem_manifest_loaded_; |
| 231 std::string region_; | 230 std::string region_; |
| 232 scoped_ptr<base::Value> regional_data_; | 231 scoped_ptr<base::Value> regional_data_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 if (!regional_data_->GetAsDictionary(&full_dict)) | 264 if (!regional_data_->GetAsDictionary(&full_dict)) |
| 266 return nullptr; | 265 return nullptr; |
| 267 | 266 |
| 268 const base::DictionaryValue* region_dict = nullptr; | 267 const base::DictionaryValue* region_dict = nullptr; |
| 269 if (!full_dict->GetDictionaryWithoutPathExpansion(region_, ®ion_dict)) | 268 if (!full_dict->GetDictionaryWithoutPathExpansion(region_, ®ion_dict)) |
| 270 return nullptr; | 269 return nullptr; |
| 271 | 270 |
| 272 return region_dict; | 271 return region_dict; |
| 273 } | 272 } |
| 274 | 273 |
| 275 const StatisticsProviderImpl::RegionDataExtractor | 274 StatisticsProviderImpl::RegionDataExtractor |
| 276 StatisticsProviderImpl::GetRegionalDataExtractor( | 275 StatisticsProviderImpl::GetRegionalDataExtractor( |
| 277 const std::string& name) const { | 276 const std::string& name) const { |
| 278 const auto it = regional_data_extractors_.find(name); | 277 const auto it = regional_data_extractors_.find(name); |
| 279 if (it == regional_data_extractors_.end()) | 278 if (it == regional_data_extractors_.end()) |
| 280 return nullptr; | 279 return nullptr; |
| 281 | 280 |
| 282 return it->second; | 281 return it->second; |
| 283 } | 282 } |
| 284 | 283 |
| 285 bool StatisticsProviderImpl::GetRegionalInformation(const std::string& name, | 284 bool StatisticsProviderImpl::GetRegionalInformation(const std::string& name, |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 return StatisticsProviderImpl::GetInstance(); | 558 return StatisticsProviderImpl::GetInstance(); |
| 560 } | 559 } |
| 561 | 560 |
| 562 // static | 561 // static |
| 563 void StatisticsProvider::SetTestProvider(StatisticsProvider* test_provider) { | 562 void StatisticsProvider::SetTestProvider(StatisticsProvider* test_provider) { |
| 564 g_test_statistics_provider = test_provider; | 563 g_test_statistics_provider = test_provider; |
| 565 } | 564 } |
| 566 | 565 |
| 567 } // namespace system | 566 } // namespace system |
| 568 } // namespace chromeos | 567 } // namespace chromeos |
| OLD | NEW |