| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "android_webview/browser/aw_metrics_service_client.h" | 5 #include "android_webview/browser/aw_metrics_service_client.h" |
| 6 | 6 |
| 7 #include "android_webview/common/aw_version_info_values.h" | 7 #include "android_webview/common/aw_version_info_values.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return client_info; | 39 return client_info; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // A GUID in text form is composed of 32 hex digits and 4 hyphens. | 42 // A GUID in text form is composed of 32 hex digits and 4 hyphens. |
| 43 const size_t GUID_SIZE = 32 + 4; | 43 const size_t GUID_SIZE = 32 + 4; |
| 44 | 44 |
| 45 void GetOrCreateGUID(const base::FilePath guid_file_path, std::string* guid) { | 45 void GetOrCreateGUID(const base::FilePath guid_file_path, std::string* guid) { |
| 46 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 46 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 47 | 47 |
| 48 // Try to read an existing GUID. | 48 // Try to read an existing GUID. |
| 49 if (base::ReadFileToString(guid_file_path, guid, GUID_SIZE)) { | 49 if (base::ReadFileToStringWithMaxSize(guid_file_path, guid, GUID_SIZE)) { |
| 50 if (base::IsValidGUID(*guid)) | 50 if (base::IsValidGUID(*guid)) |
| 51 return; | 51 return; |
| 52 else | 52 else |
| 53 LOG(ERROR) << "Found invalid GUID"; | 53 LOG(ERROR) << "Found invalid GUID"; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // We must write a new GUID. | 56 // We must write a new GUID. |
| 57 *guid = base::GenerateGUID(); | 57 *guid = base::GenerateGUID(); |
| 58 if (!base::WriteFile(guid_file_path, guid->c_str(), guid->size())) | 58 if (!base::WriteFile(guid_file_path, guid->c_str(), guid->size())) |
| 59 LOG(ERROR) << "Failed to write new GUID"; | 59 LOG(ERROR) << "Failed to write new GUID"; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 request_context_(nullptr) {} | 220 request_context_(nullptr) {} |
| 221 | 221 |
| 222 AwMetricsServiceClient::~AwMetricsServiceClient() {} | 222 AwMetricsServiceClient::~AwMetricsServiceClient() {} |
| 223 | 223 |
| 224 bool AwMetricsServiceClient::is_reporting_enabled() { | 224 bool AwMetricsServiceClient::is_reporting_enabled() { |
| 225 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 225 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 226 return is_enabled_; | 226 return is_enabled_; |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace android_webview | 229 } // namespace android_webview |
| OLD | NEW |