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

Unified Diff: webkit/fileapi/syncable/canned_syncable_file_system.cc

Issue 11090019: Add LocalFileSyncContext class which wires up profile-owned service and FileSystemContext(s) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments #2 Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/fileapi/syncable/canned_syncable_file_system.h ('k') | webkit/fileapi/syncable/syncable_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/syncable/canned_syncable_file_system.cc
diff --git a/webkit/fileapi/syncable/canned_syncable_file_system.cc b/webkit/fileapi/syncable/canned_syncable_file_system.cc
index 50e4c51027ee3fe7e0ff37bf6438b5308c5568cc..049d0e9a95bc28b094f9aab3f5abf1038133e9f5 100644
--- a/webkit/fileapi/syncable/canned_syncable_file_system.cc
+++ b/webkit/fileapi/syncable/canned_syncable_file_system.cc
@@ -15,6 +15,7 @@
#include "webkit/fileapi/isolated_context.h"
#include "webkit/fileapi/local_file_system_operation.h"
#include "webkit/fileapi/mock_file_system_options.h"
+#include "webkit/fileapi/syncable/syncable_context.h"
#include "webkit/quota/mock_special_storage_policy.h"
#include "webkit/quota/quota_manager.h"
@@ -29,12 +30,15 @@ CannedSyncableFileSystem::CannedSyncableFileSystem(
test_helper_(origin, kFileSystemTypeSyncable),
result_(base::PLATFORM_FILE_OK),
sync_status_(SYNC_STATUS_OK),
+ is_filesystem_set_up_(false),
+ is_filesystem_opened_(false),
weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
}
CannedSyncableFileSystem::~CannedSyncableFileSystem() {}
void CannedSyncableFileSystem::SetUp() {
+ ASSERT_FALSE(is_filesystem_set_up_);
ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
scoped_refptr<quota::SpecialStoragePolicy> storage_policy =
@@ -55,6 +59,7 @@ void CannedSyncableFileSystem::SetUp() {
CreateAllowFileAccessOptions());
test_helper_.SetUp(file_system_context_.get(), NULL);
+ is_filesystem_set_up_ = true;
}
void CannedSyncableFileSystem::TearDown() {
@@ -63,10 +68,14 @@ void CannedSyncableFileSystem::TearDown() {
}
FileSystemURL CannedSyncableFileSystem::URL(const std::string& path) const {
+ EXPECT_TRUE(is_filesystem_set_up_);
+ EXPECT_TRUE(is_filesystem_opened_);
return FileSystemURL(GURL(root_url_.spec() + path));
}
PlatformFileError CannedSyncableFileSystem::OpenFileSystem() {
+ EXPECT_TRUE(is_filesystem_set_up_);
+ EXPECT_FALSE(is_filesystem_opened_);
file_system_context_->OpenSyncableFileSystem(
service_name_,
test_helper_.origin(), test_helper_.type(),
@@ -77,8 +86,22 @@ PlatformFileError CannedSyncableFileSystem::OpenFileSystem() {
return result_;
}
+SyncStatusCode CannedSyncableFileSystem::MaybeInitializeFileSystemContext(
+ SyncableContext* syncable_context) {
+ DCHECK(syncable_context);
+ sync_status_ = SYNC_FILE_ERROR_FAILED;
tzik 2012/10/12 07:02:20 can we use SYNC_STATUS_UNKNOWN instead?
kinuko 2012/10/12 07:17:30 Done.
+ syncable_context->MaybeInitializeFileSystemContext(
+ test_helper_.origin(),
+ file_system_context_,
+ base::Bind(&CannedSyncableFileSystem::DidInitializeFileSystemContext,
+ base::Unretained(this)));
+ MessageLoop::current()->Run();
+ return sync_status_;
+}
+
PlatformFileError CannedSyncableFileSystem::CreateDirectory(
const FileSystemURL& url) {
+ EXPECT_TRUE(is_filesystem_opened_);
result_ = base::PLATFORM_FILE_ERROR_FAILED;
test_helper_.NewOperation()->CreateDirectory(
url, false /* exclusive */, false /* recursive */,
@@ -90,6 +113,7 @@ PlatformFileError CannedSyncableFileSystem::CreateDirectory(
PlatformFileError CannedSyncableFileSystem::CreateFile(
const FileSystemURL& url) {
+ EXPECT_TRUE(is_filesystem_opened_);
result_ = base::PLATFORM_FILE_ERROR_FAILED;
test_helper_.NewOperation()->CreateFile(
url, false /* exclusive */,
@@ -101,6 +125,7 @@ PlatformFileError CannedSyncableFileSystem::CreateFile(
PlatformFileError CannedSyncableFileSystem::TruncateFile(
const FileSystemURL& url, int64 size) {
+ EXPECT_TRUE(is_filesystem_opened_);
result_ = base::PLATFORM_FILE_ERROR_FAILED;
test_helper_.NewOperation()->Truncate(
url, size,
@@ -112,6 +137,7 @@ PlatformFileError CannedSyncableFileSystem::TruncateFile(
PlatformFileError CannedSyncableFileSystem::Remove(
const FileSystemURL& url, bool recursive) {
+ EXPECT_TRUE(is_filesystem_opened_);
result_ = base::PLATFORM_FILE_ERROR_FAILED;
test_helper_.NewOperation()->Remove(
url, recursive,
@@ -122,6 +148,7 @@ PlatformFileError CannedSyncableFileSystem::Remove(
}
PlatformFileError CannedSyncableFileSystem::DeleteFileSystem() {
+ EXPECT_TRUE(is_filesystem_set_up_);
file_system_context_->DeleteFileSystem(
test_helper_.origin(), test_helper_.type(),
base::Bind(&CannedSyncableFileSystem::StatusCallback,
@@ -134,6 +161,13 @@ void CannedSyncableFileSystem::DidOpenFileSystem(
PlatformFileError result, const std::string& name, const GURL& root) {
result_ = result;
root_url_ = root;
+ is_filesystem_opened_ = true;
+}
+
+void CannedSyncableFileSystem::DidInitializeFileSystemContext(
+ SyncStatusCode status) {
+ sync_status_ = status;
+ MessageLoop::current()->Quit();
}
void CannedSyncableFileSystem::StatusCallback(PlatformFileError result) {
« no previous file with comments | « webkit/fileapi/syncable/canned_syncable_file_system.h ('k') | webkit/fileapi/syncable/syncable_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698