summaryrefslogtreecommitdiffstats
path: root/sync/engine
diff options
context:
space:
mode:
authorpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-20 11:27:34 +0000
committerpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-20 11:27:34 +0000
commit83be0c3320ae4612132bc48008cefc3559283d70 (patch)
treeaa496d795c9a56a4f3da021e373a105709c5abe4 /sync/engine
parent5e36170e155de91b7b8808d38645059e2518d6ad (diff)
downloadchromium_src-83be0c3320ae4612132bc48008cefc3559283d70.zip
chromium_src-83be0c3320ae4612132bc48008cefc3559283d70.tar.gz
chromium_src-83be0c3320ae4612132bc48008cefc3559283d70.tar.bz2
Revert of sync: Add NonBlockingSyncTypeProcessorCore (https://codereview.chromium.org/192953008/)
Reason for revert: Best guess that this broke SyncFileSystemApiTest.WriteFileThenGetUsage SyncFileSystemApiTest.GetFileStatuses MediaGalleriesPlatformAppBrowserTest.MediaGalleriesCopyTo on XP Tests(1). Original issue's description: > sync: Add NonBlockingSyncTypeProcessorCore > > Adds the class for handling sync updates and commits on the sync thread. > The current implementation is mostly a bunch of stubs. > > In the future, this will be hooked up to a NonBlockingSyncTypeProcessor > that lives on the model type's thread. These two classes will > collaborate to implement the non-blocking sync system. > > This CL also adds some code to the ModelTypeRegistry and > SyncSessionContext to prepare for managing these > NonBlockingSyncTypeProcessor objects. This new code is used only in > tests. > > BUG=351005 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=258035 TBR=zea@chromium.org,rlarocque@chromium.org NOTREECHECKS=true NOTRY=true BUG=351005 Review URL: https://codereview.chromium.org/204913004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine')
-rw-r--r--sync/engine/commit_contributor.h3
-rw-r--r--sync/engine/non_blocking_type_processor_core.cc72
-rw-r--r--sync/engine/non_blocking_type_processor_core.h73
-rw-r--r--sync/engine/sync_scheduler_impl.cc10
-rw-r--r--sync/engine/syncer.cc2
-rw-r--r--sync/engine/syncer_unittest.cc10
6 files changed, 12 insertions, 158 deletions
diff --git a/sync/engine/commit_contributor.h b/sync/engine/commit_contributor.h
index 5e9d156..2d190af 100644
--- a/sync/engine/commit_contributor.h
+++ b/sync/engine/commit_contributor.h
@@ -8,7 +8,6 @@
#include <cstddef>
#include "base/memory/scoped_ptr.h"
-#include "sync/base/sync_export.h"
namespace syncer {
@@ -22,7 +21,7 @@ class Directory;
//
// When asked, it can return CommitContribution objects that contain a set of
// items to be committed from this source.
-class SYNC_EXPORT_PRIVATE CommitContributor {
+class CommitContributor {
public:
CommitContributor();
virtual ~CommitContributor() = 0;
diff --git a/sync/engine/non_blocking_type_processor_core.cc b/sync/engine/non_blocking_type_processor_core.cc
deleted file mode 100644
index 6d6abc4..0000000
--- a/sync/engine/non_blocking_type_processor_core.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/engine/non_blocking_type_processor_core.h"
-
-#include "base/logging.h"
-#include "sync/engine/commit_contribution.h"
-
-namespace syncer {
-
-NonBlockingTypeProcessorCore::NonBlockingTypeProcessorCore(
- ModelType type) : type_(type), weak_ptr_factory_(this) {
- progress_marker_.set_data_type_id(GetSpecificsFieldNumberFromModelType(type));
-}
-
-NonBlockingTypeProcessorCore::~NonBlockingTypeProcessorCore() {
-}
-
-ModelType NonBlockingTypeProcessorCore::GetModelType() const {
- DCHECK(CalledOnValidThread());
- return type_;
-}
-
-// UpdateHandler implementation.
-void NonBlockingTypeProcessorCore::GetDownloadProgress(
- sync_pb::DataTypeProgressMarker* progress_marker) const {
- DCHECK(CalledOnValidThread());
- // TODO(rlarocque): Implement this properly. crbug.com/351005.
- VLOG(1) << "Getting progress for: " << ModelTypeToString(type_);
- *progress_marker = progress_marker_;
-}
-
-void NonBlockingTypeProcessorCore::ProcessGetUpdatesResponse(
- const sync_pb::DataTypeProgressMarker& progress_marker,
- const SyncEntityList& applicable_updates,
- sessions::StatusController* status) {
- DCHECK(CalledOnValidThread());
- // TODO(rlarocque): Implement this properly. crbug.com/351005.
- VLOG(1) << "Processing updates response for: " << ModelTypeToString(type_);
- progress_marker_ = progress_marker;
-}
-
-void NonBlockingTypeProcessorCore::ApplyUpdates(
- sessions::StatusController* status) {
- DCHECK(CalledOnValidThread());
- // TODO(rlarocque): Implement this properly. crbug.com/351005.
- VLOG(1) << "Applying updates for: " << ModelTypeToString(type_);
-}
-
-void NonBlockingTypeProcessorCore::PassiveApplyUpdates(
- sessions::StatusController* status) {
- NOTREACHED()
- << "Non-blocking types should never apply updates on sync thread. "
- << "ModelType is: " << ModelTypeToString(type_);
-}
-
-// CommitContributor implementation.
-scoped_ptr<CommitContribution>
-NonBlockingTypeProcessorCore::GetContribution(size_t max_entries) {
- DCHECK(CalledOnValidThread());
- // TODO(rlarocque): Implement this properly. crbug.com/351005.
- VLOG(1) << "Getting commit contribution for: " << ModelTypeToString(type_);
- return scoped_ptr<CommitContribution>();
-}
-
-base::WeakPtr<NonBlockingTypeProcessorCore>
-NonBlockingTypeProcessorCore::AsWeakPtr() {
- return weak_ptr_factory_.GetWeakPtr();
-}
-
-} // namespace syncer
diff --git a/sync/engine/non_blocking_type_processor_core.h b/sync/engine/non_blocking_type_processor_core.h
deleted file mode 100644
index 028bb3a..0000000
--- a/sync/engine/non_blocking_type_processor_core.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_CORE_H_
-#define SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_CORE_H_
-
-#include "base/memory/weak_ptr.h"
-#include "base/threading/non_thread_safe.h"
-#include "sync/base/sync_export.h"
-#include "sync/engine/commit_contributor.h"
-#include "sync/engine/update_handler.h"
-#include "sync/internal_api/public/base/model_type.h"
-#include "sync/protocol/sync.pb.h"
-
-namespace syncer {
-
-// A smart cache for sync types that use message passing (rather than
-// transactions and the syncable::Directory) to communicate with the sync
-// thread.
-//
-// When the non-blocking sync type wants to talk with the sync server, it will
-// send a message from its thread to this object on the sync thread. This
-// object is responsible for helping to ensure the appropriate sync server
-// communication gets scheduled and executed. The response, if any, will be
-// returned to the non-blocking sync type's thread eventually.
-//
-// This object also has a role to play in communications in the opposite
-// direction. Sometimes the sync thread will receive changes from the sync
-// server and deliver them here. This object will post this information back to
-// the appropriate component on the model type's thread.
-//
-// This object does more than just pass along messages. It understands the sync
-// protocol, and it can make decisions when it sees conflicting messages. For
-// example, if the sync server sends down an update for a sync entity that is
-// currently pending for commit, this object will detect this condition and
-// cancel the pending commit.
-class SYNC_EXPORT_PRIVATE NonBlockingTypeProcessorCore
- : public UpdateHandler,
- public CommitContributor,
- public base::NonThreadSafe {
- public:
- explicit NonBlockingTypeProcessorCore(ModelType type);
- virtual ~NonBlockingTypeProcessorCore();
-
- ModelType GetModelType() const;
-
- // UpdateHandler implementation.
- virtual void GetDownloadProgress(
- sync_pb::DataTypeProgressMarker* progress_marker) const OVERRIDE;
- virtual void ProcessGetUpdatesResponse(
- const sync_pb::DataTypeProgressMarker& progress_marker,
- const SyncEntityList& applicable_updates,
- sessions::StatusController* status) OVERRIDE;
- virtual void ApplyUpdates(sessions::StatusController* status) OVERRIDE;
- virtual void PassiveApplyUpdates(sessions::StatusController* status) OVERRIDE;
-
- // CommitContributor implementation.
- virtual scoped_ptr<CommitContribution> GetContribution(
- size_t max_entries) OVERRIDE;
-
- base::WeakPtr<NonBlockingTypeProcessorCore> AsWeakPtr();
-
- private:
- ModelType type_;
- sync_pb::DataTypeProgressMarker progress_marker_;
-
- base::WeakPtrFactory<NonBlockingTypeProcessorCore> weak_ptr_factory_;
-};
-
-} // namespace syncer
-
-#endif // SYNC_ENGINE_NON_BLOCKING_TYPE_PROCESSOR_CORE_H_
diff --git a/sync/engine/sync_scheduler_impl.cc b/sync/engine/sync_scheduler_impl.cc
index a9c6359..6ff250f 100644
--- a/sync/engine/sync_scheduler_impl.cc
+++ b/sync/engine/sync_scheduler_impl.cc
@@ -245,7 +245,7 @@ void SyncSchedulerImpl::Start(Mode mode) {
}
ModelTypeSet SyncSchedulerImpl::GetEnabledAndUnthrottledTypes() {
- ModelTypeSet enabled_types = session_context_->GetEnabledTypes();
+ ModelTypeSet enabled_types = session_context_->enabled_types();
ModelTypeSet enabled_protocol_types =
Intersection(ProtocolTypes(), enabled_types);
ModelTypeSet throttled_types = nudge_tracker_.GetThrottledTypes();
@@ -341,7 +341,7 @@ bool SyncSchedulerImpl::CanRunNudgeJobNow(JobPriority priority) {
return false;
}
- const ModelTypeSet enabled_types = session_context_->GetEnabledTypes();
+ const ModelTypeSet enabled_types = session_context_->enabled_types();
if (nudge_tracker_.GetThrottledTypes().HasAll(enabled_types)) {
SDVLOG(1) << "Not running a nudge because we're fully type throttled.";
return false;
@@ -458,7 +458,7 @@ void SyncSchedulerImpl::DoNudgeSyncSessionJob(JobPriority priority) {
DCHECK(CanRunNudgeJobNow(priority));
DVLOG(2) << "Will run normal mode sync cycle with types "
- << ModelTypeSetToString(session_context_->GetEnabledTypes());
+ << ModelTypeSetToString(session_context_->enabled_types());
scoped_ptr<SyncSession> session(SyncSession::Build(session_context_, this));
bool premature_exit = !syncer_->NormalSyncShare(
GetEnabledAndUnthrottledTypes(),
@@ -501,10 +501,10 @@ void SyncSchedulerImpl::DoConfigurationSyncSessionJob(JobPriority priority) {
}
SDVLOG(2) << "Will run configure SyncShare with types "
- << ModelTypeSetToString(session_context_->GetEnabledTypes());
+ << ModelTypeSetToString(session_context_->enabled_types());
scoped_ptr<SyncSession> session(SyncSession::Build(session_context_, this));
bool premature_exit = !syncer_->ConfigureSyncShare(
- session_context_->GetEnabledTypes(),
+ session_context_->enabled_types(),
pending_configure_params_->source,
session.get());
AdjustPolling(FORCE_RESET);
diff --git a/sync/engine/syncer.cc b/sync/engine/syncer.cc
index 508a2d9..c752510 100644
--- a/sync/engine/syncer.cc
+++ b/sync/engine/syncer.cc
@@ -168,7 +168,7 @@ SyncerError Syncer::BuildAndPostCommits(ModelTypeSet requested_types,
scoped_ptr<Commit> commit(
Commit::Init(
requested_types,
- session->context()->GetEnabledTypes(),
+ session->context()->enabled_types(),
session->context()->max_commit_batch_size(),
session->context()->account_name(),
session->context()->directory()->cache_guid(),
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
index d0a2ab4..2be9dab 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/sync/engine/syncer_unittest.cc
@@ -194,7 +194,7 @@ class SyncerTest : public testing::Test,
EXPECT_TRUE(
syncer_->NormalSyncShare(
- context_->GetEnabledTypes(),
+ context_->enabled_types(),
nudge_tracker_,
session_.get()));
}
@@ -202,7 +202,7 @@ class SyncerTest : public testing::Test,
void SyncShareConfigure() {
ResetSession();
EXPECT_TRUE(syncer_->ConfigureSyncShare(
- context_->GetEnabledTypes(),
+ context_->enabled_types(),
sync_pb::GetUpdatesCallerInfo::RECONFIGURATION,
session_.get()));
}
@@ -551,10 +551,10 @@ TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) {
// Now sync without enabling bookmarks.
mock_server_->ExpectGetUpdatesRequestTypes(
- Difference(context_->GetEnabledTypes(), ModelTypeSet(BOOKMARKS)));
+ Difference(context_->enabled_types(), ModelTypeSet(BOOKMARKS)));
ResetSession();
syncer_->NormalSyncShare(
- Difference(context_->GetEnabledTypes(), ModelTypeSet(BOOKMARKS)),
+ Difference(context_->enabled_types(), ModelTypeSet(BOOKMARKS)),
nudge_tracker_,
session_.get());
@@ -567,7 +567,7 @@ TEST_F(SyncerTest, GetCommitIdsFiltersThrottledEntries) {
}
// Sync again with bookmarks enabled.
- mock_server_->ExpectGetUpdatesRequestTypes(context_->GetEnabledTypes());
+ mock_server_->ExpectGetUpdatesRequestTypes(context_->enabled_types());
SyncShareNudge();
{
// It should have been committed.