OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 DCHECK(file_system_context->sandbox_provider()); | 43 DCHECK(file_system_context->sandbox_provider()); |
44 | 44 |
45 file_util_ = file_util; | 45 file_util_ = file_util; |
46 file_system_context_ = file_system_context; | 46 file_system_context_ = file_system_context; |
47 if (!file_util_) | 47 if (!file_util_) |
48 file_util_ = file_system_context->sandbox_provider()->GetFileUtil(); | 48 file_util_ = file_system_context->sandbox_provider()->GetFileUtil(); |
49 DCHECK(file_util_); | 49 DCHECK(file_util_); |
50 | 50 |
51 // Prepare the origin's root directory. | 51 // Prepare the origin's root directory. |
52 file_system_context_->GetMountPointProvider(type_)-> | 52 file_system_context_->GetMountPointProvider(type_)-> |
53 ValidateFileSystemRootAndGetPathOnFileThread( | 53 GetFileSystemRootPathOnFileThread( |
54 origin_, type_, FilePath(), true /* create */); | 54 origin_, type_, FilePath(), true /* create */); |
55 | 55 |
56 // Initialize the usage cache file. | 56 // Initialize the usage cache file. |
57 FilePath usage_cache_path = file_system_context_-> | 57 FilePath usage_cache_path = file_system_context_-> |
58 sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); | 58 sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); |
59 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); | 59 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); |
60 } | 60 } |
61 | 61 |
62 void FileSystemTestOriginHelper::SetUp( | 62 void FileSystemTestOriginHelper::SetUp( |
63 const FilePath& base_dir, | 63 const FilePath& base_dir, |
(...skipping 10 matching lines...) Expand all Loading... |
74 base::MessageLoopProxy::current(), | 74 base::MessageLoopProxy::current(), |
75 special_storage_policy, | 75 special_storage_policy, |
76 quota_manager_proxy, | 76 quota_manager_proxy, |
77 base_dir, | 77 base_dir, |
78 new AllowFileAccessOptions()); | 78 new AllowFileAccessOptions()); |
79 | 79 |
80 DCHECK(file_system_context_->sandbox_provider()); | 80 DCHECK(file_system_context_->sandbox_provider()); |
81 | 81 |
82 // Prepare the origin's root directory. | 82 // Prepare the origin's root directory. |
83 file_system_context_->GetMountPointProvider(type_)-> | 83 file_system_context_->GetMountPointProvider(type_)-> |
84 ValidateFileSystemRootAndGetPathOnFileThread( | 84 GetFileSystemRootPathOnFileThread( |
85 origin_, type_, FilePath(), true /* create */); | 85 origin_, type_, FilePath(), true /* create */); |
86 | 86 |
87 // Initialize the usage cache file. This code assumes that we're either using | 87 // Initialize the usage cache file. This code assumes that we're either using |
88 // OFSFU or we've mocked it out in the sandbox provider. | 88 // OFSFU or we've mocked it out in the sandbox provider. |
89 FilePath usage_cache_path = file_system_context_-> | 89 FilePath usage_cache_path = file_system_context_-> |
90 sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); | 90 sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); |
91 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); | 91 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); |
92 } | 92 } |
93 | 93 |
94 void FileSystemTestOriginHelper::TearDown() { | 94 void FileSystemTestOriginHelper::TearDown() { |
95 file_system_context_ = NULL; | 95 file_system_context_ = NULL; |
96 MessageLoop::current()->RunAllPending(); | 96 MessageLoop::current()->RunAllPending(); |
97 } | 97 } |
98 | 98 |
99 FilePath FileSystemTestOriginHelper::GetOriginRootPath() const { | 99 FilePath FileSystemTestOriginHelper::GetOriginRootPath() const { |
100 return file_system_context_->GetMountPointProvider(type_)-> | 100 return file_system_context_->GetMountPointProvider(type_)-> |
101 ValidateFileSystemRootAndGetPathOnFileThread( | 101 GetFileSystemRootPathOnFileThread( |
102 origin_, type_, FilePath(), false); | 102 origin_, type_, FilePath(), false); |
103 } | 103 } |
104 | 104 |
105 FilePath FileSystemTestOriginHelper::GetLocalPath(const FilePath& path) { | 105 FilePath FileSystemTestOriginHelper::GetLocalPath(const FilePath& path) { |
106 DCHECK(file_util_); | 106 DCHECK(file_util_); |
107 FilePath local_path; | 107 FilePath local_path; |
108 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); | 108 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); |
109 file_util_->GetLocalFilePath(context.get(), path, &local_path); | 109 file_util_->GetLocalFilePath(context.get(), path, &local_path); |
110 return local_path; | 110 return local_path; |
111 } | 111 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 void FileSystemTestOriginHelper::InitializeOperationContext( | 165 void FileSystemTestOriginHelper::InitializeOperationContext( |
166 FileSystemOperationContext* context) { | 166 FileSystemOperationContext* context) { |
167 DCHECK(context); | 167 DCHECK(context); |
168 context->set_src_origin_url(origin_); | 168 context->set_src_origin_url(origin_); |
169 context->set_src_type(type_); | 169 context->set_src_type(type_); |
170 context->set_dest_origin_url(origin_); | 170 context->set_dest_origin_url(origin_); |
171 context->set_dest_type(type_); | 171 context->set_dest_type(type_); |
172 } | 172 } |
173 | 173 |
174 } // namespace fileapi | 174 } // namespace fileapi |
OLD | NEW |