| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chrome_browser_field_trials.h" | 5 #include "chrome/browser/chrome_browser_field_trials.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 InitResult result; | 66 InitResult result; |
| 67 | 67 |
| 68 // Create persistent/shared memory and allow histograms to be stored in | 68 // Create persistent/shared memory and allow histograms to be stored in |
| 69 // it. Memory that is not actualy used won't be physically mapped by the | 69 // it. Memory that is not actualy used won't be physically mapped by the |
| 70 // system. BrowserMetrics usage, as reported in UMA, peaked around 3.0MiB | 70 // system. BrowserMetrics usage, as reported in UMA, peaked around 3.0MiB |
| 71 // as of 2016-12-20. | 71 // as of 2016-12-20. |
| 72 const size_t kAllocSize = 5 << 20; // 5 MiB | 72 const size_t kAllocSize = 5 << 20; // 5 MiB |
| 73 const uint32_t kAllocId = 0x935DDD43; // SHA1(BrowserMetrics) | 73 const uint32_t kAllocId = 0x935DDD43; // SHA1(BrowserMetrics) |
| 74 std::string storage = variations::GetVariationParamValueByFeature( | 74 std::string storage = variations::GetVariationParamValueByFeature( |
| 75 base::kPersistentHistogramsFeature, "storage"); | 75 base::kPersistentHistogramsFeature, "storage"); |
| 76 | 76 if (storage == "MappedFile") { |
| 77 // As of M58, "MappedFile" is the default. | |
| 78 if (storage.empty() || storage == "MappedFile") { | |
| 79 // If for some reason the existing "active" file could not be moved above | 77 // If for some reason the existing "active" file could not be moved above |
| 80 // then it is essential it be scheduled for deletion when possible and the | 78 // then it is essential it be scheduled for deletion when possible and the |
| 81 // contents ignored. Because this shouldn't happen but can on an OS like | 79 // contents ignored. Because this shouldn't happen but can on an OS like |
| 82 // Windows where another process reading the file (backup, AV, etc.) can | 80 // Windows where another process reading the file (backup, AV, etc.) can |
| 83 // prevent its alteration, it's necessary to handle this case by switching | 81 // prevent its alteration, it's necessary to handle this case by switching |
| 84 // to the equivalent of "LocalMemory" for this run. | 82 // to the equivalent of "LocalMemory" for this run. |
| 85 if (base::PathExists(active_file)) { | 83 if (base::PathExists(active_file)) { |
| 86 base::File file(active_file, base::File::FLAG_OPEN | | 84 base::File file(active_file, base::File::FLAG_OPEN | |
| 87 base::File::FLAG_READ | | 85 base::File::FLAG_READ | |
| 88 base::File::FLAG_DELETE_ON_CLOSE); | 86 base::File::FLAG_DELETE_ON_CLOSE); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 bool has_seed, | 164 bool has_seed, |
| 167 base::FeatureList* feature_list) { | 165 base::FeatureList* feature_list) { |
| 168 CreateFallbackSamplingTrialIfNeeded(has_seed, feature_list); | 166 CreateFallbackSamplingTrialIfNeeded(has_seed, feature_list); |
| 169 } | 167 } |
| 170 | 168 |
| 171 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { | 169 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { |
| 172 // Persistent histograms must be enabled as soon as possible. | 170 // Persistent histograms must be enabled as soon as possible. |
| 173 InstantiatePersistentHistograms(); | 171 InstantiatePersistentHistograms(); |
| 174 tracing::SetupBackgroundTracingFieldTrial(); | 172 tracing::SetupBackgroundTracingFieldTrial(); |
| 175 } | 173 } |
| OLD | NEW |