| 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 "components/cronet/android/cronet_url_request_context_adapter.h" | 5 #include "components/cronet/android/cronet_url_request_context_adapter.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 return false; | 324 return false; |
| 325 } | 325 } |
| 326 return version == kStorageVersion; | 326 return version == kStorageVersion; |
| 327 } | 327 } |
| 328 | 328 |
| 329 // TODO(xunjieli): Handle failures. | 329 // TODO(xunjieli): Handle failures. |
| 330 void InitializeStorageDirectory(const base::FilePath& dir) { | 330 void InitializeStorageDirectory(const base::FilePath& dir) { |
| 331 // Checks version file and clear old storage. | 331 // Checks version file and clear old storage. |
| 332 base::FilePath version_filepath = dir.Append("version"); | 332 base::FilePath version_filepath = dir.Append("version"); |
| 333 if (IsCurrentVersion(version_filepath)) { | 333 if (IsCurrentVersion(version_filepath)) { |
| 334 // The version is up-to-date, so there is nothing to do. | 334 // The version is up to date, so there is nothing to do. |
| 335 return; | 335 return; |
| 336 } | 336 } |
| 337 // Delete old directory recursively and create a new directory. | 337 // Delete old directory recursively and create a new directory. |
| 338 // base::DeleteFile returns true if the directory does not exist, so it is | 338 // base::DeleteFile returns true if the directory does not exist, so it is |
| 339 // fine if there is nothing on disk. | 339 // fine if there is nothing on disk. |
| 340 if (!(base::DeleteFile(dir, true) && base::CreateDirectory(dir))) { | 340 if (!(base::DeleteFile(dir, true) && base::CreateDirectory(dir))) { |
| 341 DLOG(WARNING) << "Cannot purge directory."; | 341 DLOG(WARNING) << "Cannot purge directory."; |
| 342 return; | 342 return; |
| 343 } | 343 } |
| 344 base::File new_version_file(version_filepath, base::File::FLAG_CREATE_ALWAYS | | 344 base::File new_version_file(version_filepath, base::File::FLAG_CREATE_ALWAYS | |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 JNIEnv* env, | 887 JNIEnv* env, |
| 888 const JavaParamRef<jclass>& jcaller) { | 888 const JavaParamRef<jclass>& jcaller) { |
| 889 base::StatisticsRecorder::Initialize(); | 889 base::StatisticsRecorder::Initialize(); |
| 890 std::vector<uint8_t> data; | 890 std::vector<uint8_t> data; |
| 891 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 891 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 892 return ScopedJavaLocalRef<jbyteArray>(); | 892 return ScopedJavaLocalRef<jbyteArray>(); |
| 893 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 893 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
| 894 } | 894 } |
| 895 | 895 |
| 896 } // namespace cronet | 896 } // namespace cronet |
| OLD | NEW |