summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync_file_system
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-19 01:49:10 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-09-19 01:49:10 +0000
commitc21aae4c5085110ff9115b2b7e094699016ff65e (patch)
tree762862aabcc071df4a9cbecf497b7118d35df8f9 /chrome/browser/sync_file_system
parentd67e32fe5bdb747f5a0ba22779e3333ce74a8561 (diff)
downloadchromium_src-c21aae4c5085110ff9115b2b7e094699016ff65e.zip
chromium_src-c21aae4c5085110ff9115b2b7e094699016ff65e.tar.gz
chromium_src-c21aae4c5085110ff9115b2b7e094699016ff65e.tar.bz2
Revert 223913 "Use SNAPSHOT sync mode for LocalSync"
This apparently was racy, see http://crbug.com/294499 > Use SNAPSHOT sync mode for LocalSync > > LocalFileSyncService keeps the returned snapshot around until > ApplyLocalChange finishes, so this change must be transparent > to the remote side. > > This patch depends on: https://codereview.chromium.org/24106002/ > > BUG=175693 > TEST=LocalFileSyncContextTest.PrepareSync_WriteDuringSync_* > TEST=DriveFileSyncServiceSyncTest.* > TEST=manual > > Review URL: https://chromiumcodereview.appspot.com/23578026 TBR=kinuko@chromium.org Review URL: https://codereview.chromium.org/23452045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync_file_system')
-rw-r--r--chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service.cc15
-rw-r--r--chrome/browser/sync_file_system/local/local_file_change_tracker.h1
-rw-r--r--chrome/browser/sync_file_system/local/local_file_change_tracker_unittest.cc3
-rw-r--r--chrome/browser/sync_file_system/local/local_file_sync_context.cc85
-rw-r--r--chrome/browser/sync_file_system/local/local_file_sync_context.h29
-rw-r--r--chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc150
-rw-r--r--chrome/browser/sync_file_system/local/local_file_sync_service.cc16
-rw-r--r--chrome/browser/sync_file_system/local/local_file_sync_service.h8
-rw-r--r--chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc20
-rw-r--r--chrome/browser/sync_file_system/local/syncable_file_operation_runner_unittest.cc7
-rw-r--r--chrome/browser/sync_file_system/local/syncable_file_system_unittest.cc5
-rw-r--r--chrome/browser/sync_file_system/syncable_file_system_util.cc11
-rw-r--r--chrome/browser/sync_file_system/syncable_file_system_util.h3
-rw-r--r--chrome/browser/sync_file_system/syncable_file_system_util_unittest.cc1
14 files changed, 84 insertions, 270 deletions
diff --git a/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service.cc b/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service.cc
index 39f2db2..e2a93d5 100644
--- a/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service.cc
+++ b/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service.cc
@@ -48,6 +48,15 @@ typedef RemoteFileSyncService::OriginStatusMap OriginStatusMap;
namespace {
const base::FilePath::CharType kTempDirName[] = FILE_PATH_LITERAL("tmp");
+const base::FilePath::CharType kSyncFileSystemDir[] =
+ FILE_PATH_LITERAL("Sync FileSystem");
+const base::FilePath::CharType kSyncFileSystemDirDev[] =
+ FILE_PATH_LITERAL("Sync FileSystem Dev");
+
+const base::FilePath::CharType* GetSyncFileSystemDir() {
+ return IsSyncFSDirectoryOperationEnabled()
+ ? kSyncFileSystemDirDev : kSyncFileSystemDir;
+}
void EmptyStatusCallback(SyncStatusCode status) {}
@@ -342,14 +351,14 @@ void DriveFileSyncService::Initialize(
task_manager_ = task_manager.Pass();
- temporary_file_dir_ = sync_file_system::GetSyncFileSystemDir(
- profile_->GetPath()).Append(kTempDirName);
+ temporary_file_dir_ =
+ profile_->GetPath().Append(GetSyncFileSystemDir()).Append(kTempDirName);
api_util_.reset(new drive_backend::APIUtil(profile_, temporary_file_dir_));
api_util_->AddObserver(this);
metadata_store_.reset(new DriveMetadataStore(
- GetSyncFileSystemDir(profile_->GetPath()),
+ profile_->GetPath().Append(GetSyncFileSystemDir()),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE).get()));
diff --git a/chrome/browser/sync_file_system/local/local_file_change_tracker.h b/chrome/browser/sync_file_system/local/local_file_change_tracker.h
index 456a489..93470d1 100644
--- a/chrome/browser/sync_file_system/local/local_file_change_tracker.h
+++ b/chrome/browser/sync_file_system/local/local_file_change_tracker.h
@@ -103,7 +103,6 @@ class LocalFileChangeTracker
friend class CannedSyncableFileSystem;
friend class LocalFileChangeTrackerTest;
friend class LocalFileSyncContext;
- friend class LocalFileSyncContextTest;
friend class SyncableFileSystemTest;
struct ChangeInfo {
diff --git a/chrome/browser/sync_file_system/local/local_file_change_tracker_unittest.cc b/chrome/browser/sync_file_system/local/local_file_change_tracker_unittest.cc
index 4a44e76..de0128d 100644
--- a/chrome/browser/sync_file_system/local/local_file_change_tracker_unittest.cc
+++ b/chrome/browser/sync_file_system/local/local_file_change_tracker_unittest.cc
@@ -43,8 +43,7 @@ class LocalFileChangeTrackerTest : public testing::Test {
file_system_.SetUp();
sync_context_ =
- new LocalFileSyncContext(base::FilePath(),
- base::MessageLoopProxy::current().get(),
+ new LocalFileSyncContext(base::MessageLoopProxy::current().get(),
base::MessageLoopProxy::current().get());
ASSERT_EQ(
sync_file_system::SYNC_STATUS_OK,
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_context.cc b/chrome/browser/sync_file_system/local/local_file_sync_context.cc
index b4f3a03..c8b937a 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_context.cc
+++ b/chrome/browser/sync_file_system/local/local_file_sync_context.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
#include "base/bind.h"
-#include "base/file_util.h"
#include "base/location.h"
#include "base/platform_file.h"
#include "base/single_thread_task_runner.h"
@@ -22,7 +21,6 @@
#include "webkit/browser/fileapi/file_system_file_util.h"
#include "webkit/browser/fileapi/file_system_operation_context.h"
#include "webkit/browser/fileapi/file_system_operation_runner.h"
-#include "webkit/common/blob/scoped_file.h"
#include "webkit/common/fileapi/file_system_util.h"
using fileapi::FileSystemContext;
@@ -39,16 +37,12 @@ const int kMaxConcurrentSyncableOperation = 3;
const int kNotifyChangesDurationInSec = 1;
const int kMaxURLsToFetchForLocalSync = 5;
-const base::FilePath::CharType kSnapshotDir[] = FILE_PATH_LITERAL("snapshots");
-
} // namespace
LocalFileSyncContext::LocalFileSyncContext(
- const base::FilePath& base_path,
base::SingleThreadTaskRunner* ui_task_runner,
base::SingleThreadTaskRunner* io_task_runner)
- : local_base_path_(base_path.Append(FILE_PATH_LITERAL("local"))),
- ui_task_runner_(ui_task_runner),
+ : ui_task_runner_(ui_task_runner),
io_task_runner_(io_task_runner),
shutdown_on_ui_(false),
mock_notify_changes_duration_in_sec_(-1) {
@@ -165,12 +159,6 @@ void LocalFileSyncContext::CommitChangeStatusForURL(
backend->change_tracker()->RemoveMirrorAndCommitChangesForURL(url);
}
- // We've been keeping it in writing mode, so clear the writing counter
- // to unblock sync activities.
- io_task_runner_->PostTask(
- FROM_HERE, base::Bind(&LocalFileSyncContext::EndWritingOnIOThread,
- this, url));
-
// Call the completion callback on UI thread.
ui_task_runner_->PostTask(FROM_HERE, done_callback);
}
@@ -179,8 +167,8 @@ void LocalFileSyncContext::ClearSyncFlagForURL(const FileSystemURL& url) {
// This is initially called on UI thread and to be relayed to IO thread.
io_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&LocalFileSyncContext::ClearSyncFlagOnIOThread,
- this, url, false /* keep_url_in_writing */));
+ base::Bind(&LocalFileSyncContext::EnableWritingOnIOThread,
+ this, url, true /* may_have_updates */));
}
void LocalFileSyncContext::PrepareForSync(
@@ -562,10 +550,6 @@ SyncStatusCode LocalFileSyncContext::InitializeChangeTrackerOnFileThread(
iter != urls.end(); ++iter) {
origins_with_changes->insert(iter->origin());
}
-
- // Creates snapshot directory.
- file_util::CreateDirectory(local_base_path_.Append(kSnapshotDir));
-
return status;
}
@@ -649,14 +633,13 @@ void LocalFileSyncContext::TryPrepareForLocalSync(
DCHECK(urls);
if (shutdown_on_ui_) {
- callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo(),
- scoped_ptr<webkit_blob::ScopedFile>());
+ callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo());
return;
}
if (urls->empty()) {
- callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, LocalFileSyncInfo(),
- scoped_ptr<webkit_blob::ScopedFile>());
+ callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC,
+ LocalFileSyncInfo());
return;
}
@@ -665,8 +648,9 @@ void LocalFileSyncContext::TryPrepareForLocalSync(
std::deque<FileSystemURL>* remaining = new std::deque<FileSystemURL>;
remaining->swap(*urls);
+ // TODO(kinuko): Call PrepareForSync with SYNC_SNAPSHOT when it becomes ready.
PrepareForSync(
- file_system_context, url, SYNC_SNAPSHOT,
+ file_system_context, url, SYNC_EXCLUSIVE,
base::Bind(&LocalFileSyncContext::DidTryPrepareForLocalSync,
this, make_scoped_refptr(file_system_context),
base::Owned(remaining), callback));
@@ -677,11 +661,10 @@ void LocalFileSyncContext::DidTryPrepareForLocalSync(
std::deque<FileSystemURL>* remaining_urls,
const LocalFileSyncInfoCallback& callback,
SyncStatusCode status,
- const LocalFileSyncInfo& sync_file_info,
- scoped_ptr<webkit_blob::ScopedFile> snapshot) {
+ const LocalFileSyncInfo& sync_file_info) {
DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
if (status != SYNC_STATUS_FILE_BUSY) {
- callback.Run(status, sync_file_info, snapshot.Pass());
+ callback.Run(status, sync_file_info);
return;
}
// Recursively call TryPrepareForLocalSync with remaining_urls.
@@ -700,8 +683,7 @@ void LocalFileSyncContext::DidGetWritingStatusForSync(
RunsTasksOnCurrentThread()) {
DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
if (shutdown_on_ui_) {
- callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo(),
- scoped_ptr<webkit_blob::ScopedFile>());
+ callback.Run(SYNC_STATUS_ABORT, LocalFileSyncInfo());
return;
}
file_system_context->default_file_task_runner()->PostTask(
@@ -731,21 +713,9 @@ void LocalFileSyncContext::DidGetWritingStatusForSync(
url,
&file_info,
&platform_path);
-
- scoped_ptr<webkit_blob::ScopedFile> snapshot;
if (file_error == base::PLATFORM_FILE_OK && sync_mode == SYNC_SNAPSHOT) {
- base::FilePath snapshot_path;
- file_util::CreateTemporaryFileInDir(local_base_path_.Append(kSnapshotDir),
- &snapshot_path);
- if (base::CopyFile(platform_path, snapshot_path)) {
- platform_path = snapshot_path;
- snapshot.reset(new webkit_blob::ScopedFile(
- snapshot_path,
- webkit_blob::ScopedFile::DELETE_ON_SCOPE_OUT,
- file_system_context->default_file_task_runner()));
- }
+ // TODO(kinuko): creates a snapshot file.
}
-
if (status == SYNC_STATUS_OK &&
file_error != base::PLATFORM_FILE_OK &&
file_error != base::PLATFORM_FILE_ERROR_NOT_FOUND)
@@ -759,6 +729,7 @@ void LocalFileSyncContext::DidGetWritingStatusForSync(
else if (file_info.is_directory)
file_type = SYNC_FILE_TYPE_DIRECTORY;
+ // TODO(kinuko): returns the snapshot file path if snapshot is available.
LocalFileSyncInfo sync_file_info;
sync_file_info.url = url;
sync_file_info.local_file_path = platform_path;
@@ -776,24 +747,21 @@ void LocalFileSyncContext::DidGetWritingStatusForSync(
}
// 'Unlock' the file if sync_mode is not SYNC_EXCLUSIVE.
- // (But keep it in writing status so that no other sync starts on
- // the same URL)
if (sync_mode != SYNC_EXCLUSIVE) {
io_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&LocalFileSyncContext::ClearSyncFlagOnIOThread,
- this, url, true /* keep_url_in_writing */));
+ base::Bind(&LocalFileSyncContext::EnableWritingOnIOThread,
+ this, url, false /* may_have_updates */));
}
}
ui_task_runner_->PostTask(FROM_HERE,
- base::Bind(callback, status, sync_file_info,
- base::Passed(&snapshot)));
+ base::Bind(callback, status, sync_file_info));
}
-void LocalFileSyncContext::ClearSyncFlagOnIOThread(
+void LocalFileSyncContext::EnableWritingOnIOThread(
const FileSystemURL& url,
- bool keep_url_in_writing) {
+ bool may_have_updates) {
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
if (!sync_status()) {
// The service might have been shut down.
@@ -801,27 +769,14 @@ void LocalFileSyncContext::ClearSyncFlagOnIOThread(
}
sync_status()->EndSyncing(url);
- if (keep_url_in_writing) {
- // The caller will hold shared lock on this one.
- sync_status()->StartWriting(url);
+ if (!may_have_updates)
return;
- }
// Since a sync has finished the number of changes must have been updated.
origins_with_pending_changes_.insert(url.origin());
ScheduleNotifyChangesUpdatedOnIOThread();
}
-void LocalFileSyncContext::EndWritingOnIOThread(
- const FileSystemURL& url) {
- DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
- if (!sync_status()) {
- // The service might have been shut down.
- return;
- }
- sync_status()->EndWriting(url);
-}
-
void LocalFileSyncContext::DidApplyRemoteChange(
const FileSystemURL& url,
const SyncStatusCallback& callback_on_ui,
@@ -831,7 +786,7 @@ void LocalFileSyncContext::DidApplyRemoteChange(
FROM_HERE,
base::Bind(callback_on_ui,
PlatformFileErrorToSyncStatusCode(file_error)));
- ClearSyncFlagOnIOThread(url, false /* keep_url_in_writing */);
+ EnableWritingOnIOThread(url, true /* may_have_updates */);
}
void LocalFileSyncContext::DidGetFileMetadata(
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_context.h b/chrome/browser/sync_file_system/local/local_file_sync_context.h
index 788721d..7a4cfe7 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_context.h
+++ b/chrome/browser/sync_file_system/local/local_file_sync_context.h
@@ -33,10 +33,6 @@ class FileSystemContext;
class FileSystemURL;
}
-namespace webkit_blob {
-class ScopedFile;
-}
-
namespace sync_file_system {
class FileChange;
@@ -60,17 +56,14 @@ class LocalFileSyncContext
};
typedef base::Callback<void(
- SyncStatusCode status,
- const LocalFileSyncInfo& sync_file_info,
- scoped_ptr<webkit_blob::ScopedFile> snapshot)>
+ SyncStatusCode status, const LocalFileSyncInfo& sync_file_info)>
LocalFileSyncInfoCallback;
typedef base::Callback<void(SyncStatusCode status,
bool has_pending_changes)>
HasPendingLocalChangeCallback;
- LocalFileSyncContext(const base::FilePath& base_path,
- base::SingleThreadTaskRunner* ui_task_runner,
+ LocalFileSyncContext(base::SingleThreadTaskRunner* ui_task_runner,
base::SingleThreadTaskRunner* io_task_runner);
// Initializes |file_system_context| for syncable file operations
@@ -244,8 +237,7 @@ class LocalFileSyncContext
std::deque<fileapi::FileSystemURL>* remaining_urls,
const LocalFileSyncInfoCallback& callback,
SyncStatusCode status,
- const LocalFileSyncInfo& sync_file_info,
- scoped_ptr<webkit_blob::ScopedFile> snapshot);
+ const LocalFileSyncInfo& sync_file_info);
// Callback routine for PrepareForSync and GetFileForLocalSync.
void DidGetWritingStatusForSync(
@@ -255,16 +247,9 @@ class LocalFileSyncContext
SyncMode sync_mode,
const LocalFileSyncInfoCallback& callback);
- // Helper routine for sync/writing flag handling, primarily for
- // ClearSyncFlagForURL but is also called by other internal routines.
- // If |keep_url_in_writing| is true this increments the writing counter
- // for |url| (after clearing syncing flag), so that the caller can
- // continue to hold a shared lock on the URL.
- // (The counter must be manually decremented by EndWritingOnIOThread
- // if that's the case)
- void ClearSyncFlagOnIOThread(const fileapi::FileSystemURL& url,
- bool keep_url_in_writing);
- void EndWritingOnIOThread(const fileapi::FileSystemURL& url);
+ // Helper routine for ClearSyncFlagForURL.
+ void EnableWritingOnIOThread(const fileapi::FileSystemURL& url,
+ bool may_have_updates);
void DidRemoveExistingEntryForApplyRemoteChange(
fileapi::FileSystemContext* file_system_context,
@@ -294,8 +279,6 @@ class LocalFileSyncContext
const StatusCallback& callback,
base::PlatformFileError error);
- const base::FilePath local_base_path_;
-
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc b/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc
index 1d3b360..a1ede5a 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc
+++ b/chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc
@@ -26,7 +26,6 @@
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_operation_runner.h"
#include "webkit/browser/fileapi/isolated_context.h"
-#include "webkit/common/blob/scoped_file.h"
#define FPL FILE_PATH_LITERAL
@@ -61,7 +60,6 @@ class LocalFileSyncContextTest : public testing::Test {
virtual void SetUp() OVERRIDE {
RegisterSyncableFileSystem();
- ASSERT_TRUE(dir_.CreateUniqueTempDir());
ui_task_runner_ = base::MessageLoop::current()->message_loop_proxy();
io_task_runner_ = BrowserThread::GetMessageLoopProxyForThread(
@@ -76,10 +74,8 @@ class LocalFileSyncContextTest : public testing::Test {
void StartPrepareForSync(FileSystemContext* file_system_context,
const FileSystemURL& url,
- LocalFileSyncContext::SyncMode sync_mode,
SyncFileMetadata* metadata,
- FileChangeList* changes,
- webkit_blob::ScopedFile* snapshot) {
+ FileChangeList* changes) {
ASSERT_TRUE(changes != NULL);
ASSERT_FALSE(has_inflight_prepare_for_sync_);
status_ = SYNC_STATUS_UNKNOWN;
@@ -87,49 +83,39 @@ class LocalFileSyncContextTest : public testing::Test {
sync_context_->PrepareForSync(
file_system_context,
url,
- sync_mode,
+ LocalFileSyncContext::SYNC_EXCLUSIVE,
base::Bind(&LocalFileSyncContextTest::DidPrepareForSync,
- base::Unretained(this), metadata, changes, snapshot));
+ base::Unretained(this), metadata, changes));
}
SyncStatusCode PrepareForSync(FileSystemContext* file_system_context,
const FileSystemURL& url,
- LocalFileSyncContext::SyncMode sync_mode,
SyncFileMetadata* metadata,
- FileChangeList* changes,
- webkit_blob::ScopedFile* snapshot) {
- StartPrepareForSync(file_system_context, url, sync_mode,
- metadata, changes, snapshot);
+ FileChangeList* changes) {
+ StartPrepareForSync(file_system_context, url, metadata, changes);
base::MessageLoop::current()->Run();
return status_;
}
- base::Closure GetPrepareForSyncClosure(
- FileSystemContext* file_system_context,
- const FileSystemURL& url,
- LocalFileSyncContext::SyncMode sync_mode,
- SyncFileMetadata* metadata,
- FileChangeList* changes,
- webkit_blob::ScopedFile* snapshot) {
+ base::Closure GetPrepareForSyncClosure(FileSystemContext* file_system_context,
+ const FileSystemURL& url,
+ SyncFileMetadata* metadata,
+ FileChangeList* changes) {
return base::Bind(&LocalFileSyncContextTest::StartPrepareForSync,
base::Unretained(this),
base::Unretained(file_system_context),
- url, sync_mode, metadata, changes, snapshot);
+ url, metadata, changes);
}
void DidPrepareForSync(SyncFileMetadata* metadata_out,
FileChangeList* changes_out,
- webkit_blob::ScopedFile* snapshot_out,
SyncStatusCode status,
- const LocalFileSyncInfo& sync_file_info,
- scoped_ptr<webkit_blob::ScopedFile> snapshot) {
+ const LocalFileSyncInfo& sync_file_info) {
ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread());
has_inflight_prepare_for_sync_ = false;
status_ = status;
*metadata_out = sync_file_info.metadata;
*changes_out = sync_file_info.changes;
- if (snapshot_out && snapshot)
- *snapshot_out = snapshot->Pass();
base::MessageLoop::current()->Quit();
}
@@ -145,9 +131,7 @@ class LocalFileSyncContextTest : public testing::Test {
SyncFileMetadata metadata;
FileChangeList changes;
EXPECT_EQ(SYNC_STATUS_OK,
- PrepareForSync(file_system_context, url,
- LocalFileSyncContext::SYNC_EXCLUSIVE,
- &metadata, &changes, NULL));
+ PrepareForSync(file_system_context, url, &metadata, &changes));
EXPECT_EQ(expected_file_type, metadata.file_type);
status_ = SYNC_STATUS_UNKNOWN;
@@ -222,7 +206,7 @@ class LocalFileSyncContextTest : public testing::Test {
file_task_runner_.get());
file_system.SetUp();
sync_context_ = new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
+ ui_task_runner_.get(), io_task_runner_.get());
ASSERT_EQ(SYNC_STATUS_OK,
file_system.MaybeInitializeFileSystemContext(
sync_context_.get()));
@@ -235,7 +219,7 @@ class LocalFileSyncContextTest : public testing::Test {
FileChangeList changes;
EXPECT_EQ(SYNC_STATUS_OK,
PrepareForSync(file_system.file_system_context(), kFile,
- sync_mode, &metadata, &changes, NULL));
+ &metadata, &changes));
EXPECT_EQ(1U, changes.size());
EXPECT_TRUE(changes.list().back().IsFile());
EXPECT_TRUE(changes.list().back().IsAddOrUpdate());
@@ -265,73 +249,8 @@ class LocalFileSyncContextTest : public testing::Test {
file_system.TearDown();
}
- void PrepareForSync_WriteDuringSync(
- LocalFileSyncContext::SyncMode sync_mode) {
- CannedSyncableFileSystem file_system(GURL(kOrigin1),
- io_task_runner_.get(),
- file_task_runner_.get());
- file_system.SetUp();
- sync_context_ = new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
- ASSERT_EQ(SYNC_STATUS_OK,
- file_system.MaybeInitializeFileSystemContext(
- sync_context_.get()));
- ASSERT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem());
-
- const FileSystemURL kFile(file_system.URL("file"));
- EXPECT_EQ(base::PLATFORM_FILE_OK, file_system.CreateFile(kFile));
-
- SyncFileMetadata metadata;
- FileChangeList changes;
- webkit_blob::ScopedFile snapshot;
- EXPECT_EQ(SYNC_STATUS_OK,
- PrepareForSync(file_system.file_system_context(), kFile,
- sync_mode, &metadata, &changes, &snapshot));
- EXPECT_EQ(1U, changes.size());
- EXPECT_TRUE(changes.list().back().IsFile());
- EXPECT_TRUE(changes.list().back().IsAddOrUpdate());
-
- EXPECT_EQ(sync_mode == LocalFileSyncContext::SYNC_SNAPSHOT,
- !snapshot.path().empty());
-
- // Tracker keeps same set of changes.
- file_system.GetChangesForURLInTracker(kFile, &changes);
- EXPECT_EQ(1U, changes.size());
- EXPECT_TRUE(changes.list().back().IsFile());
- EXPECT_TRUE(changes.list().back().IsAddOrUpdate());
-
- StartModifyFileOnIOThread(&file_system, kFile);
-
- if (sync_mode == LocalFileSyncContext::SYNC_SNAPSHOT) {
- // Write should succeed.
- EXPECT_EQ(base::PLATFORM_FILE_OK, WaitUntilModifyFileIsDone());
- } else {
- base::MessageLoop::current()->RunUntilIdle();
- EXPECT_FALSE(async_modify_finished_);
- }
-
- SimulateFinishSync(file_system.file_system_context(), kFile,
- SYNC_STATUS_OK);
-
- EXPECT_EQ(base::PLATFORM_FILE_OK, WaitUntilModifyFileIsDone());
-
- // Sync succeeded, but the other change that was made during or
- // after sync is recorded.
- file_system.GetChangesForURLInTracker(kFile, &changes);
- EXPECT_EQ(1U, changes.size());
- EXPECT_TRUE(changes.list().back().IsFile());
- EXPECT_TRUE(changes.list().back().IsAddOrUpdate());
-
- sync_context_->ShutdownOnUIThread();
- sync_context_ = NULL;
-
- file_system.TearDown();
- }
-
ScopedEnableSyncFSDirectoryOperation enable_directory_operation_;
- base::ScopedTempDir dir_;
-
// These need to remain until the very end.
content::TestBrowserThreadBundle thread_bundle_;
@@ -348,9 +267,8 @@ class LocalFileSyncContextTest : public testing::Test {
};
TEST_F(LocalFileSyncContextTest, ConstructAndDestruct) {
- sync_context_ =
- new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
+ sync_context_ = new LocalFileSyncContext(
+ ui_task_runner_.get(), io_task_runner_.get());
sync_context_->ShutdownOnUIThread();
}
@@ -361,7 +279,7 @@ TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) {
file_system.SetUp();
sync_context_ = new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
+ ui_task_runner_.get(), io_task_runner_.get());
// Initializes file_system using |sync_context_|.
EXPECT_EQ(SYNC_STATUS_OK,
@@ -406,7 +324,7 @@ TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) {
file_system2.SetUp();
sync_context_ = new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
+ ui_task_runner_.get(), io_task_runner_.get());
// Initializes file_system1 and file_system2.
EXPECT_EQ(SYNC_STATUS_OK,
@@ -453,8 +371,7 @@ TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) {
FileChangeList changes;
EXPECT_EQ(SYNC_STATUS_OK,
PrepareForSync(file_system1.file_system_context(), kURL1,
- LocalFileSyncContext::SYNC_EXCLUSIVE,
- &metadata, &changes, NULL));
+ &metadata, &changes));
EXPECT_EQ(1U, changes.size());
EXPECT_TRUE(changes.list().back().IsFile());
EXPECT_TRUE(changes.list().back().IsAddOrUpdate());
@@ -464,8 +381,7 @@ TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) {
changes.clear();
EXPECT_EQ(SYNC_STATUS_OK,
PrepareForSync(file_system2.file_system_context(), kURL2,
- LocalFileSyncContext::SYNC_EXCLUSIVE,
- &metadata, &changes, NULL));
+ &metadata, &changes));
EXPECT_EQ(1U, changes.size());
EXPECT_FALSE(changes.list().back().IsFile());
EXPECT_TRUE(changes.list().back().IsAddOrUpdate());
@@ -499,14 +415,6 @@ TEST_F(LocalFileSyncContextTest, PrepareSync_SyncFailure_Snapshot) {
SYNC_STATUS_FAILED);
}
-TEST_F(LocalFileSyncContextTest, PrepareSync_WriteDuringSync_Exclusive) {
- PrepareForSync_WriteDuringSync(LocalFileSyncContext::SYNC_EXCLUSIVE);
-}
-
-TEST_F(LocalFileSyncContextTest, PrepareSync_WriteDuringSync_Snapshot) {
- PrepareForSync_WriteDuringSync(LocalFileSyncContext::SYNC_SNAPSHOT);
-}
-
// LocalFileSyncContextTest.PrepareSyncWhileWriting is flaky on android.
// http://crbug.com/239793
#if defined(OS_ANDROID)
@@ -520,7 +428,7 @@ TEST_F(LocalFileSyncContextTest, MAYBE_PrepareSyncWhileWriting) {
file_task_runner_.get());
file_system.SetUp();
sync_context_ = new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
+ ui_task_runner_.get(), io_task_runner_.get());
EXPECT_EQ(SYNC_STATUS_OK,
file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
@@ -539,9 +447,8 @@ TEST_F(LocalFileSyncContextTest, MAYBE_PrepareSyncWhileWriting) {
metadata.file_type = SYNC_FILE_TYPE_UNKNOWN;
FileChangeList changes;
EXPECT_EQ(SYNC_STATUS_FILE_BUSY,
- PrepareForSync(file_system.file_system_context(), kURL1,
- LocalFileSyncContext::SYNC_EXCLUSIVE,
- &metadata, &changes, NULL));
+ PrepareForSync(file_system.file_system_context(),
+ kURL1, &metadata, &changes));
EXPECT_EQ(SYNC_FILE_TYPE_FILE, metadata.file_type);
// Register PrepareForSync method to be invoked when kURL1 becomes
@@ -550,9 +457,8 @@ TEST_F(LocalFileSyncContextTest, MAYBE_PrepareSyncWhileWriting) {
metadata.file_type = SYNC_FILE_TYPE_UNKNOWN;
changes.clear();
sync_context_->RegisterURLForWaitingSync(
- kURL1, GetPrepareForSyncClosure(file_system.file_system_context(), kURL1,
- LocalFileSyncContext::SYNC_EXCLUSIVE,
- &metadata, &changes, NULL));
+ kURL1, GetPrepareForSyncClosure(file_system.file_system_context(),
+ kURL1, &metadata, &changes));
// Wait for the completion.
EXPECT_EQ(base::PLATFORM_FILE_OK, WaitUntilModifyFileIsDone());
@@ -582,7 +488,7 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForDeletion) {
file_system.SetUp();
sync_context_ = new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
+ ui_task_runner_.get(), io_task_runner_.get());
ASSERT_EQ(SYNC_STATUS_OK,
file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
ASSERT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem());
@@ -671,7 +577,7 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate) {
file_system.SetUp();
sync_context_ = new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
+ ui_task_runner_.get(), io_task_runner_.get());
ASSERT_EQ(SYNC_STATUS_OK,
file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
ASSERT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem());
@@ -820,7 +726,7 @@ TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate_NoParent) {
file_system.SetUp();
sync_context_ = new LocalFileSyncContext(
- dir_.path(), ui_task_runner_.get(), io_task_runner_.get());
+ ui_task_runner_.get(), io_task_runner_.get());
ASSERT_EQ(SYNC_STATUS_OK,
file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
ASSERT_EQ(base::PLATFORM_FILE_OK, file_system.OpenFileSystem());
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_service.cc b/chrome/browser/sync_file_system/local/local_file_sync_service.cc
index 8a987b8..33fbb34 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_service.cc
+++ b/chrome/browser/sync_file_system/local/local_file_sync_service.cc
@@ -22,7 +22,6 @@
#include "url/gurl.h"
#include "webkit/browser/fileapi/file_system_context.h"
#include "webkit/browser/fileapi/file_system_url.h"
-#include "webkit/common/blob/scoped_file.h"
using content::BrowserThread;
using fileapi::FileSystemURL;
@@ -34,8 +33,7 @@ namespace {
void PrepareForProcessRemoteChangeCallbackAdapter(
const RemoteChangeProcessor::PrepareChangeCallback& callback,
SyncStatusCode status,
- const LocalFileSyncInfo& sync_file_info,
- scoped_ptr<webkit_blob::ScopedFile> snapshot) {
+ const LocalFileSyncInfo& sync_file_info) {
callback.Run(status, sync_file_info.metadata, sync_file_info.changes);
}
@@ -99,7 +97,6 @@ void LocalFileSyncService::OriginChangeMap::SetOriginEnabled(
LocalFileSyncService::LocalFileSyncService(Profile* profile)
: profile_(profile),
sync_context_(new LocalFileSyncContext(
- profile_->GetPath(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI).get(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)
.get())),
@@ -365,8 +362,7 @@ void LocalFileSyncService::RunLocalSyncCallback(
void LocalFileSyncService::DidGetFileForLocalSync(
SyncStatusCode status,
- const LocalFileSyncInfo& sync_file_info,
- scoped_ptr<webkit_blob::ScopedFile> snapshot) {
+ const LocalFileSyncInfo& sync_file_info) {
DCHECK(!local_sync_callback_.is_null());
if (status != SYNC_STATUS_OK) {
RunLocalSyncCallback(status, sync_file_info.url);
@@ -390,12 +386,11 @@ void LocalFileSyncService::DidGetFileForLocalSync(
sync_file_info.metadata,
sync_file_info.url,
base::Bind(&LocalFileSyncService::ProcessNextChangeForURL,
- AsWeakPtr(), base::Passed(&snapshot), sync_file_info,
+ AsWeakPtr(), sync_file_info,
next_change, sync_file_info.changes.PopAndGetNewList()));
}
void LocalFileSyncService::ProcessNextChangeForURL(
- scoped_ptr<webkit_blob::ScopedFile> snapshot,
const LocalFileSyncInfo& sync_file_info,
const FileChange& processed_change,
const FileChangeList& changes,
@@ -412,8 +407,7 @@ void LocalFileSyncService::ProcessNextChangeForURL(
sync_file_info.metadata,
sync_file_info.url,
base::Bind(&LocalFileSyncService::ProcessNextChangeForURL,
- AsWeakPtr(), base::Passed(&snapshot),
- sync_file_info, processed_change, changes));
+ AsWeakPtr(), sync_file_info, processed_change, changes));
return;
}
@@ -440,7 +434,7 @@ void LocalFileSyncService::ProcessNextChangeForURL(
sync_file_info.metadata,
url,
base::Bind(&LocalFileSyncService::ProcessNextChangeForURL,
- AsWeakPtr(), base::Passed(&snapshot), sync_file_info,
+ AsWeakPtr(), sync_file_info,
next_change, changes.PopAndGetNewList()));
}
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_service.h b/chrome/browser/sync_file_system/local/local_file_sync_service.h
index b72f66e..7da29c6 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_service.h
+++ b/chrome/browser/sync_file_system/local/local_file_sync_service.h
@@ -26,10 +26,6 @@ namespace fileapi {
class FileSystemContext;
}
-namespace webkit_blob {
-class ScopedFile;
-}
-
namespace sync_file_system {
class FileChange;
@@ -185,10 +181,8 @@ class LocalFileSyncService
// Callbacks for ProcessLocalChange.
void DidGetFileForLocalSync(
SyncStatusCode status,
- const LocalFileSyncInfo& sync_file_info,
- scoped_ptr<webkit_blob::ScopedFile> snapshot);
+ const LocalFileSyncInfo& sync_file_info);
void ProcessNextChangeForURL(
- scoped_ptr<webkit_blob::ScopedFile> snapshot,
const LocalFileSyncInfo& sync_file_info,
const FileChange& last_change,
const FileChangeList& changes,
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc b/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
index 035e03c..499ea67 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
+++ b/chrome/browser/sync_file_system/local/local_file_sync_service_unittest.cc
@@ -321,12 +321,10 @@ TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_CreateFile) {
base::RunLoop run_loop;
- // We should get called OnSyncEnabled and OnWriteEnabled on kFile.
- // (OnWriteEnabled is called because we release lock before returning
- // from ApplyLocalChange)
+ // We should get called OnSyncEnabled on kFile.
StrictMock<MockSyncStatusObserver> status_observer;
- EXPECT_CALL(status_observer, OnSyncEnabled(kFile)).Times(AtLeast(1));
- EXPECT_CALL(status_observer, OnWriteEnabled(kFile)).Times(AtLeast(1));
+ EXPECT_CALL(status_observer, OnSyncEnabled(kFile))
+ .Times(AtLeast(1));
file_system_->AddSyncStatusObserver(&status_observer);
// Creates and writes into a file.
@@ -334,7 +332,7 @@ TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_CreateFile) {
EXPECT_EQ(kTestFileDataSize,
file_system_->WriteString(kFile, std::string(kTestFileData)));
- // Retrieve the expected file info.
+ // Retrieve the expected platform_path.
base::PlatformFileInfo info;
base::FilePath platform_path;
EXPECT_EQ(base::PLATFORM_FILE_OK,
@@ -355,7 +353,7 @@ TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_CreateFile) {
const FileChange change(FileChange::FILE_CHANGE_ADD_OR_UPDATE,
SYNC_FILE_TYPE_FILE);
EXPECT_CALL(local_change_processor,
- ApplyLocalChange(change, _, metadata, kFile, _))
+ ApplyLocalChange(change, platform_path, metadata, kFile, _))
.WillOnce(MockStatusCallback(SYNC_STATUS_OK));
local_service_->SetLocalChangeProcessor(&local_change_processor);
@@ -377,8 +375,8 @@ TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_CreateAndRemoveFile) {
// We should get called OnSyncEnabled and OnWriteEnabled on kFile.
StrictMock<MockSyncStatusObserver> status_observer;
- EXPECT_CALL(status_observer, OnSyncEnabled(kFile)).Times(AtLeast(1));
- EXPECT_CALL(status_observer, OnWriteEnabled(kFile)).Times(AtLeast(1));
+ EXPECT_CALL(status_observer, OnSyncEnabled(kFile))
+ .Times(AtLeast(1));
file_system_->AddSyncStatusObserver(&status_observer);
// Creates and then deletes a file.
@@ -467,10 +465,6 @@ TEST_F(LocalFileSyncServiceTest, ProcessLocalChange_MultipleChanges) {
.WillOnce(MockStatusCallbackAndRecordChange(SYNC_STATUS_OK, &changes))
.WillOnce(MockStatusCallbackAndRecordChange(SYNC_STATUS_OK, &changes));
local_service_->SetLocalChangeProcessor(&local_change_processor);
-
- // OnWriteEnabled will be notified on kPath.
- EXPECT_CALL(status_observer, OnWriteEnabled(kPath)).Times(AtLeast(1));
-
local_service_->ProcessLocalChange(
base::Bind(&OnSyncCompleted, FROM_HERE, run_loop.QuitClosure(),
SYNC_STATUS_OK, kPath));
diff --git a/chrome/browser/sync_file_system/local/syncable_file_operation_runner_unittest.cc b/chrome/browser/sync_file_system/local/syncable_file_operation_runner_unittest.cc
index 112ad95..2f49faa 100644
--- a/chrome/browser/sync_file_system/local/syncable_file_operation_runner_unittest.cc
+++ b/chrome/browser/sync_file_system/local/syncable_file_operation_runner_unittest.cc
@@ -60,10 +60,9 @@ class SyncableFileOperationRunnerTest : public testing::Test {
virtual void SetUp() OVERRIDE {
ASSERT_TRUE(dir_.CreateUniqueTempDir());
file_system_.SetUp();
- sync_context_ = new LocalFileSyncContext(
- dir_.path(),
- base::MessageLoopProxy::current().get(),
- base::MessageLoopProxy::current().get());
+ sync_context_ =
+ new LocalFileSyncContext(base::MessageLoopProxy::current().get(),
+ base::MessageLoopProxy::current().get());
ASSERT_EQ(
SYNC_STATUS_OK,
file_system_.MaybeInitializeFileSystemContext(sync_context_.get()));
diff --git a/chrome/browser/sync_file_system/local/syncable_file_system_unittest.cc b/chrome/browser/sync_file_system/local/syncable_file_system_unittest.cc
index e4a7524..9e5da42 100644
--- a/chrome/browser/sync_file_system/local/syncable_file_system_unittest.cc
+++ b/chrome/browser/sync_file_system/local/syncable_file_system_unittest.cc
@@ -39,13 +39,10 @@ class SyncableFileSystemTest : public testing::Test {
weak_factory_(this) {}
virtual void SetUp() {
- ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
-
file_system_.SetUp();
sync_context_ =
- new LocalFileSyncContext(data_dir_.path(),
- base::MessageLoopProxy::current().get(),
+ new LocalFileSyncContext(base::MessageLoopProxy::current().get(),
base::MessageLoopProxy::current().get());
ASSERT_EQ(
sync_file_system::SYNC_STATUS_OK,
diff --git a/chrome/browser/sync_file_system/syncable_file_system_util.cc b/chrome/browser/sync_file_system/syncable_file_system_util.cc
index d4338e8..a6b2550 100644
--- a/chrome/browser/sync_file_system/syncable_file_system_util.cc
+++ b/chrome/browser/sync_file_system/syncable_file_system_util.cc
@@ -28,11 +28,6 @@ const char kEnableSyncFSDirectoryOperation[] =
const char kSyncableMountName[] = "syncfs";
const char kSyncableMountNameForInternalSync[] = "syncfs-internal";
-const base::FilePath::CharType kSyncFileSystemDir[] =
- FILE_PATH_LITERAL("Sync FileSystem");
-const base::FilePath::CharType kSyncFileSystemDirDev[] =
- FILE_PATH_LITERAL("Sync FileSystem Dev");
-
bool is_directory_operation_enabled = false;
} // namespace
@@ -112,12 +107,6 @@ bool IsSyncFSDirectoryOperationEnabled() {
kEnableSyncFSDirectoryOperation);
}
-base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir) {
- return profile_base_dir.Append(
- IsSyncFSDirectoryOperationEnabled() ? kSyncFileSystemDirDev
- : kSyncFileSystemDir);
-}
-
ScopedEnableSyncFSDirectoryOperation::ScopedEnableSyncFSDirectoryOperation() {
was_enabled_ = IsSyncFSDirectoryOperationEnabled();
SetEnableSyncFSDirectoryOperation(true);
diff --git a/chrome/browser/sync_file_system/syncable_file_system_util.h b/chrome/browser/sync_file_system/syncable_file_system_util.h
index 3cce3ad..408f72c 100644
--- a/chrome/browser/sync_file_system/syncable_file_system_util.h
+++ b/chrome/browser/sync_file_system/syncable_file_system_util.h
@@ -85,9 +85,6 @@ void SetEnableSyncFSDirectoryOperation(bool flag);
// away when we fully support directory operations. (http://crbug.com/161442)
bool IsSyncFSDirectoryOperationEnabled();
-// Returns SyncFileSystem sub-directory path.
-base::FilePath GetSyncFileSystemDir(const base::FilePath& profile_base_dir);
-
// Enables directory operation for syncable filesystems temporarily for testing.
class ScopedEnableSyncFSDirectoryOperation {
public:
diff --git a/chrome/browser/sync_file_system/syncable_file_system_util_unittest.cc b/chrome/browser/sync_file_system/syncable_file_system_util_unittest.cc
index 31bc00d..3cb27ec 100644
--- a/chrome/browser/sync_file_system/syncable_file_system_util_unittest.cc
+++ b/chrome/browser/sync_file_system/syncable_file_system_util_unittest.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
-#include "base/files/scoped_temp_dir.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"