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

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

Issue 6905095: Integrated test with the actual QuotaManager and PathManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Reflected the comments. Created 9 years, 6 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/file_system_quota_unittest.cc ('k') | webkit/tools/test_shell/test_shell.gypi » ('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) 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 FilePath usage_cache_path = file_system_context_->path_manager() 118 FilePath usage_cache_path = file_system_context_->path_manager()
119 ->sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); 119 ->sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_);
120 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0); 120 FileSystemUsageCache::UpdateUsage(usage_cache_path, 0);
121 121
122 // We expect the origin directory to be always empty, except for possibly 122 // We expect the origin directory to be always empty, except for possibly
123 // the usage cache file. We record the initial usage file size here 123 // the usage cache file. We record the initial usage file size here
124 // (it will be either 0 or kUsageFileSize) so that later we can compute 124 // (it will be either 0 or kUsageFileSize) so that later we can compute
125 // how much the size of the origin directory has grown. 125 // how much the size of the origin directory has grown.
126 initial_usage_size_ = file_util::ComputeDirectorySize( 126 initial_usage_size_ = file_util::ComputeDirectorySize(
127 GetOriginRootPath()); 127 GetOriginRootPath());
128
129 FileSystemUsageCache::UpdateUsage(usage_cache_path, initial_usage_size_);
128 } 130 }
129 131
130 void FileSystemTestOriginHelper::TearDown() { 132 void FileSystemTestOriginHelper::TearDown() {
131 file_system_context_ = NULL; 133 file_system_context_ = NULL;
132 MessageLoop::current()->RunAllPending(); 134 MessageLoop::current()->RunAllPending();
133 } 135 }
134 136
135 FilePath FileSystemTestOriginHelper::GetOriginRootPath() const { 137 FilePath FileSystemTestOriginHelper::GetOriginRootPath() const {
136 return file_system_context_->path_manager()-> 138 return file_system_context_->path_manager()->
137 ValidateFileSystemRootAndGetPathOnFileThread( 139 ValidateFileSystemRootAndGetPathOnFileThread(
(...skipping 17 matching lines...) Expand all
155 return GURL(GetFileSystemRootURI(origin_, type_).spec() + 157 return GURL(GetFileSystemRootURI(origin_, type_).spec() +
156 path.MaybeAsASCII()); 158 path.MaybeAsASCII());
157 } 159 }
158 160
159 FilePath FileSystemTestOriginHelper::GetUsageCachePath() const { 161 FilePath FileSystemTestOriginHelper::GetUsageCachePath() const {
160 return file_system_context_->path_manager() 162 return file_system_context_->path_manager()
161 ->sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_); 163 ->sandbox_provider()->GetUsageCachePathForOriginAndType(origin_, type_);
162 } 164 }
163 165
164 int64 FileSystemTestOriginHelper::GetCachedOriginUsage() const { 166 int64 FileSystemTestOriginHelper::GetCachedOriginUsage() const {
165 return FileSystemUsageCache::GetUsage(GetUsageCachePath()); 167 return FileSystemUsageCache::GetUsage(GetUsageCachePath()) -
168 initial_usage_size_;
166 } 169 }
167 170
168 int64 FileSystemTestOriginHelper::ComputeCurrentOriginUsage() const { 171 int64 FileSystemTestOriginHelper::ComputeCurrentOriginUsage() const {
169 // Depending on the file_util GetOriginRootPath() may include usage 172 // Depending on the file_util GetOriginRootPath() may include usage
170 // cache file size or may not. Here we subtract the initial size to 173 // cache file size or may not. Here we subtract the initial size to
171 // make it work for multiple file_utils. 174 // make it work for multiple file_utils.
172 return file_util::ComputeDirectorySize(GetOriginRootPath()) - 175 return file_util::ComputeDirectorySize(GetOriginRootPath()) -
173 initial_usage_size_; 176 initial_usage_size_;
174 } 177 }
175 178
(...skipping 22 matching lines...) Expand all
198 void FileSystemTestOriginHelper::InitializeOperationContext( 201 void FileSystemTestOriginHelper::InitializeOperationContext(
199 FileSystemOperationContext* context) { 202 FileSystemOperationContext* context) {
200 DCHECK(context); 203 DCHECK(context);
201 context->set_src_origin_url(origin_); 204 context->set_src_origin_url(origin_);
202 context->set_src_type(type_); 205 context->set_src_type(type_);
203 context->set_dest_origin_url(origin_); 206 context->set_dest_origin_url(origin_);
204 context->set_dest_type(type_); 207 context->set_dest_type(type_);
205 } 208 }
206 209
207 } // namespace fileapi 210 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_quota_unittest.cc ('k') | webkit/tools/test_shell/test_shell.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698