| OLD | NEW |
| 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
| 6 #include "content/browser/blob_storage/chrome_blob_storage_context.h" | 6 #include "content/browser/blob_storage/chrome_blob_storage_context.h" |
| 7 #include "content/public/browser/browser_context.h" | 7 #include "content/public/browser/browser_context.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 // This browser test is aimed towards exercising the blob storage transportation | 29 // This browser test is aimed towards exercising the blob storage transportation |
| 30 // strategies and paging memory to disk. | 30 // strategies and paging memory to disk. |
| 31 class BlobStorageBrowserTest : public ContentBrowserTest { | 31 class BlobStorageBrowserTest : public ContentBrowserTest { |
| 32 public: | 32 public: |
| 33 BlobStorageBrowserTest() { | 33 BlobStorageBrowserTest() { |
| 34 limits_.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes; | 34 limits_.max_ipc_memory_size = kTestBlobStorageIPCThresholdBytes; |
| 35 limits_.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes; | 35 limits_.max_shared_memory_size = kTestBlobStorageMaxSharedMemoryBytes; |
| 36 limits_.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize; | 36 limits_.max_blob_in_memory_space = kTestBlobStorageMaxBlobMemorySize; |
| 37 limits_.max_blob_disk_space = kTestBlobStorageMaxDiskSpace; | 37 limits_.desired_max_disk_space = kTestBlobStorageMaxDiskSpace; |
| 38 limits_.effective_max_disk_space = kTestBlobStorageMaxDiskSpace; |
| 38 limits_.min_page_file_size = kTestBlobStorageMinFileSizeBytes; | 39 limits_.min_page_file_size = kTestBlobStorageMinFileSizeBytes; |
| 39 limits_.max_file_size = kTestBlobStorageMaxFileSizeBytes; | 40 limits_.max_file_size = kTestBlobStorageMaxFileSizeBytes; |
| 40 } | 41 } |
| 41 | 42 |
| 42 void SetBlobLimits() { | 43 void SetBlobLimits() { |
| 43 GetMemoryController()->set_limits_for_testing(limits_); | 44 GetMemoryController()->set_limits_for_testing(limits_); |
| 44 } | 45 } |
| 45 | 46 |
| 46 storage::BlobMemoryController* GetMemoryController() { | 47 storage::BlobMemoryController* GetMemoryController() { |
| 47 content::ChromeBlobStorageContext* blob_context = | 48 content::ChromeBlobStorageContext* blob_context = |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 SimpleTest(GetTestUrl("blob_storage", "blob_creation_and_slicing.html")); | 82 SimpleTest(GetTestUrl("blob_storage", "blob_creation_and_slicing.html")); |
| 82 storage::BlobMemoryController* memory_controller = GetMemoryController(); | 83 storage::BlobMemoryController* memory_controller = GetMemoryController(); |
| 83 // Our exact usages depend on IPC message ordering & garbage collection. | 84 // Our exact usages depend on IPC message ordering & garbage collection. |
| 84 // Since this is basically random, we just check bounds. | 85 // Since this is basically random, we just check bounds. |
| 85 EXPECT_LT(0u, memory_controller->memory_usage()); | 86 EXPECT_LT(0u, memory_controller->memory_usage()); |
| 86 EXPECT_LT(0ul, memory_controller->disk_usage()); | 87 EXPECT_LT(0ul, memory_controller->disk_usage()); |
| 87 EXPECT_GT(memory_controller->disk_usage(), | 88 EXPECT_GT(memory_controller->disk_usage(), |
| 88 static_cast<uint64_t>(memory_controller->memory_usage())); | 89 static_cast<uint64_t>(memory_controller->memory_usage())); |
| 89 EXPECT_GT(limits_.max_blob_in_memory_space, | 90 EXPECT_GT(limits_.max_blob_in_memory_space, |
| 90 memory_controller->memory_usage()); | 91 memory_controller->memory_usage()); |
| 91 EXPECT_GT(limits_.max_blob_disk_space, memory_controller->disk_usage()); | 92 EXPECT_GT(limits_.effective_max_disk_space, memory_controller->disk_usage()); |
| 92 shell()->Close(); | 93 shell()->Close(); |
| 93 | 94 |
| 94 // Make sure we run all file / io tasks. | 95 // Make sure we run all file / io tasks. |
| 95 base::RunLoop().RunUntilIdle(); | 96 base::RunLoop().RunUntilIdle(); |
| 96 BrowserThread::GetBlockingPool()->FlushForTesting(); | 97 BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 97 base::RunLoop().RunUntilIdle(); | 98 base::RunLoop().RunUntilIdle(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 } // namespace content | 101 } // namespace content |
| OLD | NEW |