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/browser/fileapi/test_mount_point_provider.h" | 5 #include "webkit/browser/fileapi/test_mount_point_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 bool TestMountPointProvider::CanHandleType(FileSystemType type) const { | 90 bool TestMountPointProvider::CanHandleType(FileSystemType type) const { |
91 return (type == kFileSystemTypeTest); | 91 return (type == kFileSystemTypeTest); |
92 } | 92 } |
93 | 93 |
94 void TestMountPointProvider::ValidateFileSystemRoot( | 94 void TestMountPointProvider::ValidateFileSystemRoot( |
95 const GURL& origin_url, | 95 const GURL& origin_url, |
96 FileSystemType type, | 96 FileSystemType type, |
97 bool create, | 97 bool create, |
98 const ValidateFileSystemCallback& callback) { | 98 const ValidateFileSystemCallback& callback) { |
99 // This won't be called unless we add test code that opens a test | 99 callback.Run(base::PLATFORM_FILE_OK); |
100 // filesystem by OpenFileSystem. | |
101 NOTREACHED(); | |
102 } | |
103 | |
104 base::FilePath TestMountPointProvider::GetFileSystemRootPathOnFileThread( | |
105 const FileSystemURL& url, | |
106 bool create) { | |
107 DCHECK_EQ(kFileSystemTypeTest, url.type()); | |
108 bool success = true; | |
109 if (create) | |
110 success = file_util::CreateDirectory(base_path_); | |
111 else | |
112 success = file_util::DirectoryExists(base_path_); | |
113 return success ? base_path_ : base::FilePath(); | |
114 } | 100 } |
115 | 101 |
116 FileSystemFileUtil* TestMountPointProvider::GetFileUtil(FileSystemType type) { | 102 FileSystemFileUtil* TestMountPointProvider::GetFileUtil(FileSystemType type) { |
117 DCHECK(local_file_util_.get()); | 103 DCHECK(local_file_util_.get()); |
118 return local_file_util_->sync_file_util(); | 104 return local_file_util_->sync_file_util(); |
119 } | 105 } |
120 | 106 |
121 AsyncFileUtil* TestMountPointProvider::GetAsyncFileUtil(FileSystemType type) { | 107 AsyncFileUtil* TestMountPointProvider::GetAsyncFileUtil(FileSystemType type) { |
122 return local_file_util_.get(); | 108 return local_file_util_.get(); |
123 } | 109 } |
(...skipping 26 matching lines...) Expand all Loading... |
150 return FILE_PERMISSION_ALWAYS_DENY; | 136 return FILE_PERMISSION_ALWAYS_DENY; |
151 } | 137 } |
152 | 138 |
153 FileSystemOperation* TestMountPointProvider::CreateFileSystemOperation( | 139 FileSystemOperation* TestMountPointProvider::CreateFileSystemOperation( |
154 const FileSystemURL& url, | 140 const FileSystemURL& url, |
155 FileSystemContext* context, | 141 FileSystemContext* context, |
156 base::PlatformFileError* error_code) const { | 142 base::PlatformFileError* error_code) const { |
157 scoped_ptr<FileSystemOperationContext> operation_context( | 143 scoped_ptr<FileSystemOperationContext> operation_context( |
158 new FileSystemOperationContext(context)); | 144 new FileSystemOperationContext(context)); |
159 operation_context->set_update_observers(observers_); | 145 operation_context->set_update_observers(observers_); |
| 146 operation_context->set_root_path(base_path_); |
160 return new LocalFileSystemOperation(context, operation_context.Pass()); | 147 return new LocalFileSystemOperation(context, operation_context.Pass()); |
161 } | 148 } |
162 | 149 |
163 scoped_ptr<webkit_blob::FileStreamReader> | 150 scoped_ptr<webkit_blob::FileStreamReader> |
164 TestMountPointProvider::CreateFileStreamReader( | 151 TestMountPointProvider::CreateFileStreamReader( |
165 const FileSystemURL& url, | 152 const FileSystemURL& url, |
166 int64 offset, | 153 int64 offset, |
167 const base::Time& expected_modification_time, | 154 const base::Time& expected_modification_time, |
168 FileSystemContext* context) const { | 155 FileSystemContext* context) const { |
169 return scoped_ptr<webkit_blob::FileStreamReader>( | 156 return scoped_ptr<webkit_blob::FileStreamReader>( |
(...skipping 24 matching lines...) Expand all Loading... |
194 NOTREACHED(); | 181 NOTREACHED(); |
195 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 182 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
196 } | 183 } |
197 | 184 |
198 const UpdateObserverList* TestMountPointProvider::GetUpdateObservers( | 185 const UpdateObserverList* TestMountPointProvider::GetUpdateObservers( |
199 FileSystemType type) const { | 186 FileSystemType type) const { |
200 return &observers_; | 187 return &observers_; |
201 } | 188 } |
202 | 189 |
203 } // namespace fileapi | 190 } // namespace fileapi |
OLD | NEW |