| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/engine/directory_update_handler.h" | 5 #include "sync/engine/directory_update_handler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> |
| 9 #include <set> | 10 #include <set> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <utility> | 12 #include <utility> |
| 12 | 13 |
| 13 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/ptr_util.h" |
| 16 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 17 #include "sync/engine/syncer_proto_util.h" | 18 #include "sync/engine/syncer_proto_util.h" |
| 18 #include "sync/internal_api/public/base/attachment_id_proto.h" | 19 #include "sync/internal_api/public/base/attachment_id_proto.h" |
| 19 #include "sync/internal_api/public/base/model_type.h" | 20 #include "sync/internal_api/public/base/model_type.h" |
| 20 #include "sync/internal_api/public/test/test_entry_factory.h" | 21 #include "sync/internal_api/public/test/test_entry_factory.h" |
| 21 #include "sync/protocol/sync.pb.h" | 22 #include "sync/protocol/sync.pb.h" |
| 22 #include "sync/sessions/directory_type_debug_info_emitter.h" | 23 #include "sync/sessions/directory_type_debug_info_emitter.h" |
| 23 #include "sync/sessions/status_controller.h" | 24 #include "sync/sessions/status_controller.h" |
| 24 #include "sync/syncable/directory.h" | 25 #include "sync/syncable/directory.h" |
| 25 #include "sync/syncable/entry.h" | 26 #include "sync/syncable/entry.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 56 | 57 |
| 57 void SetUp() override { dir_maker_.SetUp(); } | 58 void SetUp() override { dir_maker_.SetUp(); } |
| 58 | 59 |
| 59 void TearDown() override { dir_maker_.TearDown(); } | 60 void TearDown() override { dir_maker_.TearDown(); } |
| 60 | 61 |
| 61 syncable::Directory* dir() { | 62 syncable::Directory* dir() { |
| 62 return dir_maker_.directory(); | 63 return dir_maker_.directory(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 protected: | 66 protected: |
| 66 scoped_ptr<sync_pb::SyncEntity> CreateUpdate( | 67 std::unique_ptr<sync_pb::SyncEntity> CreateUpdate(const std::string& id, |
| 67 const std::string& id, | 68 const std::string& parent, |
| 68 const std::string& parent, | 69 const ModelType& type); |
| 69 const ModelType& type); | |
| 70 | 70 |
| 71 // This exists mostly to give tests access to the protected member function. | 71 // This exists mostly to give tests access to the protected member function. |
| 72 // Warning: This takes the syncable directory lock. | 72 // Warning: This takes the syncable directory lock. |
| 73 void UpdateSyncEntities( | 73 void UpdateSyncEntities( |
| 74 DirectoryUpdateHandler* handler, | 74 DirectoryUpdateHandler* handler, |
| 75 const SyncEntityList& applicable_updates, | 75 const SyncEntityList& applicable_updates, |
| 76 sessions::StatusController* status); | 76 sessions::StatusController* status); |
| 77 | 77 |
| 78 // Another function to access private member functions. | 78 // Another function to access private member functions. |
| 79 void UpdateProgressMarkers( | 79 void UpdateProgressMarkers( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 98 protected: | 98 protected: |
| 99 // Used in the construction of DirectoryTypeDebugInfoEmitters. | 99 // Used in the construction of DirectoryTypeDebugInfoEmitters. |
| 100 base::ObserverList<TypeDebugInfoObserver> type_observers_; | 100 base::ObserverList<TypeDebugInfoObserver> type_observers_; |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 base::MessageLoop loop_; // Needed to initialize the directory. | 103 base::MessageLoop loop_; // Needed to initialize the directory. |
| 104 TestDirectorySetterUpper dir_maker_; | 104 TestDirectorySetterUpper dir_maker_; |
| 105 scoped_refptr<FakeModelWorker> ui_worker_; | 105 scoped_refptr<FakeModelWorker> ui_worker_; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 scoped_ptr<sync_pb::SyncEntity> | 108 std::unique_ptr<sync_pb::SyncEntity> |
| 109 DirectoryUpdateHandlerProcessUpdateTest::CreateUpdate( | 109 DirectoryUpdateHandlerProcessUpdateTest::CreateUpdate(const std::string& id, |
| 110 const std::string& id, | 110 const std::string& parent, |
| 111 const std::string& parent, | 111 const ModelType& type) { |
| 112 const ModelType& type) { | 112 std::unique_ptr<sync_pb::SyncEntity> e(new sync_pb::SyncEntity()); |
| 113 scoped_ptr<sync_pb::SyncEntity> e(new sync_pb::SyncEntity()); | |
| 114 e->set_id_string(id); | 113 e->set_id_string(id); |
| 115 e->set_parent_id_string(parent); | 114 e->set_parent_id_string(parent); |
| 116 e->set_non_unique_name(id); | 115 e->set_non_unique_name(id); |
| 117 e->set_name(id); | 116 e->set_name(id); |
| 118 e->set_version(kDefaultVersion); | 117 e->set_version(kDefaultVersion); |
| 119 AddDefaultFieldValue(type, e->mutable_specifics()); | 118 AddDefaultFieldValue(type, e->mutable_specifics()); |
| 120 return e; | 119 return e; |
| 121 } | 120 } |
| 122 | 121 |
| 123 void DirectoryUpdateHandlerProcessUpdateTest::UpdateSyncEntities( | 122 void DirectoryUpdateHandlerProcessUpdateTest::UpdateSyncEntities( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 139 // Test that the bookmark tag is set on newly downloaded items. | 138 // Test that the bookmark tag is set on newly downloaded items. |
| 140 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) { | 139 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, NewBookmarkTag) { |
| 141 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); | 140 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); |
| 142 DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker(), &emitter); | 141 DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker(), &emitter); |
| 143 sync_pb::GetUpdatesResponse gu_response; | 142 sync_pb::GetUpdatesResponse gu_response; |
| 144 sessions::StatusController status; | 143 sessions::StatusController status; |
| 145 | 144 |
| 146 // Add a bookmark item to the update message. | 145 // Add a bookmark item to the update message. |
| 147 std::string root = Id::GetRoot().GetServerId(); | 146 std::string root = Id::GetRoot().GetServerId(); |
| 148 Id server_id = Id::CreateFromServerId("b1"); | 147 Id server_id = Id::CreateFromServerId("b1"); |
| 149 scoped_ptr<sync_pb::SyncEntity> e = | 148 std::unique_ptr<sync_pb::SyncEntity> e = |
| 150 CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS); | 149 CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS); |
| 151 e->set_originator_cache_guid( | 150 e->set_originator_cache_guid( |
| 152 std::string(kCacheGuid, arraysize(kCacheGuid)-1)); | 151 std::string(kCacheGuid, arraysize(kCacheGuid)-1)); |
| 153 Id client_id = Id::CreateFromClientString("-2"); | 152 Id client_id = Id::CreateFromClientString("-2"); |
| 154 e->set_originator_client_item_id(client_id.GetServerId()); | 153 e->set_originator_client_item_id(client_id.GetServerId()); |
| 155 e->set_position_in_parent(0); | 154 e->set_position_in_parent(0); |
| 156 | 155 |
| 157 // Add it to the applicable updates list. | 156 // Add it to the applicable updates list. |
| 158 SyncEntityList bookmark_updates; | 157 SyncEntityList bookmark_updates; |
| 159 bookmark_updates.push_back(e.get()); | 158 bookmark_updates.push_back(e.get()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 178 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, | 177 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, |
| 179 ReceiveServerCreatedBookmarkFolders) { | 178 ReceiveServerCreatedBookmarkFolders) { |
| 180 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); | 179 DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_); |
| 181 DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker(), &emitter); | 180 DirectoryUpdateHandler handler(dir(), BOOKMARKS, ui_worker(), &emitter); |
| 182 sync_pb::GetUpdatesResponse gu_response; | 181 sync_pb::GetUpdatesResponse gu_response; |
| 183 sessions::StatusController status; | 182 sessions::StatusController status; |
| 184 | 183 |
| 185 // Create an update that mimics the bookmark root. | 184 // Create an update that mimics the bookmark root. |
| 186 Id server_id = Id::CreateFromServerId("xyz"); | 185 Id server_id = Id::CreateFromServerId("xyz"); |
| 187 std::string root = Id::GetRoot().GetServerId(); | 186 std::string root = Id::GetRoot().GetServerId(); |
| 188 scoped_ptr<sync_pb::SyncEntity> e = | 187 std::unique_ptr<sync_pb::SyncEntity> e = |
| 189 CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS); | 188 CreateUpdate(SyncableIdToProto(server_id), root, BOOKMARKS); |
| 190 e->set_server_defined_unique_tag("google_chrome_bookmarks"); | 189 e->set_server_defined_unique_tag("google_chrome_bookmarks"); |
| 191 e->set_folder(true); | 190 e->set_folder(true); |
| 192 | 191 |
| 193 // Add it to the applicable updates list. | 192 // Add it to the applicable updates list. |
| 194 SyncEntityList bookmark_updates; | 193 SyncEntityList bookmark_updates; |
| 195 bookmark_updates.push_back(e.get()); | 194 bookmark_updates.push_back(e.get()); |
| 196 | 195 |
| 197 EXPECT_FALSE(SyncerProtoUtil::ShouldMaintainPosition(*e)); | 196 EXPECT_FALSE(SyncerProtoUtil::ShouldMaintainPosition(*e)); |
| 198 | 197 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 212 | 211 |
| 213 // Test the receipt of a non-bookmark item. | 212 // Test the receipt of a non-bookmark item. |
| 214 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ReceiveNonBookmarkItem) { | 213 TEST_F(DirectoryUpdateHandlerProcessUpdateTest, ReceiveNonBookmarkItem) { |
| 215 DirectoryTypeDebugInfoEmitter emitter(AUTOFILL, &type_observers_); | 214 DirectoryTypeDebugInfoEmitter emitter(AUTOFILL, &type_observers_); |
| 216 DirectoryUpdateHandler handler(dir(), AUTOFILL, ui_worker(), &emitter); | 215 DirectoryUpdateHandler handler(dir(), AUTOFILL, ui_worker(), &emitter); |
| 217 sync_pb::GetUpdatesResponse gu_response; | 216 sync_pb::GetUpdatesResponse gu_response; |
| 218 sessions::StatusController status; | 217 sessions::StatusController status; |
| 219 | 218 |
| 220 std::string root = Id::GetRoot().GetServerId(); | 219 std::string root = Id::GetRoot().GetServerId(); |
| 221 Id server_id = Id::CreateFromServerId("xyz"); | 220 Id server_id = Id::CreateFromServerId("xyz"); |
| 222 scoped_ptr<sync_pb::SyncEntity> e = | 221 std::unique_ptr<sync_pb::SyncEntity> e = |
| 223 CreateUpdate(SyncableIdToProto(server_id), root, AUTOFILL); | 222 CreateUpdate(SyncableIdToProto(server_id), root, AUTOFILL); |
| 224 e->set_server_defined_unique_tag("9PGRuKdX5sHyGMB17CvYTXuC43I="); | 223 e->set_server_defined_unique_tag("9PGRuKdX5sHyGMB17CvYTXuC43I="); |
| 225 | 224 |
| 226 // Add it to the applicable updates list. | 225 // Add it to the applicable updates list. |
| 227 SyncEntityList autofill_updates; | 226 SyncEntityList autofill_updates; |
| 228 autofill_updates.push_back(e.get()); | 227 autofill_updates.push_back(e.get()); |
| 229 | 228 |
| 230 EXPECT_FALSE(SyncerProtoUtil::ShouldMaintainPosition(*e)); | 229 EXPECT_FALSE(SyncerProtoUtil::ShouldMaintainPosition(*e)); |
| 231 | 230 |
| 232 // Process it. | 231 // Process it. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); | 270 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); |
| 272 progress.set_token("token"); | 271 progress.set_token("token"); |
| 273 progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 10); | 272 progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 10); |
| 274 | 273 |
| 275 sync_pb::DataTypeContext context; | 274 sync_pb::DataTypeContext context; |
| 276 context.set_data_type_id( | 275 context.set_data_type_id( |
| 277 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); | 276 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); |
| 278 context.set_context("context"); | 277 context.set_context("context"); |
| 279 context.set_version(1); | 278 context.set_version(1); |
| 280 | 279 |
| 281 scoped_ptr<sync_pb::SyncEntity> e1 = | 280 std::unique_ptr<sync_pb::SyncEntity> e1 = |
| 282 CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e1")), "", | 281 CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e1")), "", |
| 283 SYNCED_NOTIFICATIONS); | 282 SYNCED_NOTIFICATIONS); |
| 284 | 283 |
| 285 scoped_ptr<sync_pb::SyncEntity> e2 = | 284 std::unique_ptr<sync_pb::SyncEntity> e2 = |
| 286 CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e2")), "", | 285 CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e2")), "", |
| 287 SYNCED_NOTIFICATIONS); | 286 SYNCED_NOTIFICATIONS); |
| 288 e2->set_version(kDefaultVersion + 100); | 287 e2->set_version(kDefaultVersion + 100); |
| 289 | 288 |
| 290 // Add to the applicable updates list. | 289 // Add to the applicable updates list. |
| 291 SyncEntityList updates; | 290 SyncEntityList updates; |
| 292 updates.push_back(e1.get()); | 291 updates.push_back(e1.get()); |
| 293 updates.push_back(e2.get()); | 292 updates.push_back(e2.get()); |
| 294 | 293 |
| 295 // Process and apply updates. | 294 // Process and apply updates. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 323 sync_pb::DataTypeProgressMarker progress; | 322 sync_pb::DataTypeProgressMarker progress; |
| 324 progress.set_data_type_id( | 323 progress.set_data_type_id( |
| 325 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); | 324 GetSpecificsFieldNumberFromModelType(SYNCED_NOTIFICATIONS)); |
| 326 progress.set_token("token"); | 325 progress.set_token("token"); |
| 327 | 326 |
| 328 sync_pb::DataTypeContext old_context; | 327 sync_pb::DataTypeContext old_context; |
| 329 old_context.set_version(1); | 328 old_context.set_version(1); |
| 330 old_context.set_context("data"); | 329 old_context.set_context("data"); |
| 331 old_context.set_data_type_id(field_number); | 330 old_context.set_data_type_id(field_number); |
| 332 | 331 |
| 333 scoped_ptr<sync_pb::SyncEntity> e1 = | 332 std::unique_ptr<sync_pb::SyncEntity> e1 = |
| 334 CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e1")), "", | 333 CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e1")), "", |
| 335 SYNCED_NOTIFICATIONS); | 334 SYNCED_NOTIFICATIONS); |
| 336 | 335 |
| 337 SyncEntityList updates; | 336 SyncEntityList updates; |
| 338 updates.push_back(e1.get()); | 337 updates.push_back(e1.get()); |
| 339 | 338 |
| 340 // The first response should be processed fine. | 339 // The first response should be processed fine. |
| 341 EXPECT_EQ(SYNCER_OK, | 340 EXPECT_EQ(SYNCER_OK, |
| 342 handler.ProcessGetUpdatesResponse( | 341 handler.ProcessGetUpdatesResponse( |
| 343 progress, old_context, updates, &status)); | 342 progress, old_context, updates, &status)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 354 trans.directory()->GetDataTypeContext( | 353 trans.directory()->GetDataTypeContext( |
| 355 &trans, SYNCED_NOTIFICATIONS, &dir_context); | 354 &trans, SYNCED_NOTIFICATIONS, &dir_context); |
| 356 EXPECT_EQ(old_context.SerializeAsString(), dir_context.SerializeAsString()); | 355 EXPECT_EQ(old_context.SerializeAsString(), dir_context.SerializeAsString()); |
| 357 } | 356 } |
| 358 | 357 |
| 359 sync_pb::DataTypeContext new_context; | 358 sync_pb::DataTypeContext new_context; |
| 360 new_context.set_version(0); | 359 new_context.set_version(0); |
| 361 new_context.set_context("old"); | 360 new_context.set_context("old"); |
| 362 new_context.set_data_type_id(field_number); | 361 new_context.set_data_type_id(field_number); |
| 363 | 362 |
| 364 scoped_ptr<sync_pb::SyncEntity> e2 = | 363 std::unique_ptr<sync_pb::SyncEntity> e2 = |
| 365 CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e2")), "", | 364 CreateUpdate(SyncableIdToProto(Id::CreateFromServerId("e2")), "", |
| 366 SYNCED_NOTIFICATIONS); | 365 SYNCED_NOTIFICATIONS); |
| 367 updates.clear(); | 366 updates.clear(); |
| 368 updates.push_back(e2.get()); | 367 updates.push_back(e2.get()); |
| 369 | 368 |
| 370 // The second response, with an old context version, should result in an | 369 // The second response, with an old context version, should result in an |
| 371 // error and the updates should be dropped. | 370 // error and the updates should be dropped. |
| 372 EXPECT_EQ(DATATYPE_TRIGGERED_RETRY, | 371 EXPECT_EQ(DATATYPE_TRIGGERED_RETRY, |
| 373 handler.ProcessGetUpdatesResponse( | 372 handler.ProcessGetUpdatesResponse( |
| 374 progress, new_context, updates, &status)); | 373 progress, new_context, updates, &status)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 396 sync_pb::DataTypeProgressMarker progress; | 395 sync_pb::DataTypeProgressMarker progress; |
| 397 progress.set_data_type_id(GetSpecificsFieldNumberFromModelType(ARTICLES)); | 396 progress.set_data_type_id(GetSpecificsFieldNumberFromModelType(ARTICLES)); |
| 398 progress.set_token("token"); | 397 progress.set_token("token"); |
| 399 progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 10); | 398 progress.mutable_gc_directive()->set_version_watermark(kDefaultVersion + 10); |
| 400 | 399 |
| 401 sync_pb::DataTypeContext context; | 400 sync_pb::DataTypeContext context; |
| 402 context.set_data_type_id(GetSpecificsFieldNumberFromModelType(ARTICLES)); | 401 context.set_data_type_id(GetSpecificsFieldNumberFromModelType(ARTICLES)); |
| 403 context.set_context("context"); | 402 context.set_context("context"); |
| 404 context.set_version(1); | 403 context.set_version(1); |
| 405 | 404 |
| 406 scoped_ptr<sync_pb::SyncEntity> e1 = CreateUpdate( | 405 std::unique_ptr<sync_pb::SyncEntity> e1 = CreateUpdate( |
| 407 SyncableIdToProto(Id::CreateFromServerId("e1")), "", ARTICLES); | 406 SyncableIdToProto(Id::CreateFromServerId("e1")), "", ARTICLES); |
| 408 sync_pb::AttachmentIdProto* attachment_id = e1->add_attachment_id(); | 407 sync_pb::AttachmentIdProto* attachment_id = e1->add_attachment_id(); |
| 409 *attachment_id = CreateAttachmentIdProto(0, 0); | 408 *attachment_id = CreateAttachmentIdProto(0, 0); |
| 410 | 409 |
| 411 SyncEntityList updates; | 410 SyncEntityList updates; |
| 412 updates.push_back(e1.get()); | 411 updates.push_back(e1.get()); |
| 413 | 412 |
| 414 // Process and apply updates. | 413 // Process and apply updates. |
| 415 EXPECT_EQ( | 414 EXPECT_EQ( |
| 416 SYNCER_OK, | 415 SYNCER_OK, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 bookmarks_emitter_(BOOKMARKS, &type_observers_), | 461 bookmarks_emitter_(BOOKMARKS, &type_observers_), |
| 463 passwords_emitter_(PASSWORDS, &type_observers_), | 462 passwords_emitter_(PASSWORDS, &type_observers_), |
| 464 articles_emitter_(ARTICLES, &type_observers_) {} | 463 articles_emitter_(ARTICLES, &type_observers_) {} |
| 465 | 464 |
| 466 void SetUp() override { | 465 void SetUp() override { |
| 467 dir_maker_.SetUp(); | 466 dir_maker_.SetUp(); |
| 468 entry_factory_.reset(new TestEntryFactory(directory())); | 467 entry_factory_.reset(new TestEntryFactory(directory())); |
| 469 | 468 |
| 470 update_handler_map_.insert(std::make_pair( | 469 update_handler_map_.insert(std::make_pair( |
| 471 BOOKMARKS, | 470 BOOKMARKS, |
| 472 make_scoped_ptr(new DirectoryUpdateHandler( | 471 base::WrapUnique(new DirectoryUpdateHandler( |
| 473 directory(), BOOKMARKS, ui_worker_, &bookmarks_emitter_)))); | 472 directory(), BOOKMARKS, ui_worker_, &bookmarks_emitter_)))); |
| 474 update_handler_map_.insert(std::make_pair( | 473 update_handler_map_.insert(std::make_pair( |
| 475 PASSWORDS, | 474 PASSWORDS, |
| 476 make_scoped_ptr(new DirectoryUpdateHandler( | 475 base::WrapUnique(new DirectoryUpdateHandler( |
| 477 directory(), PASSWORDS, password_worker_, &passwords_emitter_)))); | 476 directory(), PASSWORDS, password_worker_, &passwords_emitter_)))); |
| 478 update_handler_map_.insert(std::make_pair( | 477 update_handler_map_.insert(std::make_pair( |
| 479 ARTICLES, make_scoped_ptr(new DirectoryUpdateHandler( | 478 ARTICLES, base::WrapUnique(new DirectoryUpdateHandler( |
| 480 directory(), ARTICLES, ui_worker_, &articles_emitter_)))); | 479 directory(), ARTICLES, ui_worker_, &articles_emitter_)))); |
| 481 } | 480 } |
| 482 | 481 |
| 483 void TearDown() override { dir_maker_.TearDown(); } | 482 void TearDown() override { dir_maker_.TearDown(); } |
| 484 | 483 |
| 485 const UpdateCounters& GetBookmarksUpdateCounters() { | 484 const UpdateCounters& GetBookmarksUpdateCounters() { |
| 486 return bookmarks_emitter_.GetUpdateCounters(); | 485 return bookmarks_emitter_.GetUpdateCounters(); |
| 487 } | 486 } |
| 488 | 487 |
| 489 const UpdateCounters& GetPasswordsUpdateCounters() { | 488 const UpdateCounters& GetPasswordsUpdateCounters() { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 511 return entry_factory_.get(); | 510 return entry_factory_.get(); |
| 512 } | 511 } |
| 513 | 512 |
| 514 syncable::Directory* directory() { | 513 syncable::Directory* directory() { |
| 515 return dir_maker_.directory(); | 514 return dir_maker_.directory(); |
| 516 } | 515 } |
| 517 | 516 |
| 518 private: | 517 private: |
| 519 base::MessageLoop loop_; // Needed to initialize the directory. | 518 base::MessageLoop loop_; // Needed to initialize the directory. |
| 520 TestDirectorySetterUpper dir_maker_; | 519 TestDirectorySetterUpper dir_maker_; |
| 521 scoped_ptr<TestEntryFactory> entry_factory_; | 520 std::unique_ptr<TestEntryFactory> entry_factory_; |
| 522 | 521 |
| 523 scoped_refptr<FakeModelWorker> ui_worker_; | 522 scoped_refptr<FakeModelWorker> ui_worker_; |
| 524 scoped_refptr<FakeModelWorker> password_worker_; | 523 scoped_refptr<FakeModelWorker> password_worker_; |
| 525 scoped_refptr<FakeModelWorker> passive_worker_; | 524 scoped_refptr<FakeModelWorker> passive_worker_; |
| 526 | 525 |
| 527 base::ObserverList<TypeDebugInfoObserver> type_observers_; | 526 base::ObserverList<TypeDebugInfoObserver> type_observers_; |
| 528 DirectoryTypeDebugInfoEmitter bookmarks_emitter_; | 527 DirectoryTypeDebugInfoEmitter bookmarks_emitter_; |
| 529 DirectoryTypeDebugInfoEmitter passwords_emitter_; | 528 DirectoryTypeDebugInfoEmitter passwords_emitter_; |
| 530 DirectoryTypeDebugInfoEmitter articles_emitter_; | 529 DirectoryTypeDebugInfoEmitter articles_emitter_; |
| 531 | 530 |
| 532 std::map<ModelType, scoped_ptr<UpdateHandler>> update_handler_map_; | 531 std::map<ModelType, std::unique_ptr<UpdateHandler>> update_handler_map_; |
| 533 }; | 532 }; |
| 534 | 533 |
| 535 namespace { | 534 namespace { |
| 536 sync_pb::EntitySpecifics DefaultBookmarkSpecifics() { | 535 sync_pb::EntitySpecifics DefaultBookmarkSpecifics() { |
| 537 sync_pb::EntitySpecifics result; | 536 sync_pb::EntitySpecifics result; |
| 538 AddDefaultFieldValue(BOOKMARKS, &result); | 537 AddDefaultFieldValue(BOOKMARKS, &result); |
| 539 return result; | 538 return result; |
| 540 } | 539 } |
| 541 } // namespace | 540 } // namespace |
| 542 | 541 |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 const UpdateCounters& counters = GetArticlesUpdateCounters(); | 1149 const UpdateCounters& counters = GetArticlesUpdateCounters(); |
| 1151 EXPECT_EQ(1, counters.num_updates_applied); | 1150 EXPECT_EQ(1, counters.num_updates_applied); |
| 1152 EXPECT_EQ(1, counters.num_local_overwrites); | 1151 EXPECT_EQ(1, counters.num_local_overwrites); |
| 1153 EXPECT_EQ(0, counters.num_server_overwrites); | 1152 EXPECT_EQ(0, counters.num_server_overwrites); |
| 1154 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); | 1153 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); |
| 1155 EXPECT_EQ(server_metadata.SerializeAsString(), | 1154 EXPECT_EQ(server_metadata.SerializeAsString(), |
| 1156 local_metadata.SerializeAsString()); | 1155 local_metadata.SerializeAsString()); |
| 1157 } | 1156 } |
| 1158 | 1157 |
| 1159 } // namespace syncer | 1158 } // namespace syncer |
| OLD | NEW |