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

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

Issue 23167002: FileAPI: Rename SandboxContext to SandboxFileSystemBackendDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 SetUpFileSystem(); 55 SetUpFileSystem();
56 } 56 }
57 57
58 void SandboxFileSystemTestHelper::TearDown() { 58 void SandboxFileSystemTestHelper::TearDown() {
59 file_system_context_ = NULL; 59 file_system_context_ = NULL;
60 base::MessageLoop::current()->RunUntilIdle(); 60 base::MessageLoop::current()->RunUntilIdle();
61 } 61 }
62 62
63 base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() { 63 base::FilePath SandboxFileSystemTestHelper::GetOriginRootPath() {
64 return file_system_context_->sandbox_context()-> 64 return file_system_context_->sandbox_delegate()->
65 GetBaseDirectoryForOriginAndType(origin_, type_, false); 65 GetBaseDirectoryForOriginAndType(origin_, type_, false);
66 } 66 }
67 67
68 base::FilePath SandboxFileSystemTestHelper::GetLocalPath( 68 base::FilePath SandboxFileSystemTestHelper::GetLocalPath(
69 const base::FilePath& path) { 69 const base::FilePath& path) {
70 DCHECK(file_util_); 70 DCHECK(file_util_);
71 base::FilePath local_path; 71 base::FilePath local_path;
72 scoped_ptr<FileSystemOperationContext> context(NewOperationContext()); 72 scoped_ptr<FileSystemOperationContext> context(NewOperationContext());
73 file_util_->GetLocalFilePath(context.get(), CreateURL(path), &local_path); 73 file_util_->GetLocalFilePath(context.get(), CreateURL(path), &local_path);
74 return local_path; 74 return local_path;
75 } 75 }
76 76
77 base::FilePath SandboxFileSystemTestHelper::GetLocalPathFromASCII( 77 base::FilePath SandboxFileSystemTestHelper::GetLocalPathFromASCII(
78 const std::string& path) { 78 const std::string& path) {
79 return GetLocalPath(base::FilePath().AppendASCII(path)); 79 return GetLocalPath(base::FilePath().AppendASCII(path));
80 } 80 }
81 81
82 base::FilePath SandboxFileSystemTestHelper::GetUsageCachePath() const { 82 base::FilePath SandboxFileSystemTestHelper::GetUsageCachePath() const {
83 return file_system_context_-> 83 return file_system_context_->sandbox_delegate()->
84 sandbox_context()->GetUsageCachePathForOriginAndType(origin_, type_); 84 GetUsageCachePathForOriginAndType(origin_, type_);
85 } 85 }
86 86
87 FileSystemURL SandboxFileSystemTestHelper::CreateURL( 87 FileSystemURL SandboxFileSystemTestHelper::CreateURL(
88 const base::FilePath& path) const { 88 const base::FilePath& path) const {
89 return file_system_context_->CreateCrackedFileSystemURL(origin_, type_, path); 89 return file_system_context_->CreateCrackedFileSystemURL(origin_, type_, path);
90 } 90 }
91 91
92 int64 SandboxFileSystemTestHelper::GetCachedOriginUsage() const { 92 int64 SandboxFileSystemTestHelper::GetCachedOriginUsage() const {
93 return file_system_context_->GetQuotaUtil(type_) 93 return file_system_context_->GetQuotaUtil(type_)
94 ->GetOriginUsageOnFileThread(file_system_context_.get(), origin_, type_); 94 ->GetOriginUsageOnFileThread(file_system_context_.get(), origin_, type_);
(...skipping 27 matching lines...) Expand all
122 return context; 122 return context;
123 } 123 }
124 124
125 void SandboxFileSystemTestHelper::AddFileChangeObserver( 125 void SandboxFileSystemTestHelper::AddFileChangeObserver(
126 FileChangeObserver* observer) { 126 FileChangeObserver* observer) {
127 file_system_context_->sandbox_backend()-> 127 file_system_context_->sandbox_backend()->
128 AddFileChangeObserver(type_, observer, NULL); 128 AddFileChangeObserver(type_, observer, NULL);
129 } 129 }
130 130
131 FileSystemUsageCache* SandboxFileSystemTestHelper::usage_cache() { 131 FileSystemUsageCache* SandboxFileSystemTestHelper::usage_cache() {
132 return file_system_context()->sandbox_context()->usage_cache(); 132 return file_system_context()->sandbox_delegate()->usage_cache();
133 } 133 }
134 134
135 void SandboxFileSystemTestHelper::SetUpFileSystem() { 135 void SandboxFileSystemTestHelper::SetUpFileSystem() {
136 DCHECK(file_system_context_.get()); 136 DCHECK(file_system_context_.get());
137 DCHECK(file_system_context_->sandbox_backend()->CanHandleType(type_)); 137 DCHECK(file_system_context_->sandbox_backend()->CanHandleType(type_));
138 138
139 file_util_ = file_system_context_->GetFileUtil(type_); 139 file_util_ = file_system_context_->GetFileUtil(type_);
140 DCHECK(file_util_); 140 DCHECK(file_util_);
141 141
142 // Prepare the origin's root directory. 142 // Prepare the origin's root directory.
143 file_system_context_->sandbox_context()-> 143 file_system_context_->sandbox_delegate()->
144 GetBaseDirectoryForOriginAndType(origin_, type_, true /* create */); 144 GetBaseDirectoryForOriginAndType(origin_, type_, true /* create */);
145 145
146 // Initialize the usage cache file. 146 // Initialize the usage cache file.
147 base::FilePath usage_cache_path = GetUsageCachePath(); 147 base::FilePath usage_cache_path = GetUsageCachePath();
148 if (!usage_cache_path.empty()) 148 if (!usage_cache_path.empty())
149 usage_cache()->UpdateUsage(usage_cache_path, 0); 149 usage_cache()->UpdateUsage(usage_cache_path, 0);
150 } 150 }
151 151
152 } // namespace fileapi 152 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc ('k') | webkit/browser/fileapi/sandbox_quota_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698