| 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_context.h" | 11 #include "webkit/fileapi/file_system_context.h" |
| 12 #include "webkit/fileapi/file_system_operation.h" | 12 #include "webkit/fileapi/file_system_operation.h" |
| 13 #include "webkit/fileapi/file_system_operation_context.h" | 13 #include "webkit/fileapi/file_system_operation_context.h" |
| 14 #include "webkit/fileapi/file_system_usage_cache.h" | 14 #include "webkit/fileapi/file_system_usage_cache.h" |
| 15 #include "webkit/fileapi/file_system_util.h" | 15 #include "webkit/fileapi/file_system_util.h" |
| 16 #include "webkit/fileapi/file_util_helper.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 { |
| 21 | 22 |
| 22 FileSystemTestOriginHelper::FileSystemTestOriginHelper( | 23 FileSystemTestOriginHelper::FileSystemTestOriginHelper( |
| 23 const GURL& origin, FileSystemType type) | 24 const GURL& origin, FileSystemType type) |
| 24 : origin_(origin), type_(type), file_util_(NULL) { | 25 : origin_(origin), type_(type), file_util_(NULL) { |
| 25 } | 26 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 128 |
| 128 FileSystemPath FileSystemTestOriginHelper::CreatePath( | 129 FileSystemPath FileSystemTestOriginHelper::CreatePath( |
| 129 const FilePath& path) const { | 130 const FilePath& path) const { |
| 130 return FileSystemPath(origin_, type_, path); | 131 return FileSystemPath(origin_, type_, path); |
| 131 } | 132 } |
| 132 | 133 |
| 133 base::PlatformFileError FileSystemTestOriginHelper::SameFileUtilCopy( | 134 base::PlatformFileError FileSystemTestOriginHelper::SameFileUtilCopy( |
| 134 FileSystemOperationContext* context, | 135 FileSystemOperationContext* context, |
| 135 const FileSystemPath& src, | 136 const FileSystemPath& src, |
| 136 const FileSystemPath& dest) const { | 137 const FileSystemPath& dest) const { |
| 137 CrossFileUtilHelper cross_util_helper( | 138 return FileUtilHelper::Copy(context, file_util(), file_util(), src, dest); |
| 138 context, | |
| 139 file_util(), file_util(), | |
| 140 src, dest, | |
| 141 CrossFileUtilHelper::OPERATION_COPY); | |
| 142 return cross_util_helper.DoWork(); | |
| 143 } | 139 } |
| 144 | 140 |
| 145 base::PlatformFileError FileSystemTestOriginHelper::SameFileUtilMove( | 141 base::PlatformFileError FileSystemTestOriginHelper::SameFileUtilMove( |
| 146 FileSystemOperationContext* context, | 142 FileSystemOperationContext* context, |
| 147 const FileSystemPath& src, | 143 const FileSystemPath& src, |
| 148 const FileSystemPath& dest) const { | 144 const FileSystemPath& dest) const { |
| 149 CrossFileUtilHelper cross_util_helper( | 145 return FileUtilHelper::Move(context, file_util(), file_util(), src, dest); |
| 150 context, | |
| 151 file_util(), file_util(), | |
| 152 src, dest, | |
| 153 CrossFileUtilHelper::OPERATION_MOVE); | |
| 154 return cross_util_helper.DoWork(); | |
| 155 } | 146 } |
| 156 | 147 |
| 157 int64 FileSystemTestOriginHelper::GetCachedOriginUsage() const { | 148 int64 FileSystemTestOriginHelper::GetCachedOriginUsage() const { |
| 158 return FileSystemUsageCache::GetUsage(GetUsageCachePath()); | 149 return FileSystemUsageCache::GetUsage(GetUsageCachePath()); |
| 159 } | 150 } |
| 160 | 151 |
| 161 bool FileSystemTestOriginHelper::RevokeUsageCache() const { | 152 bool FileSystemTestOriginHelper::RevokeUsageCache() const { |
| 162 return file_util::Delete(GetUsageCachePath(), false); | 153 return file_util::Delete(GetUsageCachePath(), false); |
| 163 } | 154 } |
| 164 | 155 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 180 } | 171 } |
| 181 | 172 |
| 182 FileSystemOperationContext* FileSystemTestOriginHelper::NewOperationContext() { | 173 FileSystemOperationContext* FileSystemTestOriginHelper::NewOperationContext() { |
| 183 DCHECK(file_system_context_.get()); | 174 DCHECK(file_system_context_.get()); |
| 184 FileSystemOperationContext* context = | 175 FileSystemOperationContext* context = |
| 185 new FileSystemOperationContext(file_system_context_.get()); | 176 new FileSystemOperationContext(file_system_context_.get()); |
| 186 return context; | 177 return context; |
| 187 } | 178 } |
| 188 | 179 |
| 189 } // namespace fileapi | 180 } // namespace fileapi |
| OLD | NEW |