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

Side by Side Diff: webkit/browser/fileapi/sandbox_file_system_test_helper.cc

Issue 21116008: FileAPI: Move FileSystemQuotaUtil related functions into SandboxContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up Created 7 years, 4 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
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/browser/fileapi/sandbox_file_system_test_helper.h" 5 #include "webkit/browser/fileapi/sandbox_file_system_test_helper.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 SetUpFileSystem(); 56 SetUpFileSystem();
57 } 57 }
58 58
59 void SandboxFileSystemTestHelper::TearDown() { 59 void SandboxFileSystemTestHelper::TearDown() {
60 file_system_context_ = NULL; 60 file_system_context_ = NULL;
61 base::MessageLoop::current()->RunUntilIdle(); 61 base::MessageLoop::current()->RunUntilIdle();
62 } 62 }
63 63
64 base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() { 64 base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() {
65 return file_system_context_->sandbox_backend()-> 65 return file_system_context_->sandbox_context()->
66 GetBaseDirectoryForOriginAndType(origin_, type_, false); 66 GetBaseDirectoryForOriginAndType(origin_, type_, false);
67 } 67 }
68 68
69 base::FilePath SandboxFileSystemTestHelper::GetLocalPath( 69 base::FilePath SandboxFileSystemTestHelper::GetLocalPath(
70 const base::FilePath& path) { 70 const base::FilePath& path) {
71 DCHECK(file_util_); 71 DCHECK(file_util_);
72 base::FilePath local_path; 72 base::FilePath local_path;
73 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); 73 scoped_ptr<FileSystemOperationContext> context(NewOperationContext());
74 file_util_->GetLocalFilePath(context.get(), CreateURL(path), &local_path); 74 file_util_->GetLocalFilePath(context.get(), CreateURL(path), &local_path);
75 return local_path; 75 return local_path;
76 } 76 }
77 77
78 base::FilePath SandboxFileSystemTestHelper::GetLocalPathFromASCII( 78 base::FilePath SandboxFileSystemTestHelper::GetLocalPathFromASCII(
79 const std::string& path) { 79 const std::string& path) {
80 return GetLocalPath(base::FilePath().AppendASCII(path)); 80 return GetLocalPath(base::FilePath().AppendASCII(path));
81 } 81 }
82 82
83 base::FilePath SandboxFileSystemTestHelper::GetUsageCachePath() const { 83 base::FilePath SandboxFileSystemTestHelper::GetUsageCachePath() const {
84 return file_system_context_-> 84 return file_system_context_->
85 sandbox_backend()->GetUsageCachePathForOriginAndType(origin_, type_); 85 sandbox_context()->GetUsageCachePathForOriginAndType(origin_, type_);
86 } 86 }
87 87
88 FileSystemURL SandboxFileSystemTestHelper::CreateURL( 88 FileSystemURL SandboxFileSystemTestHelper::CreateURL(
89 const base::FilePath& path) const { 89 const base::FilePath& path) const {
90 return file_system_context_->CreateCrackedFileSystemURL(origin_, type_, path); 90 return file_system_context_->CreateCrackedFileSystemURL(origin_, type_, path);
91 } 91 }
92 92
93 int64 SandboxFileSystemTestHelper::GetCachedOriginUsage() const { 93 int64 SandboxFileSystemTestHelper::GetCachedOriginUsage() const {
94 return file_system_context_->GetQuotaUtil(type_) 94 return file_system_context_->GetQuotaUtil(type_)
95 ->GetOriginUsageOnFileThread(file_system_context_.get(), origin_, type_); 95 ->GetOriginUsageOnFileThread(file_system_context_.get(), origin_, type_);
(...skipping 27 matching lines...) Expand all
123 return context; 123 return context;
124 } 124 }
125 125
126 void SandboxFileSystemTestHelper::AddFileChangeObserver( 126 void SandboxFileSystemTestHelper::AddFileChangeObserver(
127 FileChangeObserver* observer) { 127 FileChangeObserver* observer) {
128 file_system_context_->sandbox_backend()-> 128 file_system_context_->sandbox_backend()->
129 AddFileChangeObserver(type_, observer, NULL); 129 AddFileChangeObserver(type_, observer, NULL);
130 } 130 }
131 131
132 FileSystemUsageCache* SandboxFileSystemTestHelper::usage_cache() { 132 FileSystemUsageCache* SandboxFileSystemTestHelper::usage_cache() {
133 return file_system_context()->sandbox_backend()-> 133 return file_system_context()->sandbox_context()->usage_cache();
134 sandbox_context_->usage_cache();
135 } 134 }
136 135
137 void SandboxFileSystemTestHelper::SetUpFileSystem() { 136 void SandboxFileSystemTestHelper::SetUpFileSystem() {
138 DCHECK(file_system_context_.get()); 137 DCHECK(file_system_context_.get());
139 DCHECK(file_system_context_->sandbox_backend()->CanHandleType(type_)); 138 DCHECK(file_system_context_->sandbox_backend()->CanHandleType(type_));
140 139
141 file_util_ = file_system_context_->GetFileUtil(type_); 140 file_util_ = file_system_context_->GetFileUtil(type_);
142 DCHECK(file_util_); 141 DCHECK(file_util_);
143 142
144 // Prepare the origin's root directory. 143 // Prepare the origin's root directory.
145 file_system_context_->sandbox_backend()-> 144 file_system_context_->sandbox_context()->
146 GetBaseDirectoryForOriginAndType(origin_, type_, true /* create */); 145 GetBaseDirectoryForOriginAndType(origin_, type_, true /* create */);
147 146
148 // Initialize the usage cache file. 147 // Initialize the usage cache file.
149 base::FilePath usage_cache_path = GetUsageCachePath(); 148 base::FilePath usage_cache_path = GetUsageCachePath();
150 if (!usage_cache_path.empty()) 149 if (!usage_cache_path.empty())
151 usage_cache()->UpdateUsage(usage_cache_path, 0); 150 usage_cache()->UpdateUsage(usage_cache_path, 0);
152 } 151 }
153 152
154 } // namespace fileapi 153 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698