| 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 "webkit/fileapi/file_system_test_helper.h" | 5 #include "webkit/fileapi/file_system_test_helper.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| 11 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
| 11 #include "webkit/fileapi/file_system_context.h" | 12 #include "webkit/fileapi/file_system_context.h" |
| 12 #include "webkit/fileapi/file_system_operation.h" | 13 #include "webkit/fileapi/file_system_operation.h" |
| 13 #include "webkit/fileapi/file_system_operation_context.h" | 14 #include "webkit/fileapi/file_system_operation_context.h" |
| 14 #include "webkit/fileapi/file_system_usage_cache.h" | 15 #include "webkit/fileapi/file_system_usage_cache.h" |
| 15 #include "webkit/fileapi/file_system_util.h" | 16 #include "webkit/fileapi/file_system_util.h" |
| 16 #include "webkit/fileapi/mock_file_system_options.h" | 17 #include "webkit/fileapi/mock_file_system_options.h" |
| 17 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 18 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
| 18 #include "webkit/quota/mock_special_storage_policy.h" | 19 #include "webkit/quota/mock_special_storage_policy.h" |
| 19 | 20 |
| 20 namespace fileapi { | 21 namespace fileapi { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return file_util::Delete(GetUsageCachePath(), false); | 134 return file_util::Delete(GetUsageCachePath(), false); |
| 134 } | 135 } |
| 135 | 136 |
| 136 int64 FileSystemTestOriginHelper::ComputeCurrentOriginUsage() const { | 137 int64 FileSystemTestOriginHelper::ComputeCurrentOriginUsage() const { |
| 137 int64 size = file_util::ComputeDirectorySize(GetOriginRootPath()); | 138 int64 size = file_util::ComputeDirectorySize(GetOriginRootPath()); |
| 138 if (file_util::PathExists(GetUsageCachePath())) | 139 if (file_util::PathExists(GetUsageCachePath())) |
| 139 size -= FileSystemUsageCache::kUsageFileSize; | 140 size -= FileSystemUsageCache::kUsageFileSize; |
| 140 return size; | 141 return size; |
| 141 } | 142 } |
| 142 | 143 |
| 143 FileSystemOperation* FileSystemTestOriginHelper::NewOperation() { | 144 FileSystemOperation* FileSystemTestOriginHelper::NewOperation( |
| 145 FileSystemCallbackDispatcher* callback_dispatcher) { |
| 144 DCHECK(file_system_context_.get()); | 146 DCHECK(file_system_context_.get()); |
| 145 DCHECK(file_util_); | 147 DCHECK(file_util_); |
| 146 FileSystemOperation* operation = | 148 FileSystemOperation* operation = |
| 147 new FileSystemOperation(base::MessageLoopProxy::current(), | 149 new FileSystemOperation(scoped_ptr<FileSystemCallbackDispatcher>( |
| 150 callback_dispatcher), |
| 151 base::MessageLoopProxy::current(), |
| 148 file_system_context_.get()); | 152 file_system_context_.get()); |
| 149 operation->set_override_file_util(file_util_); | 153 operation->set_override_file_util(file_util_); |
| 150 InitializeOperationContext(operation->file_system_operation_context()); | 154 InitializeOperationContext(operation->file_system_operation_context()); |
| 151 return operation; | 155 return operation; |
| 152 } | 156 } |
| 153 | 157 |
| 154 FileSystemOperationContext* FileSystemTestOriginHelper::NewOperationContext() { | 158 FileSystemOperationContext* FileSystemTestOriginHelper::NewOperationContext() { |
| 155 DCHECK(file_system_context_.get()); | 159 DCHECK(file_system_context_.get()); |
| 156 DCHECK(file_util_); | 160 DCHECK(file_util_); |
| 157 FileSystemOperationContext* context = | 161 FileSystemOperationContext* context = |
| 158 new FileSystemOperationContext(file_system_context_.get(), file_util_); | 162 new FileSystemOperationContext(file_system_context_.get(), file_util_); |
| 159 InitializeOperationContext(context); | 163 InitializeOperationContext(context); |
| 160 return context; | 164 return context; |
| 161 } | 165 } |
| 162 | 166 |
| 163 void FileSystemTestOriginHelper::InitializeOperationContext( | 167 void FileSystemTestOriginHelper::InitializeOperationContext( |
| 164 FileSystemOperationContext* context) { | 168 FileSystemOperationContext* context) { |
| 165 DCHECK(context); | 169 DCHECK(context); |
| 166 context->set_src_origin_url(origin_); | 170 context->set_src_origin_url(origin_); |
| 167 context->set_src_type(type_); | 171 context->set_src_type(type_); |
| 168 context->set_dest_origin_url(origin_); | 172 context->set_dest_origin_url(origin_); |
| 169 context->set_dest_type(type_); | 173 context->set_dest_type(type_); |
| 170 } | 174 } |
| 171 | 175 |
| 172 } // namespace fileapi | 176 } // namespace fileapi |
| OLD | NEW |