OLD | NEW |
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 "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" | 5 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/files/file.h" |
13 #include "base/guid.h" | 14 #include "base/guid.h" |
14 #include "base/message_loop/message_loop_proxy.h" | 15 #include "base/message_loop/message_loop_proxy.h" |
15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
17 #include "base/task_runner_util.h" | 18 #include "base/task_runner_util.h" |
18 #include "chrome/browser/sync_file_system/file_change.h" | 19 #include "chrome/browser/sync_file_system/file_change.h" |
19 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 20 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
20 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 21 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
21 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 22 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
22 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 23 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
23 #include "content/public/test/test_file_system_options.h" | 24 #include "content/public/test/test_file_system_options.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "webkit/browser/blob/mock_blob_url_request_context.h" | 26 #include "webkit/browser/blob/mock_blob_url_request_context.h" |
26 #include "webkit/browser/fileapi/external_mount_points.h" | 27 #include "webkit/browser/fileapi/external_mount_points.h" |
27 #include "webkit/browser/fileapi/file_system_backend.h" | 28 #include "webkit/browser/fileapi/file_system_backend.h" |
28 #include "webkit/browser/fileapi/file_system_context.h" | 29 #include "webkit/browser/fileapi/file_system_context.h" |
29 #include "webkit/browser/fileapi/file_system_operation_context.h" | 30 #include "webkit/browser/fileapi/file_system_operation_context.h" |
30 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 31 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
31 #include "webkit/browser/quota/mock_special_storage_policy.h" | 32 #include "webkit/browser/quota/mock_special_storage_policy.h" |
32 #include "webkit/browser/quota/quota_manager.h" | 33 #include "webkit/browser/quota/quota_manager.h" |
33 #include "webkit/common/blob/shareable_file_reference.h" | 34 #include "webkit/common/blob/shareable_file_reference.h" |
34 | 35 |
35 using base::PlatformFileError; | 36 using base::File; |
36 using fileapi::FileSystemContext; | 37 using fileapi::FileSystemContext; |
37 using fileapi::FileSystemOperationRunner; | 38 using fileapi::FileSystemOperationRunner; |
38 using fileapi::FileSystemURL; | 39 using fileapi::FileSystemURL; |
39 using fileapi::FileSystemURLSet; | 40 using fileapi::FileSystemURLSet; |
40 using quota::QuotaManager; | 41 using quota::QuotaManager; |
41 using webkit_blob::MockBlobURLRequestContext; | 42 using webkit_blob::MockBlobURLRequestContext; |
42 using webkit_blob::ScopedTextBlob; | 43 using webkit_blob::ScopedTextBlob; |
43 | 44 |
44 namespace sync_file_system { | 45 namespace sync_file_system { |
45 | 46 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 base::SingleThreadTaskRunner* runner2) { | 92 base::SingleThreadTaskRunner* runner2) { |
92 ASSERT_TRUE(runner1 != NULL); | 93 ASSERT_TRUE(runner1 != NULL); |
93 ASSERT_TRUE(runner2 != NULL); | 94 ASSERT_TRUE(runner2 != NULL); |
94 runner1->PostTask(FROM_HERE, | 95 runner1->PostTask(FROM_HERE, |
95 base::Bind(&EnsureRunningOn, make_scoped_refptr(runner2))); | 96 base::Bind(&EnsureRunningOn, make_scoped_refptr(runner2))); |
96 } | 97 } |
97 | 98 |
98 void OnCreateSnapshotFileAndVerifyData( | 99 void OnCreateSnapshotFileAndVerifyData( |
99 const std::string& expected_data, | 100 const std::string& expected_data, |
100 const CannedSyncableFileSystem::StatusCallback& callback, | 101 const CannedSyncableFileSystem::StatusCallback& callback, |
101 base::PlatformFileError result, | 102 base::File::Error result, |
102 const base::PlatformFileInfo& file_info, | 103 const base::File::Info& file_info, |
103 const base::FilePath& platform_path, | 104 const base::FilePath& platform_path, |
104 const scoped_refptr<webkit_blob::ShareableFileReference>& /* file_ref */) { | 105 const scoped_refptr<webkit_blob::ShareableFileReference>& /* file_ref */) { |
105 if (result != base::PLATFORM_FILE_OK) { | 106 if (result != base::File::FILE_OK) { |
106 callback.Run(result); | 107 callback.Run(result); |
107 return; | 108 return; |
108 } | 109 } |
109 EXPECT_EQ(expected_data.size(), static_cast<size_t>(file_info.size)); | 110 EXPECT_EQ(expected_data.size(), static_cast<size_t>(file_info.size)); |
110 std::string data; | 111 std::string data; |
111 const bool read_status = base::ReadFileToString(platform_path, &data); | 112 const bool read_status = base::ReadFileToString(platform_path, &data); |
112 EXPECT_TRUE(read_status); | 113 EXPECT_TRUE(read_status); |
113 EXPECT_EQ(expected_data, data); | 114 EXPECT_EQ(expected_data, data); |
114 callback.Run(result); | 115 callback.Run(result); |
115 } | 116 } |
116 | 117 |
117 void OnCreateSnapshotFile( | 118 void OnCreateSnapshotFile( |
118 base::PlatformFileInfo* file_info_out, | 119 base::File::Info* file_info_out, |
119 base::FilePath* platform_path_out, | 120 base::FilePath* platform_path_out, |
120 const CannedSyncableFileSystem::StatusCallback& callback, | 121 const CannedSyncableFileSystem::StatusCallback& callback, |
121 base::PlatformFileError result, | 122 base::File::Error result, |
122 const base::PlatformFileInfo& file_info, | 123 const base::File::Info& file_info, |
123 const base::FilePath& platform_path, | 124 const base::FilePath& platform_path, |
124 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { | 125 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref) { |
125 DCHECK(!file_ref.get()); | 126 DCHECK(!file_ref.get()); |
126 DCHECK(file_info_out); | 127 DCHECK(file_info_out); |
127 DCHECK(platform_path_out); | 128 DCHECK(platform_path_out); |
128 *file_info_out = file_info; | 129 *file_info_out = file_info; |
129 *platform_path_out = platform_path; | 130 *platform_path_out = platform_path; |
130 callback.Run(result); | 131 callback.Run(result); |
131 } | 132 } |
132 | 133 |
133 void OnReadDirectory( | 134 void OnReadDirectory( |
134 CannedSyncableFileSystem::FileEntryList* entries_out, | 135 CannedSyncableFileSystem::FileEntryList* entries_out, |
135 const CannedSyncableFileSystem::StatusCallback& callback, | 136 const CannedSyncableFileSystem::StatusCallback& callback, |
136 base::PlatformFileError error, | 137 base::File::Error error, |
137 const fileapi::FileSystemOperation::FileEntryList& entries, | 138 const fileapi::FileSystemOperation::FileEntryList& entries, |
138 bool has_more) { | 139 bool has_more) { |
139 DCHECK(entries_out); | 140 DCHECK(entries_out); |
140 entries_out->reserve(entries_out->size() + entries.size()); | 141 entries_out->reserve(entries_out->size() + entries.size()); |
141 std::copy(entries.begin(), entries.end(), std::back_inserter(*entries_out)); | 142 std::copy(entries.begin(), entries.end(), std::back_inserter(*entries_out)); |
142 | 143 |
143 if (!has_more) | 144 if (!has_more) |
144 callback.Run(error); | 145 callback.Run(error); |
145 } | 146 } |
146 | 147 |
(...skipping 12 matching lines...) Expand all Loading... |
159 ~WriteHelper() { | 160 ~WriteHelper() { |
160 if (request_context_) { | 161 if (request_context_) { |
161 base::MessageLoop::current()->DeleteSoon(FROM_HERE, | 162 base::MessageLoop::current()->DeleteSoon(FROM_HERE, |
162 request_context_.release()); | 163 request_context_.release()); |
163 } | 164 } |
164 } | 165 } |
165 | 166 |
166 ScopedTextBlob* scoped_text_blob() const { return blob_data_.get(); } | 167 ScopedTextBlob* scoped_text_blob() const { return blob_data_.get(); } |
167 | 168 |
168 void DidWrite(const base::Callback<void(int64 result)>& completion_callback, | 169 void DidWrite(const base::Callback<void(int64 result)>& completion_callback, |
169 PlatformFileError error, int64 bytes, bool complete) { | 170 File::Error error, int64 bytes, bool complete) { |
170 if (error == base::PLATFORM_FILE_OK) { | 171 if (error == base::File::FILE_OK) { |
171 bytes_written_ += bytes; | 172 bytes_written_ += bytes; |
172 if (!complete) | 173 if (!complete) |
173 return; | 174 return; |
174 } | 175 } |
175 completion_callback.Run(error == base::PLATFORM_FILE_OK | 176 completion_callback.Run(error == base::File::FILE_OK ? |
176 ? bytes_written_ : static_cast<int64>(error)); | 177 bytes_written_ : static_cast<int64>(error)); |
177 } | 178 } |
178 | 179 |
179 private: | 180 private: |
180 int64 bytes_written_; | 181 int64 bytes_written_; |
181 scoped_ptr<MockBlobURLRequestContext> request_context_; | 182 scoped_ptr<MockBlobURLRequestContext> request_context_; |
182 scoped_ptr<ScopedTextBlob> blob_data_; | 183 scoped_ptr<ScopedTextBlob> blob_data_; |
183 | 184 |
184 DISALLOW_COPY_AND_ASSIGN(WriteHelper); | 185 DISALLOW_COPY_AND_ASSIGN(WriteHelper); |
185 }; | 186 }; |
186 | 187 |
(...skipping 14 matching lines...) Expand all Loading... |
201 } | 202 } |
202 | 203 |
203 } // namespace | 204 } // namespace |
204 | 205 |
205 CannedSyncableFileSystem::CannedSyncableFileSystem( | 206 CannedSyncableFileSystem::CannedSyncableFileSystem( |
206 const GURL& origin, | 207 const GURL& origin, |
207 base::SingleThreadTaskRunner* io_task_runner, | 208 base::SingleThreadTaskRunner* io_task_runner, |
208 base::SingleThreadTaskRunner* file_task_runner) | 209 base::SingleThreadTaskRunner* file_task_runner) |
209 : origin_(origin), | 210 : origin_(origin), |
210 type_(fileapi::kFileSystemTypeSyncable), | 211 type_(fileapi::kFileSystemTypeSyncable), |
211 result_(base::PLATFORM_FILE_OK), | 212 result_(base::File::FILE_OK), |
212 sync_status_(sync_file_system::SYNC_STATUS_OK), | 213 sync_status_(sync_file_system::SYNC_STATUS_OK), |
213 io_task_runner_(io_task_runner), | 214 io_task_runner_(io_task_runner), |
214 file_task_runner_(file_task_runner), | 215 file_task_runner_(file_task_runner), |
215 is_filesystem_set_up_(false), | 216 is_filesystem_set_up_(false), |
216 is_filesystem_opened_(false), | 217 is_filesystem_opened_(false), |
217 sync_status_observers_(new ObserverList) { | 218 sync_status_observers_(new ObserverList) { |
218 } | 219 } |
219 | 220 |
220 CannedSyncableFileSystem::~CannedSyncableFileSystem() {} | 221 CannedSyncableFileSystem::~CannedSyncableFileSystem() {} |
221 | 222 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 264 } |
264 | 265 |
265 FileSystemURL CannedSyncableFileSystem::URL(const std::string& path) const { | 266 FileSystemURL CannedSyncableFileSystem::URL(const std::string& path) const { |
266 EXPECT_TRUE(is_filesystem_set_up_); | 267 EXPECT_TRUE(is_filesystem_set_up_); |
267 EXPECT_FALSE(root_url_.is_empty()); | 268 EXPECT_FALSE(root_url_.is_empty()); |
268 | 269 |
269 GURL url(root_url_.spec() + path); | 270 GURL url(root_url_.spec() + path); |
270 return file_system_context_->CrackURL(url); | 271 return file_system_context_->CrackURL(url); |
271 } | 272 } |
272 | 273 |
273 PlatformFileError CannedSyncableFileSystem::OpenFileSystem() { | 274 File::Error CannedSyncableFileSystem::OpenFileSystem() { |
274 EXPECT_TRUE(is_filesystem_set_up_); | 275 EXPECT_TRUE(is_filesystem_set_up_); |
275 | 276 |
276 io_task_runner_->PostTask( | 277 io_task_runner_->PostTask( |
277 FROM_HERE, | 278 FROM_HERE, |
278 base::Bind(&CannedSyncableFileSystem::DoOpenFileSystem, | 279 base::Bind(&CannedSyncableFileSystem::DoOpenFileSystem, |
279 base::Unretained(this), | 280 base::Unretained(this), |
280 base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, | 281 base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, |
281 base::Unretained(this), | 282 base::Unretained(this), |
282 base::MessageLoopProxy::current()))); | 283 base::MessageLoopProxy::current()))); |
283 base::MessageLoop::current()->Run(); | 284 base::MessageLoop::current()->Run(); |
(...skipping 27 matching lines...) Expand all Loading... |
311 sync_context->io_task_runner_.get()); | 312 sync_context->io_task_runner_.get()); |
312 sync_context->MaybeInitializeFileSystemContext( | 313 sync_context->MaybeInitializeFileSystemContext( |
313 origin_, | 314 origin_, |
314 file_system_context_.get(), | 315 file_system_context_.get(), |
315 base::Bind(&CannedSyncableFileSystem::DidInitializeFileSystemContext, | 316 base::Bind(&CannedSyncableFileSystem::DidInitializeFileSystemContext, |
316 base::Unretained(this))); | 317 base::Unretained(this))); |
317 base::MessageLoop::current()->Run(); | 318 base::MessageLoop::current()->Run(); |
318 return sync_status_; | 319 return sync_status_; |
319 } | 320 } |
320 | 321 |
321 PlatformFileError CannedSyncableFileSystem::CreateDirectory( | 322 File::Error CannedSyncableFileSystem::CreateDirectory( |
322 const FileSystemURL& url) { | 323 const FileSystemURL& url) { |
323 return RunOnThread<PlatformFileError>( | 324 return RunOnThread<File::Error>( |
324 io_task_runner_.get(), | 325 io_task_runner_.get(), |
325 FROM_HERE, | 326 FROM_HERE, |
326 base::Bind(&CannedSyncableFileSystem::DoCreateDirectory, | 327 base::Bind(&CannedSyncableFileSystem::DoCreateDirectory, |
327 base::Unretained(this), | 328 base::Unretained(this), |
328 url)); | 329 url)); |
329 } | 330 } |
330 | 331 |
331 PlatformFileError CannedSyncableFileSystem::CreateFile( | 332 File::Error CannedSyncableFileSystem::CreateFile(const FileSystemURL& url) { |
332 const FileSystemURL& url) { | 333 return RunOnThread<File::Error>( |
333 return RunOnThread<PlatformFileError>( | |
334 io_task_runner_.get(), | 334 io_task_runner_.get(), |
335 FROM_HERE, | 335 FROM_HERE, |
336 base::Bind(&CannedSyncableFileSystem::DoCreateFile, | 336 base::Bind(&CannedSyncableFileSystem::DoCreateFile, |
337 base::Unretained(this), | 337 base::Unretained(this), |
338 url)); | 338 url)); |
339 } | 339 } |
340 | 340 |
341 PlatformFileError CannedSyncableFileSystem::Copy( | 341 File::Error CannedSyncableFileSystem::Copy( |
342 const FileSystemURL& src_url, const FileSystemURL& dest_url) { | 342 const FileSystemURL& src_url, const FileSystemURL& dest_url) { |
343 return RunOnThread<PlatformFileError>( | 343 return RunOnThread<File::Error>( |
344 io_task_runner_.get(), | 344 io_task_runner_.get(), |
345 FROM_HERE, | 345 FROM_HERE, |
346 base::Bind(&CannedSyncableFileSystem::DoCopy, | 346 base::Bind(&CannedSyncableFileSystem::DoCopy, |
347 base::Unretained(this), | 347 base::Unretained(this), |
348 src_url, | 348 src_url, |
349 dest_url)); | 349 dest_url)); |
350 } | 350 } |
351 | 351 |
352 PlatformFileError CannedSyncableFileSystem::Move( | 352 File::Error CannedSyncableFileSystem::Move( |
353 const FileSystemURL& src_url, const FileSystemURL& dest_url) { | 353 const FileSystemURL& src_url, const FileSystemURL& dest_url) { |
354 return RunOnThread<PlatformFileError>( | 354 return RunOnThread<File::Error>( |
355 io_task_runner_.get(), | 355 io_task_runner_.get(), |
356 FROM_HERE, | 356 FROM_HERE, |
357 base::Bind(&CannedSyncableFileSystem::DoMove, | 357 base::Bind(&CannedSyncableFileSystem::DoMove, |
358 base::Unretained(this), | 358 base::Unretained(this), |
359 src_url, | 359 src_url, |
360 dest_url)); | 360 dest_url)); |
361 } | 361 } |
362 | 362 |
363 PlatformFileError CannedSyncableFileSystem::TruncateFile( | 363 File::Error CannedSyncableFileSystem::TruncateFile( |
364 const FileSystemURL& url, int64 size) { | 364 const FileSystemURL& url, int64 size) { |
365 return RunOnThread<PlatformFileError>( | 365 return RunOnThread<File::Error>( |
366 io_task_runner_.get(), | 366 io_task_runner_.get(), |
367 FROM_HERE, | 367 FROM_HERE, |
368 base::Bind(&CannedSyncableFileSystem::DoTruncateFile, | 368 base::Bind(&CannedSyncableFileSystem::DoTruncateFile, |
369 base::Unretained(this), | 369 base::Unretained(this), |
370 url, | 370 url, |
371 size)); | 371 size)); |
372 } | 372 } |
373 | 373 |
374 PlatformFileError CannedSyncableFileSystem::TouchFile( | 374 File::Error CannedSyncableFileSystem::TouchFile( |
375 const FileSystemURL& url, | 375 const FileSystemURL& url, |
376 const base::Time& last_access_time, | 376 const base::Time& last_access_time, |
377 const base::Time& last_modified_time) { | 377 const base::Time& last_modified_time) { |
378 return RunOnThread<PlatformFileError>( | 378 return RunOnThread<File::Error>( |
379 io_task_runner_.get(), | 379 io_task_runner_.get(), |
380 FROM_HERE, | 380 FROM_HERE, |
381 base::Bind(&CannedSyncableFileSystem::DoTouchFile, | 381 base::Bind(&CannedSyncableFileSystem::DoTouchFile, |
382 base::Unretained(this), | 382 base::Unretained(this), |
383 url, | 383 url, |
384 last_access_time, | 384 last_access_time, |
385 last_modified_time)); | 385 last_modified_time)); |
386 } | 386 } |
387 | 387 |
388 PlatformFileError CannedSyncableFileSystem::Remove( | 388 File::Error CannedSyncableFileSystem::Remove( |
389 const FileSystemURL& url, bool recursive) { | 389 const FileSystemURL& url, bool recursive) { |
390 return RunOnThread<PlatformFileError>( | 390 return RunOnThread<File::Error>( |
391 io_task_runner_.get(), | 391 io_task_runner_.get(), |
392 FROM_HERE, | 392 FROM_HERE, |
393 base::Bind(&CannedSyncableFileSystem::DoRemove, | 393 base::Bind(&CannedSyncableFileSystem::DoRemove, |
394 base::Unretained(this), | 394 base::Unretained(this), |
395 url, | 395 url, |
396 recursive)); | 396 recursive)); |
397 } | 397 } |
398 | 398 |
399 PlatformFileError CannedSyncableFileSystem::FileExists( | 399 File::Error CannedSyncableFileSystem::FileExists( |
400 const FileSystemURL& url) { | 400 const FileSystemURL& url) { |
401 return RunOnThread<PlatformFileError>( | 401 return RunOnThread<File::Error>( |
402 io_task_runner_.get(), | 402 io_task_runner_.get(), |
403 FROM_HERE, | 403 FROM_HERE, |
404 base::Bind(&CannedSyncableFileSystem::DoFileExists, | 404 base::Bind(&CannedSyncableFileSystem::DoFileExists, |
405 base::Unretained(this), | 405 base::Unretained(this), |
406 url)); | 406 url)); |
407 } | 407 } |
408 | 408 |
409 PlatformFileError CannedSyncableFileSystem::DirectoryExists( | 409 File::Error CannedSyncableFileSystem::DirectoryExists( |
410 const FileSystemURL& url) { | 410 const FileSystemURL& url) { |
411 return RunOnThread<PlatformFileError>( | 411 return RunOnThread<File::Error>( |
412 io_task_runner_.get(), | 412 io_task_runner_.get(), |
413 FROM_HERE, | 413 FROM_HERE, |
414 base::Bind(&CannedSyncableFileSystem::DoDirectoryExists, | 414 base::Bind(&CannedSyncableFileSystem::DoDirectoryExists, |
415 base::Unretained(this), | 415 base::Unretained(this), |
416 url)); | 416 url)); |
417 } | 417 } |
418 | 418 |
419 PlatformFileError CannedSyncableFileSystem::VerifyFile( | 419 File::Error CannedSyncableFileSystem::VerifyFile( |
420 const FileSystemURL& url, | 420 const FileSystemURL& url, |
421 const std::string& expected_data) { | 421 const std::string& expected_data) { |
422 return RunOnThread<PlatformFileError>( | 422 return RunOnThread<File::Error>( |
423 io_task_runner_.get(), | 423 io_task_runner_.get(), |
424 FROM_HERE, | 424 FROM_HERE, |
425 base::Bind(&CannedSyncableFileSystem::DoVerifyFile, | 425 base::Bind(&CannedSyncableFileSystem::DoVerifyFile, |
426 base::Unretained(this), | 426 base::Unretained(this), |
427 url, | 427 url, |
428 expected_data)); | 428 expected_data)); |
429 } | 429 } |
430 | 430 |
431 PlatformFileError CannedSyncableFileSystem::GetMetadataAndPlatformPath( | 431 File::Error CannedSyncableFileSystem::GetMetadataAndPlatformPath( |
432 const FileSystemURL& url, | 432 const FileSystemURL& url, |
433 base::PlatformFileInfo* info, | 433 base::File::Info* info, |
434 base::FilePath* platform_path) { | 434 base::FilePath* platform_path) { |
435 return RunOnThread<PlatformFileError>( | 435 return RunOnThread<File::Error>( |
436 io_task_runner_.get(), | 436 io_task_runner_.get(), |
437 FROM_HERE, | 437 FROM_HERE, |
438 base::Bind(&CannedSyncableFileSystem::DoGetMetadataAndPlatformPath, | 438 base::Bind(&CannedSyncableFileSystem::DoGetMetadataAndPlatformPath, |
439 base::Unretained(this), | 439 base::Unretained(this), |
440 url, | 440 url, |
441 info, | 441 info, |
442 platform_path)); | 442 platform_path)); |
443 } | 443 } |
444 | 444 |
445 PlatformFileError CannedSyncableFileSystem::ReadDirectory( | 445 File::Error CannedSyncableFileSystem::ReadDirectory( |
446 const fileapi::FileSystemURL& url, | 446 const fileapi::FileSystemURL& url, |
447 FileEntryList* entries) { | 447 FileEntryList* entries) { |
448 return RunOnThread<PlatformFileError>( | 448 return RunOnThread<File::Error>( |
449 io_task_runner_.get(), | 449 io_task_runner_.get(), |
450 FROM_HERE, | 450 FROM_HERE, |
451 base::Bind(&CannedSyncableFileSystem::DoReadDirectory, | 451 base::Bind(&CannedSyncableFileSystem::DoReadDirectory, |
452 base::Unretained(this), | 452 base::Unretained(this), |
453 url, | 453 url, |
454 entries)); | 454 entries)); |
455 } | 455 } |
456 | 456 |
457 int64 CannedSyncableFileSystem::Write( | 457 int64 CannedSyncableFileSystem::Write( |
458 net::URLRequestContext* url_request_context, | 458 net::URLRequestContext* url_request_context, |
(...skipping 11 matching lines...) Expand all Loading... |
470 int64 CannedSyncableFileSystem::WriteString( | 470 int64 CannedSyncableFileSystem::WriteString( |
471 const FileSystemURL& url, const std::string& data) { | 471 const FileSystemURL& url, const std::string& data) { |
472 return RunOnThread<int64>(io_task_runner_.get(), | 472 return RunOnThread<int64>(io_task_runner_.get(), |
473 FROM_HERE, | 473 FROM_HERE, |
474 base::Bind(&CannedSyncableFileSystem::DoWriteString, | 474 base::Bind(&CannedSyncableFileSystem::DoWriteString, |
475 base::Unretained(this), | 475 base::Unretained(this), |
476 url, | 476 url, |
477 data)); | 477 data)); |
478 } | 478 } |
479 | 479 |
480 PlatformFileError CannedSyncableFileSystem::DeleteFileSystem() { | 480 File::Error CannedSyncableFileSystem::DeleteFileSystem() { |
481 EXPECT_TRUE(is_filesystem_set_up_); | 481 EXPECT_TRUE(is_filesystem_set_up_); |
482 return RunOnThread<PlatformFileError>( | 482 return RunOnThread<File::Error>( |
483 io_task_runner_.get(), | 483 io_task_runner_.get(), |
484 FROM_HERE, | 484 FROM_HERE, |
485 base::Bind(&FileSystemContext::DeleteFileSystem, | 485 base::Bind(&FileSystemContext::DeleteFileSystem, |
486 file_system_context_, | 486 file_system_context_, |
487 origin_, | 487 origin_, |
488 type_)); | 488 type_)); |
489 } | 489 } |
490 | 490 |
491 quota::QuotaStatusCode CannedSyncableFileSystem::GetUsageAndQuota( | 491 quota::QuotaStatusCode CannedSyncableFileSystem::GetUsageAndQuota( |
492 int64* usage, int64* quota) { | 492 int64* usage, int64* quota) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 const StatusCallback& callback) { | 644 const StatusCallback& callback) { |
645 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 645 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
646 EXPECT_TRUE(is_filesystem_opened_); | 646 EXPECT_TRUE(is_filesystem_opened_); |
647 operation_runner()->CreateSnapshotFile( | 647 operation_runner()->CreateSnapshotFile( |
648 url, | 648 url, |
649 base::Bind(&OnCreateSnapshotFileAndVerifyData, expected_data, callback)); | 649 base::Bind(&OnCreateSnapshotFileAndVerifyData, expected_data, callback)); |
650 } | 650 } |
651 | 651 |
652 void CannedSyncableFileSystem::DoGetMetadataAndPlatformPath( | 652 void CannedSyncableFileSystem::DoGetMetadataAndPlatformPath( |
653 const FileSystemURL& url, | 653 const FileSystemURL& url, |
654 base::PlatformFileInfo* info, | 654 base::File::Info* info, |
655 base::FilePath* platform_path, | 655 base::FilePath* platform_path, |
656 const StatusCallback& callback) { | 656 const StatusCallback& callback) { |
657 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 657 EXPECT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
658 EXPECT_TRUE(is_filesystem_opened_); | 658 EXPECT_TRUE(is_filesystem_opened_); |
659 operation_runner()->CreateSnapshotFile( | 659 operation_runner()->CreateSnapshotFile( |
660 url, base::Bind(&OnCreateSnapshotFile, info, platform_path, callback)); | 660 url, base::Bind(&OnCreateSnapshotFile, info, platform_path, callback)); |
661 } | 661 } |
662 | 662 |
663 void CannedSyncableFileSystem::DoReadDirectory( | 663 void CannedSyncableFileSystem::DoReadDirectory( |
664 const FileSystemURL& url, | 664 const FileSystemURL& url, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 EXPECT_TRUE(is_filesystem_opened_); | 707 EXPECT_TRUE(is_filesystem_opened_); |
708 quota_manager_->GetUsageAndQuota( | 708 quota_manager_->GetUsageAndQuota( |
709 origin_, storage_type(), | 709 origin_, storage_type(), |
710 base::Bind(&DidGetUsageAndQuota, callback, usage, quota)); | 710 base::Bind(&DidGetUsageAndQuota, callback, usage, quota)); |
711 } | 711 } |
712 | 712 |
713 void CannedSyncableFileSystem::DidOpenFileSystem( | 713 void CannedSyncableFileSystem::DidOpenFileSystem( |
714 base::SingleThreadTaskRunner* original_task_runner, | 714 base::SingleThreadTaskRunner* original_task_runner, |
715 const GURL& root, | 715 const GURL& root, |
716 const std::string& name, | 716 const std::string& name, |
717 PlatformFileError result) { | 717 File::Error result) { |
718 if (io_task_runner_->RunsTasksOnCurrentThread()) { | 718 if (io_task_runner_->RunsTasksOnCurrentThread()) { |
719 EXPECT_FALSE(is_filesystem_opened_); | 719 EXPECT_FALSE(is_filesystem_opened_); |
720 is_filesystem_opened_ = true; | 720 is_filesystem_opened_ = true; |
721 } | 721 } |
722 if (!original_task_runner->RunsTasksOnCurrentThread()) { | 722 if (!original_task_runner->RunsTasksOnCurrentThread()) { |
723 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 723 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
724 original_task_runner->PostTask( | 724 original_task_runner->PostTask( |
725 FROM_HERE, | 725 FROM_HERE, |
726 base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, | 726 base::Bind(&CannedSyncableFileSystem::DidOpenFileSystem, |
727 base::Unretained(this), | 727 base::Unretained(this), |
(...skipping 11 matching lines...) Expand all Loading... |
739 sync_status_ = status; | 739 sync_status_ = status; |
740 base::MessageLoop::current()->Quit(); | 740 base::MessageLoop::current()->Quit(); |
741 } | 741 } |
742 | 742 |
743 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { | 743 void CannedSyncableFileSystem::InitializeSyncStatusObserver() { |
744 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 744 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
745 backend()->sync_context()->sync_status()->AddObserver(this); | 745 backend()->sync_context()->sync_status()->AddObserver(this); |
746 } | 746 } |
747 | 747 |
748 } // namespace sync_file_system | 748 } // namespace sync_file_system |
OLD | NEW |