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: storage/browser/blob/blob_memory_controller.cc

Issue 2918523003: Fix BlobMemoryControllerTest.OnMemoryPressure (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "storage/browser/blob/blob_memory_controller.h" 5 #include "storage/browser/blob/blob_memory_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <numeric> 8 #include <numeric>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 945
946 // If we still have more blobs waiting and we're not waiting on more paging 946 // If we still have more blobs waiting and we're not waiting on more paging
947 // operations, schedule more. 947 // operations, schedule more.
948 MaybeScheduleEvictionUntilSystemHealthy( 948 MaybeScheduleEvictionUntilSystemHealthy(
949 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE); 949 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE);
950 } 950 }
951 951
952 void BlobMemoryController::OnMemoryPressure( 952 void BlobMemoryController::OnMemoryPressure(
953 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { 953 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
954 auto time_from_last_evicion = base::TimeTicks::Now() - last_eviction_time_; 954 auto time_from_last_evicion = base::TimeTicks::Now() - last_eviction_time_;
955 if (time_from_last_evicion.InSeconds() < kMinSecondsForPressureEvictions) 955 if (last_eviction_time_ != base::TimeTicks() &&
956 time_from_last_evicion.InSeconds() < kMinSecondsForPressureEvictions) {
956 return; 957 return;
958 }
957 959
958 MaybeScheduleEvictionUntilSystemHealthy(memory_pressure_level); 960 MaybeScheduleEvictionUntilSystemHealthy(memory_pressure_level);
959 } 961 }
960 962
961 FilePath BlobMemoryController::GenerateNextPageFileName() { 963 FilePath BlobMemoryController::GenerateNextPageFileName() {
962 std::string file_name = base::Uint64ToString(current_file_num_++); 964 std::string file_name = base::Uint64ToString(current_file_num_++);
963 return blob_storage_dir_.Append(FilePath::FromUTF8Unsafe(file_name)); 965 return blob_storage_dir_.Append(FilePath::FromUTF8Unsafe(file_name));
964 } 966 }
965 967
966 void BlobMemoryController::RecordTracingCounters() const { 968 void BlobMemoryController::RecordTracingCounters() const {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 MaybeGrantPendingMemoryRequests(); 1036 MaybeGrantPendingMemoryRequests();
1035 } 1037 }
1036 1038
1037 void BlobMemoryController::OnBlobFileDelete(uint64_t size, 1039 void BlobMemoryController::OnBlobFileDelete(uint64_t size,
1038 const FilePath& path) { 1040 const FilePath& path) {
1039 DCHECK_LE(size, disk_used_); 1041 DCHECK_LE(size, disk_used_);
1040 disk_used_ -= size; 1042 disk_used_ -= size;
1041 } 1043 }
1042 1044
1043 } // namespace storage 1045 } // namespace storage
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698