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

Side by Side Diff: content/public/test/test_file_system_backend.cc

Issue 345673002: Fully qualify all references to fileapi::FileSystemType (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix FileSystemType instances I missed Created 6 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 | « content/public/test/sandbox_file_system_test_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/public/test/test_file_system_backend.h" 5 #include "content/public/test/test_file_system_backend.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/sequenced_task_runner.h" 12 #include "base/sequenced_task_runner.h"
13 #include "webkit/browser/blob/file_stream_reader.h" 13 #include "webkit/browser/blob/file_stream_reader.h"
14 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" 14 #include "webkit/browser/fileapi/copy_or_move_file_validator.h"
15 #include "webkit/browser/fileapi/file_observers.h" 15 #include "webkit/browser/fileapi/file_observers.h"
16 #include "webkit/browser/fileapi/file_system_operation.h" 16 #include "webkit/browser/fileapi/file_system_operation.h"
17 #include "webkit/browser/fileapi/file_system_operation_context.h" 17 #include "webkit/browser/fileapi/file_system_operation_context.h"
18 #include "webkit/browser/fileapi/file_system_quota_util.h" 18 #include "webkit/browser/fileapi/file_system_quota_util.h"
19 #include "webkit/browser/fileapi/local_file_util.h" 19 #include "webkit/browser/fileapi/local_file_util.h"
20 #include "webkit/browser/fileapi/native_file_util.h" 20 #include "webkit/browser/fileapi/native_file_util.h"
21 #include "webkit/browser/fileapi/quota/quota_reservation.h" 21 #include "webkit/browser/fileapi/quota/quota_reservation.h"
22 #include "webkit/browser/fileapi/sandbox_file_stream_writer.h" 22 #include "webkit/browser/fileapi/sandbox_file_stream_writer.h"
23 #include "webkit/browser/quota/quota_manager.h" 23 #include "webkit/browser/quota/quota_manager.h"
24 #include "webkit/common/fileapi/file_system_util.h" 24 #include "webkit/common/fileapi/file_system_util.h"
25 25
26 using fileapi::FileSystemContext; 26 using fileapi::FileSystemContext;
27 using fileapi::FileSystemOperation; 27 using fileapi::FileSystemOperation;
28 using fileapi::FileSystemOperationContext; 28 using fileapi::FileSystemOperationContext;
29 using fileapi::FileSystemType;
30 using fileapi::FileSystemURL; 29 using fileapi::FileSystemURL;
31 30
32 namespace content { 31 namespace content {
33 32
34 namespace { 33 namespace {
35 34
36 class TestFileUtil : public fileapi::LocalFileUtil { 35 class TestFileUtil : public fileapi::LocalFileUtil {
37 public: 36 public:
38 explicit TestFileUtil(const base::FilePath& base_path) 37 explicit TestFileUtil(const base::FilePath& base_path)
39 : base_path_(base_path) {} 38 : base_path_(base_path) {}
(...skipping 24 matching lines...) Expand all
64 task_runner_(task_runner) { 63 task_runner_(task_runner) {
65 update_observers_ = update_observers_.AddObserver(this, task_runner_.get()); 64 update_observers_ = update_observers_.AddObserver(this, task_runner_.get());
66 } 65 }
67 virtual ~QuotaUtil() {} 66 virtual ~QuotaUtil() {}
68 67
69 // FileSystemQuotaUtil overrides. 68 // FileSystemQuotaUtil overrides.
70 virtual base::File::Error DeleteOriginDataOnFileTaskRunner( 69 virtual base::File::Error DeleteOriginDataOnFileTaskRunner(
71 FileSystemContext* context, 70 FileSystemContext* context,
72 quota::QuotaManagerProxy* proxy, 71 quota::QuotaManagerProxy* proxy,
73 const GURL& origin_url, 72 const GURL& origin_url,
74 FileSystemType type) OVERRIDE { 73 fileapi::FileSystemType type) OVERRIDE {
75 NOTREACHED(); 74 NOTREACHED();
76 return base::File::FILE_OK; 75 return base::File::FILE_OK;
77 } 76 }
78 77
79 virtual scoped_refptr<fileapi::QuotaReservation> 78 virtual scoped_refptr<fileapi::QuotaReservation>
80 CreateQuotaReservationOnFileTaskRunner( 79 CreateQuotaReservationOnFileTaskRunner(
81 const GURL& origin_url, 80 const GURL& origin_url,
82 FileSystemType type) OVERRIDE { 81 fileapi::FileSystemType type) OVERRIDE {
83 NOTREACHED(); 82 NOTREACHED();
84 return scoped_refptr<fileapi::QuotaReservation>(); 83 return scoped_refptr<fileapi::QuotaReservation>();
85 } 84 }
86 85
87 virtual void GetOriginsForTypeOnFileTaskRunner( 86 virtual void GetOriginsForTypeOnFileTaskRunner(
88 FileSystemType type, 87 fileapi::FileSystemType type,
89 std::set<GURL>* origins) OVERRIDE { 88 std::set<GURL>* origins) OVERRIDE {
90 NOTREACHED(); 89 NOTREACHED();
91 } 90 }
92 91
93 virtual void GetOriginsForHostOnFileTaskRunner( 92 virtual void GetOriginsForHostOnFileTaskRunner(
94 FileSystemType type, 93 fileapi::FileSystemType type,
95 const std::string& host, 94 const std::string& host,
96 std::set<GURL>* origins) OVERRIDE { 95 std::set<GURL>* origins) OVERRIDE {
97 NOTREACHED(); 96 NOTREACHED();
98 } 97 }
99 98
100 virtual int64 GetOriginUsageOnFileTaskRunner( 99 virtual int64 GetOriginUsageOnFileTaskRunner(
101 FileSystemContext* context, 100 FileSystemContext* context,
102 const GURL& origin_url, 101 const GURL& origin_url,
103 FileSystemType type) OVERRIDE { 102 fileapi::FileSystemType type) OVERRIDE {
104 return usage_; 103 return usage_;
105 } 104 }
106 105
107 virtual void AddFileUpdateObserver( 106 virtual void AddFileUpdateObserver(
108 FileSystemType type, 107 fileapi::FileSystemType type,
109 FileUpdateObserver* observer, 108 FileUpdateObserver* observer,
110 base::SequencedTaskRunner* task_runner) OVERRIDE { 109 base::SequencedTaskRunner* task_runner) OVERRIDE {
111 NOTIMPLEMENTED(); 110 NOTIMPLEMENTED();
112 } 111 }
113 112
114 virtual void AddFileChangeObserver( 113 virtual void AddFileChangeObserver(
115 FileSystemType type, 114 fileapi::FileSystemType type,
116 fileapi::FileChangeObserver* observer, 115 fileapi::FileChangeObserver* observer,
117 base::SequencedTaskRunner* task_runner) OVERRIDE { 116 base::SequencedTaskRunner* task_runner) OVERRIDE {
118 change_observers_ = change_observers_.AddObserver(observer, task_runner); 117 change_observers_ = change_observers_.AddObserver(observer, task_runner);
119 } 118 }
120 119
121 virtual void AddFileAccessObserver( 120 virtual void AddFileAccessObserver(
122 FileSystemType type, 121 fileapi::FileSystemType type,
123 fileapi::FileAccessObserver* observer, 122 fileapi::FileAccessObserver* observer,
124 base::SequencedTaskRunner* task_runner) OVERRIDE { 123 base::SequencedTaskRunner* task_runner) OVERRIDE {
125 NOTIMPLEMENTED(); 124 NOTIMPLEMENTED();
126 } 125 }
127 126
128 virtual const fileapi::UpdateObserverList* GetUpdateObservers( 127 virtual const fileapi::UpdateObserverList* GetUpdateObservers(
129 FileSystemType type) const OVERRIDE { 128 fileapi::FileSystemType type) const OVERRIDE {
130 return &update_observers_; 129 return &update_observers_;
131 } 130 }
132 131
133 virtual const fileapi::ChangeObserverList* GetChangeObservers( 132 virtual const fileapi::ChangeObserverList* GetChangeObservers(
134 FileSystemType type) const OVERRIDE { 133 fileapi::FileSystemType type) const OVERRIDE {
135 return &change_observers_; 134 return &change_observers_;
136 } 135 }
137 136
138 virtual const fileapi::AccessObserverList* GetAccessObservers( 137 virtual const fileapi::AccessObserverList* GetAccessObservers(
139 FileSystemType type) const OVERRIDE { 138 fileapi::FileSystemType type) const OVERRIDE {
140 return NULL; 139 return NULL;
141 } 140 }
142 141
143 // FileUpdateObserver overrides. 142 // FileUpdateObserver overrides.
144 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE {} 143 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE {}
145 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE { 144 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE {
146 usage_ += delta; 145 usage_ += delta;
147 } 146 }
148 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE {} 147 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE {}
149 148
(...skipping 14 matching lines...) Expand all
164 : base_path_(base_path), 163 : base_path_(base_path),
165 file_util_( 164 file_util_(
166 new fileapi::AsyncFileUtilAdapter(new TestFileUtil(base_path))), 165 new fileapi::AsyncFileUtilAdapter(new TestFileUtil(base_path))),
167 quota_util_(new QuotaUtil(task_runner)), 166 quota_util_(new QuotaUtil(task_runner)),
168 require_copy_or_move_validator_(false) { 167 require_copy_or_move_validator_(false) {
169 } 168 }
170 169
171 TestFileSystemBackend::~TestFileSystemBackend() { 170 TestFileSystemBackend::~TestFileSystemBackend() {
172 } 171 }
173 172
174 bool TestFileSystemBackend::CanHandleType(FileSystemType type) const { 173 bool TestFileSystemBackend::CanHandleType(fileapi::FileSystemType type) const {
175 return (type == fileapi::kFileSystemTypeTest); 174 return (type == fileapi::kFileSystemTypeTest);
176 } 175 }
177 176
178 void TestFileSystemBackend::Initialize(FileSystemContext* context) { 177 void TestFileSystemBackend::Initialize(FileSystemContext* context) {
179 } 178 }
180 179
181 void TestFileSystemBackend::ResolveURL(const FileSystemURL& url, 180 void TestFileSystemBackend::ResolveURL(const FileSystemURL& url,
182 fileapi::OpenFileSystemMode mode, 181 fileapi::OpenFileSystemMode mode,
183 const OpenFileSystemCallback& callback) { 182 const OpenFileSystemCallback& callback) {
184 callback.Run(GetFileSystemRootURI(url.origin(), url.type()), 183 callback.Run(GetFileSystemRootURI(url.origin(), url.type()),
185 GetFileSystemName(url.origin(), url.type()), 184 GetFileSystemName(url.origin(), url.type()),
186 base::File::FILE_OK); 185 base::File::FILE_OK);
187 } 186 }
188 187
189 fileapi::AsyncFileUtil* TestFileSystemBackend::GetAsyncFileUtil( 188 fileapi::AsyncFileUtil* TestFileSystemBackend::GetAsyncFileUtil(
190 FileSystemType type) { 189 fileapi::FileSystemType type) {
191 return file_util_.get(); 190 return file_util_.get();
192 } 191 }
193 192
194 fileapi::CopyOrMoveFileValidatorFactory* 193 fileapi::CopyOrMoveFileValidatorFactory*
195 TestFileSystemBackend::GetCopyOrMoveFileValidatorFactory( 194 TestFileSystemBackend::GetCopyOrMoveFileValidatorFactory(
196 FileSystemType type, base::File::Error* error_code) { 195 fileapi::FileSystemType type,
196 base::File::Error* error_code) {
197 DCHECK(error_code); 197 DCHECK(error_code);
198 *error_code = base::File::FILE_OK; 198 *error_code = base::File::FILE_OK;
199 if (require_copy_or_move_validator_) { 199 if (require_copy_or_move_validator_) {
200 if (!copy_or_move_file_validator_factory_) 200 if (!copy_or_move_file_validator_factory_)
201 *error_code = base::File::FILE_ERROR_SECURITY; 201 *error_code = base::File::FILE_ERROR_SECURITY;
202 return copy_or_move_file_validator_factory_.get(); 202 return copy_or_move_file_validator_factory_.get();
203 } 203 }
204 return NULL; 204 return NULL;
205 } 205 }
206 206
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return scoped_ptr<fileapi::FileStreamWriter>( 246 return scoped_ptr<fileapi::FileStreamWriter>(
247 new fileapi::SandboxFileStreamWriter(context, url, offset, 247 new fileapi::SandboxFileStreamWriter(context, url, offset,
248 *GetUpdateObservers(url.type()))); 248 *GetUpdateObservers(url.type())));
249 } 249 }
250 250
251 fileapi::FileSystemQuotaUtil* TestFileSystemBackend::GetQuotaUtil() { 251 fileapi::FileSystemQuotaUtil* TestFileSystemBackend::GetQuotaUtil() {
252 return quota_util_.get(); 252 return quota_util_.get();
253 } 253 }
254 254
255 const fileapi::UpdateObserverList* TestFileSystemBackend::GetUpdateObservers( 255 const fileapi::UpdateObserverList* TestFileSystemBackend::GetUpdateObservers(
256 FileSystemType type) const { 256 fileapi::FileSystemType type) const {
257 return quota_util_->GetUpdateObservers(type); 257 return quota_util_->GetUpdateObservers(type);
258 } 258 }
259 259
260 void TestFileSystemBackend::AddFileChangeObserver( 260 void TestFileSystemBackend::AddFileChangeObserver(
261 fileapi::FileChangeObserver* observer) { 261 fileapi::FileChangeObserver* observer) {
262 quota_util_->AddFileChangeObserver( 262 quota_util_->AddFileChangeObserver(
263 fileapi::kFileSystemTypeTest, observer, quota_util_->task_runner()); 263 fileapi::kFileSystemTypeTest, observer, quota_util_->task_runner());
264 } 264 }
265 265
266 } // namespace content 266 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/sandbox_file_system_test_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698