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