| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/platform_file.h" | 14 #include "base/platform_file.h" |
| 15 #include "base/scoped_temp_dir.h" | 15 #include "base/scoped_temp_dir.h" |
| 16 #include "base/sys_string_conversions.h" | 16 #include "base/sys_string_conversions.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "webkit/fileapi/file_system_context.h" | 18 #include "webkit/fileapi/file_system_context.h" |
| 19 #include "webkit/fileapi/file_system_operation_context.h" | 19 #include "webkit/fileapi/file_system_operation_context.h" |
| 20 #include "webkit/fileapi/file_system_task_runners.h" |
| 20 #include "webkit/fileapi/file_system_usage_cache.h" | 21 #include "webkit/fileapi/file_system_usage_cache.h" |
| 21 #include "webkit/fileapi/file_util_helper.h" | 22 #include "webkit/fileapi/file_util_helper.h" |
| 22 #include "webkit/fileapi/local_file_system_test_helper.h" | 23 #include "webkit/fileapi/local_file_system_test_helper.h" |
| 23 #include "webkit/fileapi/mock_file_system_options.h" | 24 #include "webkit/fileapi/mock_file_system_options.h" |
| 24 #include "webkit/fileapi/obfuscated_file_util.h" | 25 #include "webkit/fileapi/obfuscated_file_util.h" |
| 25 #include "webkit/fileapi/test_file_set.h" | 26 #include "webkit/fileapi/test_file_set.h" |
| 26 #include "webkit/quota/mock_special_storage_policy.h" | 27 #include "webkit/quota/mock_special_storage_policy.h" |
| 27 #include "webkit/quota/quota_manager.h" | 28 #include "webkit/quota/quota_manager.h" |
| 28 #include "webkit/quota/quota_types.h" | 29 #include "webkit/quota/quota_types.h" |
| 29 | 30 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 false /* is_incognito */, | 115 false /* is_incognito */, |
| 115 data_dir_.path(), | 116 data_dir_.path(), |
| 116 base::MessageLoopProxy::current(), | 117 base::MessageLoopProxy::current(), |
| 117 base::MessageLoopProxy::current(), | 118 base::MessageLoopProxy::current(), |
| 118 storage_policy); | 119 storage_policy); |
| 119 | 120 |
| 120 // Every time we create a new helper, it creates another context, which | 121 // Every time we create a new helper, it creates another context, which |
| 121 // creates another path manager, another sandbox_mount_point_provider, and | 122 // creates another path manager, another sandbox_mount_point_provider, and |
| 122 // another OFU. We need to pass in the context to skip all that. | 123 // another OFU. We need to pass in the context to skip all that. |
| 123 file_system_context_ = new FileSystemContext( | 124 file_system_context_ = new FileSystemContext( |
| 124 base::MessageLoopProxy::current(), | 125 FileSystemTaskRunners::CreateMockTaskRunners(), |
| 125 base::MessageLoopProxy::current(), | |
| 126 storage_policy, | 126 storage_policy, |
| 127 quota_manager_->proxy(), | 127 quota_manager_->proxy(), |
| 128 data_dir_.path(), | 128 data_dir_.path(), |
| 129 CreateAllowFileAccessOptions()); | 129 CreateAllowFileAccessOptions()); |
| 130 | 130 |
| 131 obfuscated_file_util_ = static_cast<ObfuscatedFileUtil*>( | 131 obfuscated_file_util_ = static_cast<ObfuscatedFileUtil*>( |
| 132 file_system_context_->GetFileUtil(type_)); | 132 file_system_context_->GetFileUtil(type_)); |
| 133 | 133 |
| 134 test_helper_.SetUp(file_system_context_.get(), | 134 test_helper_.SetUp(file_system_context_.get(), |
| 135 obfuscated_file_util_); | 135 obfuscated_file_util_); |
| (...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 | 2210 |
| 2211 // Opening it with TRUNCATED flag, which should truncate the file size. | 2211 // Opening it with TRUNCATED flag, which should truncate the file size. |
| 2212 ASSERT_EQ(base::PLATFORM_FILE_OK, | 2212 ASSERT_EQ(base::PLATFORM_FILE_OK, |
| 2213 ofu()->CreateOrOpen( | 2213 ofu()->CreateOrOpen( |
| 2214 AllowUsageIncrease(-length)->context(), file, | 2214 AllowUsageIncrease(-length)->context(), file, |
| 2215 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, | 2215 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, |
| 2216 &file_handle, &created)); | 2216 &file_handle, &created)); |
| 2217 ASSERT_EQ(0, ComputeTotalFileSize()); | 2217 ASSERT_EQ(0, ComputeTotalFileSize()); |
| 2218 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); | 2218 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); |
| 2219 } | 2219 } |
| OLD | NEW |