Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: webkit/fileapi/local_file_system_test_helper.cc

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/local_file_system_test_helper.h ('k') | webkit/fileapi/local_file_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/local_file_system_test_helper.h" 5 #include "webkit/fileapi/local_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 20 matching lines...) Expand all
31 31
32 LocalFileSystemTestOriginHelper::LocalFileSystemTestOriginHelper() 32 LocalFileSystemTestOriginHelper::LocalFileSystemTestOriginHelper()
33 : origin_(GURL("http://foo.com")), 33 : origin_(GURL("http://foo.com")),
34 type_(kFileSystemTypeTemporary), 34 type_(kFileSystemTypeTemporary),
35 file_util_(NULL) { 35 file_util_(NULL) {
36 } 36 }
37 37
38 LocalFileSystemTestOriginHelper::~LocalFileSystemTestOriginHelper() { 38 LocalFileSystemTestOriginHelper::~LocalFileSystemTestOriginHelper() {
39 } 39 }
40 40
41 void LocalFileSystemTestOriginHelper::SetUp(const FilePath& base_dir) { 41 void LocalFileSystemTestOriginHelper::SetUp(const base::FilePath& base_dir) {
42 SetUp(base_dir, false, NULL); 42 SetUp(base_dir, false, NULL);
43 } 43 }
44 44
45 void LocalFileSystemTestOriginHelper::SetUp( 45 void LocalFileSystemTestOriginHelper::SetUp(
46 FileSystemContext* file_system_context) { 46 FileSystemContext* file_system_context) {
47 file_system_context_ = file_system_context; 47 file_system_context_ = file_system_context;
48 48
49 SetUpFileUtil(); 49 SetUpFileUtil();
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 GetFileSystemRootPathOnFileThread(CreateURL(FilePath()), 53 GetFileSystemRootPathOnFileThread(CreateURL(base::FilePath()),
54 true /* create */); 54 true /* create */);
55 55
56 // Initialize the usage cache file. 56 // Initialize the usage cache file.
57 FilePath usage_cache_path = GetUsageCachePath(); 57 base::FilePath usage_cache_path = GetUsageCachePath();
58 if (!usage_cache_path.empty()) 58 if (!usage_cache_path.empty())
59 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); 59 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0);
60 } 60 }
61 61
62 void LocalFileSystemTestOriginHelper::SetUp( 62 void LocalFileSystemTestOriginHelper::SetUp(
63 const FilePath& base_dir, 63 const base::FilePath& base_dir,
64 bool unlimited_quota, 64 bool unlimited_quota,
65 quota::QuotaManagerProxy* quota_manager_proxy) { 65 quota::QuotaManagerProxy* quota_manager_proxy) {
66 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = 66 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
67 new quota::MockSpecialStoragePolicy; 67 new quota::MockSpecialStoragePolicy;
68 special_storage_policy->SetAllUnlimited(unlimited_quota); 68 special_storage_policy->SetAllUnlimited(unlimited_quota);
69 file_system_context_ = new FileSystemContext( 69 file_system_context_ = new FileSystemContext(
70 FileSystemTaskRunners::CreateMockTaskRunners(), 70 FileSystemTaskRunners::CreateMockTaskRunners(),
71 ExternalMountPoints::CreateRefCounted().get(), 71 ExternalMountPoints::CreateRefCounted().get(),
72 special_storage_policy, 72 special_storage_policy,
73 quota_manager_proxy, 73 quota_manager_proxy,
74 base_dir, 74 base_dir,
75 CreateAllowFileAccessOptions()); 75 CreateAllowFileAccessOptions());
76 76
77 SetUpFileUtil(); 77 SetUpFileUtil();
78 78
79 // Prepare the origin's root directory. 79 // Prepare the origin's root directory.
80 FileSystemMountPointProvider* mount_point_provider = 80 FileSystemMountPointProvider* mount_point_provider =
81 file_system_context_->GetMountPointProvider(type_); 81 file_system_context_->GetMountPointProvider(type_);
82 mount_point_provider->GetFileSystemRootPathOnFileThread(CreateURL(FilePath()), 82 mount_point_provider->GetFileSystemRootPathOnFileThread(CreateURL(base::FilePa th()),
83 true /* create */); 83 true /* create */);
84 84
85 // Initialize the usage cache file. 85 // Initialize the usage cache file.
86 FilePath usage_cache_path = GetUsageCachePath(); 86 base::FilePath usage_cache_path = GetUsageCachePath();
87 if (!usage_cache_path.empty()) 87 if (!usage_cache_path.empty())
88 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); 88 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0);
89 } 89 }
90 90
91 void LocalFileSystemTestOriginHelper::TearDown() { 91 void LocalFileSystemTestOriginHelper::TearDown() {
92 file_system_context_ = NULL; 92 file_system_context_ = NULL;
93 MessageLoop::current()->RunUntilIdle(); 93 MessageLoop::current()->RunUntilIdle();
94 } 94 }
95 95
96 FilePath LocalFileSystemTestOriginHelper::GetOriginRootPath() const { 96 base::FilePath LocalFileSystemTestOriginHelper::GetOriginRootPath() const {
97 return file_system_context_->GetMountPointProvider(type_)-> 97 return file_system_context_->GetMountPointProvider(type_)->
98 GetFileSystemRootPathOnFileThread(CreateURL(FilePath()), false); 98 GetFileSystemRootPathOnFileThread(CreateURL(base::FilePath()), false);
99 } 99 }
100 100
101 FilePath LocalFileSystemTestOriginHelper::GetLocalPath(const FilePath& path) { 101 base::FilePath LocalFileSystemTestOriginHelper::GetLocalPath(const base::FilePat h& path) {
102 DCHECK(file_util_); 102 DCHECK(file_util_);
103 FilePath local_path; 103 base::FilePath local_path;
104 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); 104 scoped_ptr<FileSystemOperationContext> context(NewOperationContext());
105 file_util_->GetLocalFilePath(context.get(), CreateURL(path), &local_path); 105 file_util_->GetLocalFilePath(context.get(), CreateURL(path), &local_path);
106 return local_path; 106 return local_path;
107 } 107 }
108 108
109 FilePath LocalFileSystemTestOriginHelper::GetLocalPathFromASCII( 109 base::FilePath LocalFileSystemTestOriginHelper::GetLocalPathFromASCII(
110 const std::string& path) { 110 const std::string& path) {
111 return GetLocalPath(FilePath().AppendASCII(path)); 111 return GetLocalPath(base::FilePath().AppendASCII(path));
112 } 112 }
113 113
114 FilePath LocalFileSystemTestOriginHelper::GetUsageCachePath() const { 114 base::FilePath LocalFileSystemTestOriginHelper::GetUsageCachePath() const {
115 if (type_ != kFileSystemTypeTemporary && 115 if (type_ != kFileSystemTypeTemporary &&
116 type_ != kFileSystemTypePersistent) 116 type_ != kFileSystemTypePersistent)
117 return FilePath(); 117 return base::FilePath();
118 return file_system_context_-> 118 return file_system_context_->
119 sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); 119 sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_);
120 } 120 }
121 121
122 FileSystemURL LocalFileSystemTestOriginHelper::CreateURL(const FilePath& path) 122 FileSystemURL LocalFileSystemTestOriginHelper::CreateURL(const base::FilePath& p ath)
123 const { 123 const {
124 return file_system_context_->CreateCrackedFileSystemURL(origin_, type_, path); 124 return file_system_context_->CreateCrackedFileSystemURL(origin_, type_, path);
125 } 125 }
126 126
127 base::PlatformFileError LocalFileSystemTestOriginHelper::SameFileUtilCopy( 127 base::PlatformFileError LocalFileSystemTestOriginHelper::SameFileUtilCopy(
128 FileSystemOperationContext* context, 128 FileSystemOperationContext* context,
129 const FileSystemURL& src, 129 const FileSystemURL& src,
130 const FileSystemURL& dest) const { 130 const FileSystemURL& dest) const {
131 return FileUtilHelper::Copy(context, file_util(), file_util(), src, dest); 131 return FileUtilHelper::Copy(context, file_util(), file_util(), src, dest);
132 } 132 }
(...skipping 23 matching lines...) Expand all
156 GetOriginRootPath().AppendASCII("Paths")); 156 GetOriginRootPath().AppendASCII("Paths"));
157 } 157 }
158 158
159 LocalFileSystemOperation* LocalFileSystemTestOriginHelper::NewOperation() { 159 LocalFileSystemOperation* LocalFileSystemTestOriginHelper::NewOperation() {
160 DCHECK(file_system_context_.get()); 160 DCHECK(file_system_context_.get());
161 DCHECK(file_util_); 161 DCHECK(file_util_);
162 scoped_ptr<FileSystemOperationContext> operation_context( 162 scoped_ptr<FileSystemOperationContext> operation_context(
163 NewOperationContext()); 163 NewOperationContext());
164 LocalFileSystemOperation* operation = static_cast<LocalFileSystemOperation*>( 164 LocalFileSystemOperation* operation = static_cast<LocalFileSystemOperation*>(
165 file_system_context_->CreateFileSystemOperation( 165 file_system_context_->CreateFileSystemOperation(
166 CreateURL(FilePath()), NULL)); 166 CreateURL(base::FilePath()), NULL));
167 return operation; 167 return operation;
168 } 168 }
169 169
170 FileSystemOperationContext* 170 FileSystemOperationContext*
171 LocalFileSystemTestOriginHelper::NewOperationContext() { 171 LocalFileSystemTestOriginHelper::NewOperationContext() {
172 DCHECK(file_system_context_.get()); 172 DCHECK(file_system_context_.get());
173 FileSystemOperationContext* context = 173 FileSystemOperationContext* context =
174 new FileSystemOperationContext(file_system_context_.get()); 174 new FileSystemOperationContext(file_system_context_.get());
175 context->set_update_observers( 175 context->set_update_observers(
176 *file_system_context_->GetUpdateObservers(type_)); 176 *file_system_context_->GetUpdateObservers(type_));
177 return context; 177 return context;
178 } 178 }
179 179
180 void LocalFileSystemTestOriginHelper::SetUpFileUtil() { 180 void LocalFileSystemTestOriginHelper::SetUpFileUtil() {
181 DCHECK(file_system_context_); 181 DCHECK(file_system_context_);
182 if (type_ == kFileSystemTypeTest) { 182 if (type_ == kFileSystemTypeTest) {
183 file_system_context_->RegisterMountPointProvider( 183 file_system_context_->RegisterMountPointProvider(
184 type_, 184 type_,
185 new TestMountPointProvider( 185 new TestMountPointProvider(
186 file_system_context_->task_runners()->file_task_runner(), 186 file_system_context_->task_runners()->file_task_runner(),
187 file_system_context_->partition_path())); 187 file_system_context_->partition_path()));
188 } 188 }
189 file_util_ = file_system_context_->GetFileUtil(type_); 189 file_util_ = file_system_context_->GetFileUtil(type_);
190 DCHECK(file_util_); 190 DCHECK(file_util_);
191 } 191 }
192 192
193 } // namespace fileapi 193 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/local_file_system_test_helper.h ('k') | webkit/fileapi/local_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698