Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/sync/engine_impl/sync_manager_impl.h" | 5 #include "components/sync/engine_impl/sync_manager_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | |
|
pavely
2016/10/27 23:53:39
I don't think you use CommandLine in this file.
pastarmovj
2016/11/02 13:39:25
Done.
| |
| 14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 15 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
| 16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 18 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 20 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "base/values.h" | 23 #include "base/values.h" |
| 23 #include "components/sync/base/cancelation_signal.h" | 24 #include "components/sync/base/cancelation_signal.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 39 #include "components/sync/syncable/base_node.h" | 40 #include "components/sync/syncable/base_node.h" |
| 40 #include "components/sync/syncable/directory.h" | 41 #include "components/sync/syncable/directory.h" |
| 41 #include "components/sync/syncable/entry.h" | 42 #include "components/sync/syncable/entry.h" |
| 42 #include "components/sync/syncable/in_memory_directory_backing_store.h" | 43 #include "components/sync/syncable/in_memory_directory_backing_store.h" |
| 43 #include "components/sync/syncable/on_disk_directory_backing_store.h" | 44 #include "components/sync/syncable/on_disk_directory_backing_store.h" |
| 44 #include "components/sync/syncable/read_node.h" | 45 #include "components/sync/syncable/read_node.h" |
| 45 #include "components/sync/syncable/read_transaction.h" | 46 #include "components/sync/syncable/read_transaction.h" |
| 46 #include "components/sync/syncable/write_node.h" | 47 #include "components/sync/syncable/write_node.h" |
| 47 #include "components/sync/syncable/write_transaction.h" | 48 #include "components/sync/syncable/write_transaction.h" |
| 48 | 49 |
| 50 #if defined(OS_WIN) | |
| 51 #include "components/sync/engine_impl/loopback_server/loopback_connection_manage r.h" | |
| 52 #endif | |
| 53 | |
| 49 using base::TimeDelta; | 54 using base::TimeDelta; |
| 50 using sync_pb::GetUpdatesCallerInfo; | 55 using sync_pb::GetUpdatesCallerInfo; |
| 51 | 56 |
| 52 class GURL; | 57 class GURL; |
| 53 | 58 |
| 54 namespace syncer { | 59 namespace syncer { |
| 55 | 60 |
| 56 using syncable::ImmutableWriteTransactionInfo; | 61 using syncable::ImmutableWriteTransactionInfo; |
| 57 using syncable::SPECIFICS; | 62 using syncable::SPECIFICS; |
| 58 using syncable::UNIQUE_POSITION; | 63 using syncable::UNIQUE_POSITION; |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 return; | 279 return; |
| 275 } | 280 } |
| 276 | 281 |
| 277 // Now that we have opened the Directory we can restore any previously saved | 282 // Now that we have opened the Directory we can restore any previously saved |
| 278 // nigori specifics. | 283 // nigori specifics. |
| 279 if (args->saved_nigori_state) { | 284 if (args->saved_nigori_state) { |
| 280 sync_encryption_handler_->RestoreNigori(*args->saved_nigori_state); | 285 sync_encryption_handler_->RestoreNigori(*args->saved_nigori_state); |
| 281 args->saved_nigori_state.reset(); | 286 args->saved_nigori_state.reset(); |
| 282 } | 287 } |
| 283 | 288 |
| 284 connection_manager_ = base::MakeUnique<SyncServerConnectionManager>( | 289 if (args->enable_local_sync_backend) { |
| 285 args->service_url.host() + args->service_url.path(), | 290 #if defined(OS_WIN) |
| 286 args->service_url.EffectiveIntPort(), | 291 VLOG(1) << "Running against local sync backend."; |
| 287 args->service_url.SchemeIsCryptographic(), args->post_factory.release(), | 292 connection_manager_ = base::MakeUnique<LoopbackConnectionManager>( |
| 288 args->cancelation_signal); | 293 args->cancelation_signal, args->local_sync_backend_folder); |
| 294 #else | |
| 295 NOTREACHED(); | |
| 296 #endif // defined(OS_WIN) | |
| 297 } else { | |
| 298 connection_manager_ = base::MakeUnique<SyncServerConnectionManager>( | |
| 299 args->service_url.host() + args->service_url.path(), | |
| 300 args->service_url.EffectiveIntPort(), | |
| 301 args->service_url.SchemeIsCryptographic(), args->post_factory.release(), | |
| 302 args->cancelation_signal); | |
| 303 } | |
| 289 connection_manager_->set_client_id(directory()->cache_guid()); | 304 connection_manager_->set_client_id(directory()->cache_guid()); |
| 290 connection_manager_->AddListener(this); | 305 connection_manager_->AddListener(this); |
| 291 | 306 |
| 292 std::string sync_id = directory()->cache_guid(); | 307 std::string sync_id = directory()->cache_guid(); |
| 293 | 308 |
| 294 DVLOG(1) << "Setting sync client ID: " << sync_id; | 309 DVLOG(1) << "Setting sync client ID: " << sync_id; |
| 295 allstatus_.SetSyncId(sync_id); | 310 allstatus_.SetSyncId(sync_id); |
| 296 DVLOG(1) << "Setting invalidator client ID: " << args->invalidator_client_id; | 311 DVLOG(1) << "Setting invalidator client ID: " << args->invalidator_client_id; |
| 297 allstatus_.SetInvalidatorClientId(args->invalidator_client_id); | 312 allstatus_.SetInvalidatorClientId(args->invalidator_client_id); |
| 298 | 313 |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 995 } | 1010 } |
| 996 | 1011 |
| 997 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch, | 1012 void SyncManagerImpl::OnCookieJarChanged(bool account_mismatch, |
| 998 bool empty_jar) { | 1013 bool empty_jar) { |
| 999 DCHECK(thread_checker_.CalledOnValidThread()); | 1014 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1000 cycle_context_->set_cookie_jar_mismatch(account_mismatch); | 1015 cycle_context_->set_cookie_jar_mismatch(account_mismatch); |
| 1001 cycle_context_->set_cookie_jar_empty(empty_jar); | 1016 cycle_context_->set_cookie_jar_empty(empty_jar); |
| 1002 } | 1017 } |
| 1003 | 1018 |
| 1004 } // namespace syncer | 1019 } // namespace syncer |
| OLD | NEW |