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

Unified Diff: sync/internal_api/sync_manager.cc

Issue 10520010: Not for review: Support sync init with missing or corrupt store (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Documentation Created 8 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 side-by-side diff with in-line comments
Download patch
Index: sync/internal_api/sync_manager.cc
diff --git a/sync/internal_api/sync_manager.cc b/sync/internal_api/sync_manager.cc
index b25c88483e3f2a0a9174e07153f8b3b4635154c9..43959e3e1005fb576f32136469b2a329988055a8 100644
--- a/sync/internal_api/sync_manager.cc
+++ b/sync/internal_api/sync_manager.cc
@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
+#include "base/file_util.h"
#include "base/json/json_writer.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram.h"
@@ -195,7 +196,6 @@ class SyncManager::SyncInternal
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
HttpPostProviderFactory* post_factory,
- const browser_sync::ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<browser_sync::ModelSafeWorker*>& workers,
browser_sync::ExtensionsActivityMonitor*
extensions_activity_monitor,
@@ -739,7 +739,6 @@ bool SyncManager::Init(
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
HttpPostProviderFactory* post_factory,
- const browser_sync::ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<browser_sync::ModelSafeWorker*>& workers,
browser_sync::ExtensionsActivityMonitor* extensions_activity_monitor,
ChangeDelegate* change_delegate,
@@ -762,7 +761,6 @@ bool SyncManager::Init(
use_ssl,
blocking_task_runner,
post_factory,
- model_safe_routing_info,
workers,
extensions_activity_monitor,
change_delegate,
@@ -891,7 +889,6 @@ bool SyncManager::SyncInternal::Init(
bool use_ssl,
const scoped_refptr<base::TaskRunner>& blocking_task_runner,
HttpPostProviderFactory* post_factory,
- const browser_sync::ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<browser_sync::ModelSafeWorker*>& workers,
browser_sync::ExtensionsActivityMonitor* extensions_activity_monitor,
ChangeDelegate* change_delegate,
@@ -928,10 +925,6 @@ bool SyncManager::SyncInternal::Init(
encryptor_ = encryptor;
unrecoverable_error_handler_ = unrecoverable_error_handler;
report_unrecoverable_error_function_ = report_unrecoverable_error_function;
- share_.directory.reset(
- new syncable::Directory(encryptor_,
- unrecoverable_error_handler_,
- report_unrecoverable_error_function_));
connection_manager_.reset(new SyncAPIServerConnectionManager(
sync_server_and_path, port, use_ssl, user_agent, post_factory));
@@ -941,6 +934,8 @@ bool SyncManager::SyncInternal::Init(
connection_manager()->AddListener(this);
+ bool signed_in = SignIn(credentials);
+
// Test mode does not use a syncer context or syncer thread.
if (testing_mode_ == NON_TEST) {
// Build a SyncSessionContext and store the worker in it.
@@ -951,7 +946,6 @@ bool SyncManager::SyncInternal::Init(
session_context_.reset(new SyncSessionContext(
connection_manager_.get(),
directory(),
- model_safe_routing_info,
workers,
extensions_activity_monitor,
listeners,
@@ -961,8 +955,6 @@ bool SyncManager::SyncInternal::Init(
scheduler_.reset(new SyncScheduler(name_, session_context(), new Syncer()));
}
- bool signed_in = SignIn(credentials);
-
if (signed_in) {
if (scheduler()) {
scheduler()->Start(
@@ -988,7 +980,9 @@ bool SyncManager::SyncInternal::Init(
FOR_EACH_OBSERVER(SyncManager::Observer, observers_,
OnInitializationComplete(
MakeWeakHandle(weak_ptr_factory_.GetWeakPtr()),
- signed_in));
+ signed_in,
+ signed_in ? InitialSyncEndedTypes() :
+ syncable::ModelTypeSet()));
if (!signed_in && testing_mode_ == NON_TEST)
return false;
@@ -1148,6 +1142,10 @@ void SyncManager::SyncInternal::StartSyncingNormally(
bool SyncManager::SyncInternal::OpenDirectory() {
DCHECK(!initialized_) << "Should only happen once";
+ share_.directory.reset(
+ new syncable::Directory(encryptor_,
+ unrecoverable_error_handler_,
+ report_unrecoverable_error_function_));
// Set before Open().
change_observer_ =
@@ -1162,6 +1160,12 @@ bool SyncManager::SyncInternal::OpenDirectory() {
} else {
open_result = directory()->Open(
database_path_, username_for_share(), this, transaction_observer);
+ // If at first we don't succeed, delete the DB and try again.
+ if (open_result != syncable::OPENED) {
+ file_util::Delete(database_path_, true);
+ open_result = directory()->Open(
+ database_path_, username_for_share(), this, transaction_observer);
+ }
}
if (open_result != syncable::OPENED) {
LOG(ERROR) << "Could not open share for:" << username_for_share();
@@ -2491,20 +2495,4 @@ bool InitialSyncEndedForTypes(syncable::ModelTypeSet types,
return true;
}
-syncable::ModelTypeSet GetTypesWithEmptyProgressMarkerToken(
- syncable::ModelTypeSet types,
- sync_api::UserShare* share) {
- syncable::ModelTypeSet result;
- for (syncable::ModelTypeSet::Iterator i = types.First();
- i.Good(); i.Inc()) {
- sync_pb::DataTypeProgressMarker marker;
- share->directory->GetDownloadProgress(i.Get(), &marker);
-
- if (marker.token().empty())
- result.Put(i.Get());
-
- }
- return result;
-}
-
} // namespace sync_api

Powered by Google App Engine
This is Rietveld 408576698