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/sandbox_mount_point_provider.h" | 5 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 namespace fileapi { | 35 namespace fileapi { |
36 | 36 |
37 class SandboxMountPointProviderOriginEnumeratorTest : public testing::Test { | 37 class SandboxMountPointProviderOriginEnumeratorTest : public testing::Test { |
38 public: | 38 public: |
39 void SetUp() { | 39 void SetUp() { |
40 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 40 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
41 sandbox_provider_.reset( | 41 sandbox_provider_.reset( |
42 new SandboxMountPointProvider( | 42 new SandboxMountPointProvider( |
43 NULL, | 43 NULL, |
44 base::MessageLoopProxy::current(), | 44 base::MessageLoopProxy::current().get(), |
45 data_dir_.path(), | 45 data_dir_.path(), |
46 CreateAllowFileAccessOptions())); | 46 CreateAllowFileAccessOptions())); |
47 } | 47 } |
48 | 48 |
49 SandboxMountPointProvider::OriginEnumerator* CreateEnumerator() const { | 49 SandboxMountPointProvider::OriginEnumerator* CreateEnumerator() const { |
50 return sandbox_provider_->CreateOriginEnumerator(); | 50 return sandbox_provider_->CreateOriginEnumerator(); |
51 } | 51 } |
52 | 52 |
53 protected: | 53 protected: |
54 void CreateOriginTypeDirectory(const GURL& origin, | 54 void CreateOriginTypeDirectory(const GURL& origin, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 143 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
144 } | 144 } |
145 | 145 |
146 void SetUp() { | 146 void SetUp() { |
147 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 147 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
148 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = | 148 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = |
149 new quota::MockSpecialStoragePolicy; | 149 new quota::MockSpecialStoragePolicy; |
150 special_storage_policy->SetAllUnlimited(true); | 150 special_storage_policy->SetAllUnlimited(true); |
151 file_system_context_ = new FileSystemContext( | 151 file_system_context_ = new FileSystemContext( |
152 FileSystemTaskRunners::CreateMockTaskRunners(), | 152 FileSystemTaskRunners::CreateMockTaskRunners(), |
153 special_storage_policy, | 153 special_storage_policy.get(), |
154 NULL, | 154 NULL, |
155 data_dir_.path(), | 155 data_dir_.path(), |
156 CreateAllowFileAccessOptions()); | 156 CreateAllowFileAccessOptions()); |
157 } | 157 } |
158 | 158 |
159 SandboxMountPointProvider* sandbox_provider() { | 159 SandboxMountPointProvider* sandbox_provider() { |
160 return file_system_context_->sandbox_provider(); | 160 return file_system_context_->sandbox_provider(); |
161 } | 161 } |
162 | 162 |
163 FileSystemFileUtil* file_util() { | 163 FileSystemFileUtil* file_util() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 ASSERT_TRUE(file_util::CreateDirectory( | 197 ASSERT_TRUE(file_util::CreateDirectory( |
198 root.AppendASCII(seed).AppendASCII("d 1"))); | 198 root.AppendASCII(seed).AppendASCII("d 1"))); |
199 EnsureFileExists(root.AppendASCII("file 0")); | 199 EnsureFileExists(root.AppendASCII("file 0")); |
200 EnsureFileExists( | 200 EnsureFileExists( |
201 root.AppendASCII(seed).AppendASCII("d 0").AppendASCII("file 1")); | 201 root.AppendASCII(seed).AppendASCII("d 0").AppendASCII("file 1")); |
202 EnsureFileExists( | 202 EnsureFileExists( |
203 root.AppendASCII(seed).AppendASCII("d 0").AppendASCII("file 2")); | 203 root.AppendASCII(seed).AppendASCII("d 0").AppendASCII("file 2")); |
204 } | 204 } |
205 | 205 |
206 FileSystemOperationContext* NewContext() { | 206 FileSystemOperationContext* NewContext() { |
207 return new FileSystemOperationContext(file_system_context_); | 207 return new FileSystemOperationContext(file_system_context_.get()); |
208 } | 208 } |
209 | 209 |
210 bool PathExists(const FileSystemURL& url) { | 210 bool PathExists(const FileSystemURL& url) { |
211 scoped_ptr<FileSystemOperationContext> context(NewContext()); | 211 scoped_ptr<FileSystemOperationContext> context(NewContext()); |
212 return FileUtilHelper::PathExists(context.get(), file_util(), url); | 212 return FileUtilHelper::PathExists(context.get(), file_util(), url); |
213 } | 213 } |
214 | 214 |
215 bool DirectoryExists(const FileSystemURL& url) { | 215 bool DirectoryExists(const FileSystemURL& url) { |
216 scoped_ptr<FileSystemOperationContext> context(NewContext()); | 216 scoped_ptr<FileSystemOperationContext> context(NewContext()); |
217 return FileUtilHelper::DirectoryExists(context.get(), file_util(), url); | 217 return FileUtilHelper::DirectoryExists(context.get(), file_util(), url); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 case 1: | 292 case 1: |
293 sandbox_provider()->GetFileSystemRootPathOnFileThread( | 293 sandbox_provider()->GetFileSystemRootPathOnFileThread( |
294 origin_url, type, FilePath(), create); | 294 origin_url, type, FilePath(), create); |
295 break; | 295 break; |
296 case 2: | 296 case 2: |
297 sandbox_provider()->GetBaseDirectoryForOriginAndType( | 297 sandbox_provider()->GetBaseDirectoryForOriginAndType( |
298 origin_url, type, create); | 298 origin_url, type, create); |
299 break; | 299 break; |
300 case 3: | 300 case 3: |
301 sandbox_provider()->DeleteOriginDataOnFileThread( | 301 sandbox_provider()->DeleteOriginDataOnFileThread( |
302 file_system_context_, NULL, origin_url, type); | 302 file_system_context_.get(), NULL, origin_url, type); |
303 break; | 303 break; |
304 case 4: | 304 case 4: |
305 sandbox_provider()->GetOriginsForTypeOnFileThread( | 305 sandbox_provider()->GetOriginsForTypeOnFileThread( |
306 type, &origins); | 306 type, &origins); |
307 break; | 307 break; |
308 case 5: | 308 case 5: |
309 sandbox_provider()->GetOriginsForHostOnFileThread( | 309 sandbox_provider()->GetOriginsForHostOnFileThread( |
310 type, host, &origins); | 310 type, host, &origins); |
311 break; | 311 break; |
312 case 6: | 312 case 6: |
313 sandbox_provider()->GetOriginUsageOnFileThread( | 313 sandbox_provider()->GetOriginUsageOnFileThread( |
314 file_system_context_, origin_url, type); | 314 file_system_context_.get(), origin_url, type); |
315 break; | 315 break; |
316 default: | 316 default: |
317 FAIL(); | 317 FAIL(); |
318 break; | 318 break; |
319 } | 319 } |
320 for (size_t i = 0; i < arraysize(kMigrationTestRecords); ++i) { | 320 for (size_t i = 0; i < arraysize(kMigrationTestRecords); ++i) { |
321 const MigrationTestCaseRecord& test_case = kMigrationTestRecords[i]; | 321 const MigrationTestCaseRecord& test_case = kMigrationTestRecords[i]; |
322 const GURL& origin_url = test_case.origin; | 322 const GURL& origin_url = test_case.origin; |
323 ASSERT_TRUE(test_case.has_temporary || test_case.has_persistent); | 323 ASSERT_TRUE(test_case.has_temporary || test_case.has_persistent); |
324 if (test_case.has_temporary) | 324 if (test_case.has_temporary) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 357 |
358 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod5) { | 358 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod5) { |
359 RunMigrationTest(5); | 359 RunMigrationTest(5); |
360 } | 360 } |
361 | 361 |
362 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod6) { | 362 TEST_F(SandboxMountPointProviderMigrationTest, TestMigrateViaMethod6) { |
363 RunMigrationTest(6); | 363 RunMigrationTest(6); |
364 } | 364 } |
365 | 365 |
366 } // namespace fileapi | 366 } // namespace fileapi |
OLD | NEW |