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

Side by Side Diff: chrome/browser/ui/app_list/app_list_syncable_service.cc

Issue 229233003: Fix AppListSyncableService::ModelObserver actions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/app_list/app_list_syncable_service.h" 5 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } 128 }
129 129
130 AppListSyncableService::SyncItem::~SyncItem() { 130 AppListSyncableService::SyncItem::~SyncItem() {
131 } 131 }
132 132
133 // AppListSyncableService::ModelObserver 133 // AppListSyncableService::ModelObserver
134 134
135 class AppListSyncableService::ModelObserver : public AppListModelObserver { 135 class AppListSyncableService::ModelObserver : public AppListModelObserver {
136 public: 136 public:
137 explicit ModelObserver(AppListSyncableService* owner) 137 explicit ModelObserver(AppListSyncableService* owner)
138 : owner_(owner) { 138 : owner_(owner),
139 adding_item_(NULL) {
139 DVLOG(2) << owner_ << ": ModelObserver Added"; 140 DVLOG(2) << owner_ << ": ModelObserver Added";
140 owner_->model()->AddObserver(this); 141 owner_->model()->AddObserver(this);
141 } 142 }
142 143
143 virtual ~ModelObserver() { 144 virtual ~ModelObserver() {
144 owner_->model()->RemoveObserver(this); 145 owner_->model()->RemoveObserver(this);
145 DVLOG(2) << owner_ << ": ModelObserver Removed"; 146 DVLOG(2) << owner_ << ": ModelObserver Removed";
146 } 147 }
147 148
148 private: 149 private:
149 // AppListModelObserver 150 // AppListModelObserver
150 virtual void OnAppListItemAdded(AppListItem* item) OVERRIDE { 151 virtual void OnAppListItemAdded(AppListItem* item) OVERRIDE {
151 DVLOG(2) << owner_ << " OnAppListItemAdded: " << item->ToDebugString(); 152 DCHECK(!adding_item_);
153 adding_item_ = item; // Ignore updates while adding an item.
154 VLOG(2) << owner_ << " OnAppListItemAdded: " << item->ToDebugString();
152 owner_->AddOrUpdateFromSyncItem(item); 155 owner_->AddOrUpdateFromSyncItem(item);
156 adding_item_ = NULL;
153 } 157 }
154 158
155 virtual void OnAppListItemWillBeDeleted(AppListItem* item) OVERRIDE { 159 virtual void OnAppListItemWillBeDeleted(AppListItem* item) OVERRIDE {
156 DVLOG(2) << owner_ << " OnAppListItemDeleted: " << item->ToDebugString(); 160 DCHECK(!adding_item_);
161 VLOG(2) << owner_ << " OnAppListItemDeleted: " << item->ToDebugString();
162 // Don't sync folder removal in case the folder still exists on another
163 // device (e.g. with device specific items in it). Empty folders will be
164 // deleted when the last item is removed (in PruneEmptySyncFolders()).
165 if (item->GetItemType() == AppListFolderItem::kItemType)
166 return;
jennyz 2014/04/09 22:00:32 When users logs out and in again, the syncable ser
stevenjb 2014/04/09 22:17:16 AppListSyncableService has reliable information ab
157 owner_->RemoveSyncItem(item->id()); 167 owner_->RemoveSyncItem(item->id());
158 } 168 }
159 169
160 virtual void OnAppListItemUpdated(AppListItem* item) OVERRIDE { 170 virtual void OnAppListItemUpdated(AppListItem* item) OVERRIDE {
161 DVLOG(2) << owner_ << " OnAppListItemUpdated: " << item->ToDebugString(); 171 if (adding_item_) {
172 // Adding an item may trigger update notifications which should be
173 // ignored.
174 DCHECK_EQ(adding_item_, item);
175 return;
jennyz 2014/04/09 21:31:08 What if the update is not triggered by adding item
stevenjb 2014/04/09 21:48:16 This is all synchronous, so adding_item_ would be
jennyz 2014/04/09 22:00:32 Sounds good.
176 }
177 VLOG(2) << owner_ << " OnAppListItemUpdated: " << item->ToDebugString();
162 owner_->UpdateSyncItem(item); 178 owner_->UpdateSyncItem(item);
163 } 179 }
164 180
165 AppListSyncableService* owner_; 181 AppListSyncableService* owner_;
182 AppListItem* adding_item_; // Unowned pointer to item being added.
166 183
167 DISALLOW_COPY_AND_ASSIGN(ModelObserver); 184 DISALLOW_COPY_AND_ASSIGN(ModelObserver);
168 }; 185 };
169 186
170 // AppListSyncableService 187 // AppListSyncableService
171 188
172 AppListSyncableService::AppListSyncableService( 189 AppListSyncableService::AppListSyncableService(
173 Profile* profile, 190 Profile* profile,
174 extensions::ExtensionSystem* extension_system) 191 extensions::ExtensionSystem* extension_system)
175 : profile_(profile), 192 : profile_(profile),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } 314 }
298 315
299 return CreateSyncItemFromAppItem(app_item); 316 return CreateSyncItemFromAppItem(app_item);
300 } 317 }
301 318
302 AppListSyncableService::SyncItem* 319 AppListSyncableService::SyncItem*
303 AppListSyncableService::CreateSyncItemFromAppItem(AppListItem* app_item) { 320 AppListSyncableService::CreateSyncItemFromAppItem(AppListItem* app_item) {
304 sync_pb::AppListSpecifics::AppListItemType type; 321 sync_pb::AppListSpecifics::AppListItemType type;
305 if (!GetAppListItemType(app_item, &type)) 322 if (!GetAppListItemType(app_item, &type))
306 return NULL; 323 return NULL;
324 VLOG(2) << this << " CreateSyncItemFromAppItem:" << app_item->ToDebugString();
307 SyncItem* sync_item = CreateSyncItem(app_item->id(), type); 325 SyncItem* sync_item = CreateSyncItem(app_item->id(), type);
308 UpdateSyncItemFromAppItem(app_item, sync_item); 326 UpdateSyncItemFromAppItem(app_item, sync_item);
309 SendSyncChange(sync_item, SyncChange::ACTION_ADD); 327 SendSyncChange(sync_item, SyncChange::ACTION_ADD);
310 return sync_item; 328 return sync_item;
311 } 329 }
312 330
313 void AppListSyncableService::AddOrUpdateFromSyncItem(AppListItem* app_item) { 331 void AppListSyncableService::AddOrUpdateFromSyncItem(AppListItem* app_item) {
314 SyncItem* sync_item = FindSyncItem(app_item->id()); 332 SyncItem* sync_item = FindSyncItem(app_item->id());
315 if (sync_item) { 333 if (sync_item) {
316 UpdateAppItemFromSyncItem(sync_item, app_item); 334 UpdateAppItemFromSyncItem(sync_item, app_item);
(...skipping 19 matching lines...) Expand all
336 354
337 // Otherwise, we are adding the app as a non-default app (i.e. an app that 355 // Otherwise, we are adding the app as a non-default app (i.e. an app that
338 // was installed by Default and removed is getting installed explicitly by 356 // was installed by Default and removed is getting installed explicitly by
339 // the user), so delete the REMOVE_DEFAULT_APP. 357 // the user), so delete the REMOVE_DEFAULT_APP.
340 DeleteSyncItem(sync_item); 358 DeleteSyncItem(sync_item);
341 return false; 359 return false;
342 } 360 }
343 361
344 void AppListSyncableService::DeleteSyncItem(SyncItem* sync_item) { 362 void AppListSyncableService::DeleteSyncItem(SyncItem* sync_item) {
345 if (SyncStarted()) { 363 if (SyncStarted()) {
346 DVLOG(2) << this << " -> SYNC DELETE: " << sync_item->ToString(); 364 VLOG(2) << this << " -> SYNC DELETE: " << sync_item->ToString();
347 SyncChange sync_change(FROM_HERE, SyncChange::ACTION_DELETE, 365 SyncChange sync_change(FROM_HERE, SyncChange::ACTION_DELETE,
348 GetSyncDataFromSyncItem(sync_item)); 366 GetSyncDataFromSyncItem(sync_item));
349 sync_processor_->ProcessSyncChanges( 367 sync_processor_->ProcessSyncChanges(
350 FROM_HERE, syncer::SyncChangeList(1, sync_change)); 368 FROM_HERE, syncer::SyncChangeList(1, sync_change));
351 } 369 }
352 std::string item_id = sync_item->item_id; 370 std::string item_id = sync_item->item_id;
353 delete sync_item; 371 delete sync_item;
354 sync_items_.erase(item_id); 372 sync_items_.erase(item_id);
355 } 373 }
356 374
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (type == sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP) { 417 if (type == sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP) {
400 // RemoveDefault item exists, just return. 418 // RemoveDefault item exists, just return.
401 DVLOG(2) << this << " : RemoveDefault Item exists."; 419 DVLOG(2) << this << " : RemoveDefault Item exists.";
402 return; 420 return;
403 } 421 }
404 422
405 if (type == sync_pb::AppListSpecifics::TYPE_APP && 423 if (type == sync_pb::AppListSpecifics::TYPE_APP &&
406 AppIsDefault(extension_system_->extension_service(), id)) { 424 AppIsDefault(extension_system_->extension_service(), id)) {
407 // This is a Default app; update the entry to a REMOVE_DEFAULT entry. This 425 // This is a Default app; update the entry to a REMOVE_DEFAULT entry. This
408 // will overwrite any existing entry for the item. 426 // will overwrite any existing entry for the item.
409 DVLOG(2) << this << " -> SYNC UPDATE: REMOVE_DEFAULT: " 427 VLOG(2) << this << " -> SYNC UPDATE: REMOVE_DEFAULT: "
410 << sync_item->item_id; 428 << sync_item->item_id;
411 sync_item->item_type = sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP; 429 sync_item->item_type = sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP;
412 SendSyncChange(sync_item, SyncChange::ACTION_UPDATE); 430 SendSyncChange(sync_item, SyncChange::ACTION_UPDATE);
413 return; 431 return;
414 } 432 }
415 433
416 DeleteSyncItem(sync_item); 434 DeleteSyncItem(sync_item);
417 } 435 }
418 436
419 void AppListSyncableService::ResolveFolderPositions(bool move_oem_to_end) { 437 void AppListSyncableService::ResolveFolderPositions(bool move_oem_to_end) {
420 if (!app_list::switches::IsFolderUIEnabled()) 438 if (!app_list::switches::IsFolderUIEnabled())
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 result.set_num_items_after_association(sync_items_.size()); 521 result.set_num_items_after_association(sync_items_.size());
504 result.set_num_items_added(new_items); 522 result.set_num_items_added(new_items);
505 result.set_num_items_deleted(0); 523 result.set_num_items_deleted(0);
506 result.set_num_items_modified(updated_items); 524 result.set_num_items_modified(updated_items);
507 525
508 // Send unsynced items. Does not affect |result|. 526 // Send unsynced items. Does not affect |result|.
509 syncer::SyncChangeList change_list; 527 syncer::SyncChangeList change_list;
510 for (std::set<std::string>::iterator iter = unsynced_items.begin(); 528 for (std::set<std::string>::iterator iter = unsynced_items.begin();
511 iter != unsynced_items.end(); ++iter) { 529 iter != unsynced_items.end(); ++iter) {
512 SyncItem* sync_item = FindSyncItem(*iter); 530 SyncItem* sync_item = FindSyncItem(*iter);
513 DVLOG(2) << this << " -> SYNC ADD: " << sync_item->ToString(); 531 VLOG(2) << this << " -> SYNC ADD: " << sync_item->ToString();
514 change_list.push_back(SyncChange(FROM_HERE, SyncChange::ACTION_ADD, 532 change_list.push_back(SyncChange(FROM_HERE, SyncChange::ACTION_ADD,
515 GetSyncDataFromSyncItem(sync_item))); 533 GetSyncDataFromSyncItem(sync_item)));
516 } 534 }
517 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list); 535 sync_processor_->ProcessSyncChanges(FROM_HERE, change_list);
518 536
519 // Adding items may have created folders without setting their positions 537 // Adding items may have created folders without setting their positions
520 // since we haven't started observing the item list yet. Resolve those. 538 // since we haven't started observing the item list yet. Resolve those.
521 // Also ensure the OEM folder is at the end if its position hasn't been set. 539 // Also ensure the OEM folder is at the end if its position hasn't been set.
522 bool move_oem_to_end = !oem_folder_is_synced; 540 bool move_oem_to_end = !oem_folder_is_synced;
523 ResolveFolderPositions(move_oem_to_end); 541 ResolveFolderPositions(move_oem_to_end);
(...skipping 12 matching lines...) Expand all
536 } 554 }
537 555
538 syncer::SyncDataList AppListSyncableService::GetAllSyncData( 556 syncer::SyncDataList AppListSyncableService::GetAllSyncData(
539 syncer::ModelType type) const { 557 syncer::ModelType type) const {
540 DCHECK_EQ(syncer::APP_LIST, type); 558 DCHECK_EQ(syncer::APP_LIST, type);
541 559
542 VLOG(1) << this << ": GetAllSyncData: " << sync_items_.size(); 560 VLOG(1) << this << ": GetAllSyncData: " << sync_items_.size();
543 syncer::SyncDataList list; 561 syncer::SyncDataList list;
544 for (SyncItemMap::const_iterator iter = sync_items_.begin(); 562 for (SyncItemMap::const_iterator iter = sync_items_.begin();
545 iter != sync_items_.end(); ++iter) { 563 iter != sync_items_.end(); ++iter) {
546 DVLOG(2) << this << " -> SYNC: " << iter->second->ToString(); 564 VLOG(2) << this << " -> SYNC: " << iter->second->ToString();
547 list.push_back(GetSyncDataFromSyncItem(iter->second)); 565 list.push_back(GetSyncDataFromSyncItem(iter->second));
548 } 566 }
549 return list; 567 return list;
550 } 568 }
551 569
552 syncer::SyncError AppListSyncableService::ProcessSyncChanges( 570 syncer::SyncError AppListSyncableService::ProcessSyncChanges(
553 const tracked_objects::Location& from_here, 571 const tracked_objects::Location& from_here,
554 const syncer::SyncChangeList& change_list) { 572 const syncer::SyncChangeList& change_list) {
555 if (!sync_processor_.get()) { 573 if (!sync_processor_.get()) {
556 return syncer::SyncError(FROM_HERE, 574 return syncer::SyncError(FROM_HERE,
557 syncer::SyncError::DATATYPE_ERROR, 575 syncer::SyncError::DATATYPE_ERROR,
558 "App List syncable service is not started.", 576 "App List syncable service is not started.",
559 syncer::APP_LIST); 577 syncer::APP_LIST);
560 } 578 }
561 579
562 // Don't observe the model while processing incoming sync changes. 580 // Don't observe the model while processing incoming sync changes.
563 model_observer_.reset(); 581 model_observer_.reset();
564 582
565 VLOG(1) << this << ": ProcessSyncChanges: " << change_list.size(); 583 VLOG(1) << this << ": ProcessSyncChanges: " << change_list.size();
566 for (syncer::SyncChangeList::const_iterator iter = change_list.begin(); 584 for (syncer::SyncChangeList::const_iterator iter = change_list.begin();
567 iter != change_list.end(); ++iter) { 585 iter != change_list.end(); ++iter) {
568 const SyncChange& change = *iter; 586 const SyncChange& change = *iter;
569 DVLOG(2) << this << " Change: " 587 VLOG(2) << this << " Change: "
570 << change.sync_data().GetSpecifics().app_list().item_id() 588 << change.sync_data().GetSpecifics().app_list().item_id()
571 << " (" << change.change_type() << ")"; 589 << " (" << change.change_type() << ")";
572 if (change.change_type() == SyncChange::ACTION_ADD || 590 if (change.change_type() == SyncChange::ACTION_ADD ||
573 change.change_type() == SyncChange::ACTION_UPDATE) { 591 change.change_type() == SyncChange::ACTION_UPDATE) {
574 ProcessSyncItemSpecifics(change.sync_data().GetSpecifics().app_list()); 592 ProcessSyncItemSpecifics(change.sync_data().GetSpecifics().app_list());
575 } else if (change.change_type() == SyncChange::ACTION_DELETE) { 593 } else if (change.change_type() == SyncChange::ACTION_DELETE) {
576 DeleteSyncItemSpecifics(change.sync_data().GetSpecifics().app_list()); 594 DeleteSyncItemSpecifics(change.sync_data().GetSpecifics().app_list());
577 } else { 595 } else {
578 LOG(ERROR) << "Invalid sync change"; 596 LOG(ERROR) << "Invalid sync change";
579 } 597 }
580 } 598 }
581 599
(...skipping 11 matching lines...) Expand all
593 if (item_id.empty()) { 611 if (item_id.empty()) {
594 LOG(ERROR) << "AppList item with empty ID"; 612 LOG(ERROR) << "AppList item with empty ID";
595 return false; 613 return false;
596 } 614 }
597 SyncItem* sync_item = FindSyncItem(item_id); 615 SyncItem* sync_item = FindSyncItem(item_id);
598 if (sync_item) { 616 if (sync_item) {
599 // If an item of the same type exists, update it. 617 // If an item of the same type exists, update it.
600 if (sync_item->item_type == specifics.item_type()) { 618 if (sync_item->item_type == specifics.item_type()) {
601 UpdateSyncItemFromSync(specifics, sync_item); 619 UpdateSyncItemFromSync(specifics, sync_item);
602 ProcessExistingSyncItem(sync_item); 620 ProcessExistingSyncItem(sync_item);
603 DVLOG(2) << this << " <- SYNC UPDATE: " << sync_item->ToString(); 621 VLOG(2) << this << " <- SYNC UPDATE: " << sync_item->ToString();
604 return false; 622 return false;
605 } 623 }
606 // Otherwise, one of the entries should be TYPE_REMOVE_DEFAULT_APP. 624 // Otherwise, one of the entries should be TYPE_REMOVE_DEFAULT_APP.
607 if (sync_item->item_type != 625 if (sync_item->item_type !=
608 sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP && 626 sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP &&
609 specifics.item_type() != 627 specifics.item_type() !=
610 sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP) { 628 sync_pb::AppListSpecifics::TYPE_REMOVE_DEFAULT_APP) {
611 LOG(ERROR) << "Synced item type: " << specifics.item_type() 629 LOG(ERROR) << "Synced item type: " << specifics.item_type()
612 << " != existing sync item type: " << sync_item->item_type 630 << " != existing sync item type: " << sync_item->item_type
613 << " Deleting item from model!"; 631 << " Deleting item from model!";
614 model_->DeleteItem(item_id); 632 model_->DeleteItem(item_id);
615 } 633 }
616 DVLOG(2) << this << " - ProcessSyncItem: Delete existing entry: " 634 VLOG(2) << this << " - ProcessSyncItem: Delete existing entry: "
617 << sync_item->ToString(); 635 << sync_item->ToString();
618 delete sync_item; 636 delete sync_item;
619 sync_items_.erase(item_id); 637 sync_items_.erase(item_id);
620 } 638 }
621 639
622 sync_item = CreateSyncItem(item_id, specifics.item_type()); 640 sync_item = CreateSyncItem(item_id, specifics.item_type());
623 UpdateSyncItemFromSync(specifics, sync_item); 641 UpdateSyncItemFromSync(specifics, sync_item);
624 ProcessNewSyncItem(sync_item); 642 ProcessNewSyncItem(sync_item);
625 DVLOG(2) << this << " <- SYNC ADD: " << sync_item->ToString(); 643 VLOG(2) << this << " <- SYNC ADD: " << sync_item->ToString();
626 return true; 644 return true;
627 } 645 }
628 646
629 void AppListSyncableService::ProcessNewSyncItem(SyncItem* sync_item) { 647 void AppListSyncableService::ProcessNewSyncItem(SyncItem* sync_item) {
630 VLOG(2) << "ProcessNewSyncItem: " << sync_item->ToString(); 648 VLOG(2) << "ProcessNewSyncItem: " << sync_item->ToString();
631 switch (sync_item->item_type) { 649 switch (sync_item->item_type) {
632 case sync_pb::AppListSpecifics::TYPE_APP: { 650 case sync_pb::AppListSpecifics::TYPE_APP: {
633 // New apps are added through ExtensionAppModelBuilder. 651 // New apps are added through ExtensionAppModelBuilder.
634 // TODO(stevenjb): Determine how to handle app items in sync that 652 // TODO(stevenjb): Determine how to handle app items in sync that
635 // are not installed (e.g. default / OEM apps). 653 // are not installed (e.g. default / OEM apps).
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 !AppIsOem(app_item->id())) { 693 !AppIsOem(app_item->id())) {
676 DVLOG(2) << " Moving Item To Folder: " << sync_item->parent_id; 694 DVLOG(2) << " Moving Item To Folder: " << sync_item->parent_id;
677 model_->MoveItemToFolder(app_item, sync_item->parent_id); 695 model_->MoveItemToFolder(app_item, sync_item->parent_id);
678 } 696 }
679 UpdateAppItemFromSyncItem(sync_item, app_item); 697 UpdateAppItemFromSyncItem(sync_item, app_item);
680 } 698 }
681 699
682 void AppListSyncableService::UpdateAppItemFromSyncItem( 700 void AppListSyncableService::UpdateAppItemFromSyncItem(
683 const AppListSyncableService::SyncItem* sync_item, 701 const AppListSyncableService::SyncItem* sync_item,
684 AppListItem* app_item) { 702 AppListItem* app_item) {
703 VLOG(2) << this << "UpdateAppItemFromSyncItem: " << sync_item->ToString();
685 if (!app_item->position().Equals(sync_item->item_ordinal)) 704 if (!app_item->position().Equals(sync_item->item_ordinal))
686 model_->SetItemPosition(app_item, sync_item->item_ordinal); 705 model_->SetItemPosition(app_item, sync_item->item_ordinal);
687 // Only update the item name if it is a Folder or the name is empty. 706 // Only update the item name if it is a Folder or the name is empty.
688 if (sync_item->item_name != app_item->name() && 707 if (sync_item->item_name != app_item->name() &&
689 sync_item->item_id != kOemFolderId && 708 sync_item->item_id != kOemFolderId &&
690 (app_item->GetItemType() == AppListFolderItem::kItemType || 709 (app_item->GetItemType() == AppListFolderItem::kItemType ||
691 app_item->name().empty())) { 710 app_item->name().empty())) {
692 model_->SetItemName(app_item, sync_item->item_name); 711 model_->SetItemName(app_item, sync_item->item_name);
693 } 712 }
694 } 713 }
(...skipping 11 matching lines...) Expand all
706 725
707 void AppListSyncableService::SendSyncChange( 726 void AppListSyncableService::SendSyncChange(
708 SyncItem* sync_item, 727 SyncItem* sync_item,
709 SyncChange::SyncChangeType sync_change_type) { 728 SyncChange::SyncChangeType sync_change_type) {
710 if (!SyncStarted()) { 729 if (!SyncStarted()) {
711 DVLOG(2) << this << " - SendSyncChange: SYNC NOT STARTED: " 730 DVLOG(2) << this << " - SendSyncChange: SYNC NOT STARTED: "
712 << sync_item->ToString(); 731 << sync_item->ToString();
713 return; 732 return;
714 } 733 }
715 if (sync_change_type == SyncChange::ACTION_ADD) 734 if (sync_change_type == SyncChange::ACTION_ADD)
716 DVLOG(2) << this << " -> SYNC ADD: " << sync_item->ToString(); 735 VLOG(2) << this << " -> SYNC ADD: " << sync_item->ToString();
717 else 736 else
718 DVLOG(2) << this << " -> SYNC UPDATE: " << sync_item->ToString(); 737 VLOG(2) << this << " -> SYNC UPDATE: " << sync_item->ToString();
719 SyncChange sync_change(FROM_HERE, sync_change_type, 738 SyncChange sync_change(FROM_HERE, sync_change_type,
720 GetSyncDataFromSyncItem(sync_item)); 739 GetSyncDataFromSyncItem(sync_item));
721 sync_processor_->ProcessSyncChanges( 740 sync_processor_->ProcessSyncChanges(
722 FROM_HERE, syncer::SyncChangeList(1, sync_change)); 741 FROM_HERE, syncer::SyncChangeList(1, sync_change));
723 } 742 }
724 743
725 AppListSyncableService::SyncItem* 744 AppListSyncableService::SyncItem*
726 AppListSyncableService::FindSyncItem(const std::string& item_id) { 745 AppListSyncableService::FindSyncItem(const std::string& item_id) {
727 SyncItemMap::iterator iter = sync_items_.find(item_id); 746 SyncItemMap::iterator iter = sync_items_.find(item_id);
728 if (iter == sync_items_.end()) 747 if (iter == sync_items_.end())
(...skipping 17 matching lines...) Expand all
746 if (item_id.empty()) { 765 if (item_id.empty()) {
747 LOG(ERROR) << "Delete AppList item with empty ID"; 766 LOG(ERROR) << "Delete AppList item with empty ID";
748 return; 767 return;
749 } 768 }
750 VLOG(2) << this << ": DeleteSyncItemSpecifics: " << item_id.substr(0, 8); 769 VLOG(2) << this << ": DeleteSyncItemSpecifics: " << item_id.substr(0, 8);
751 SyncItemMap::iterator iter = sync_items_.find(item_id); 770 SyncItemMap::iterator iter = sync_items_.find(item_id);
752 if (iter == sync_items_.end()) 771 if (iter == sync_items_.end())
753 return; 772 return;
754 sync_pb::AppListSpecifics::AppListItemType item_type = 773 sync_pb::AppListSpecifics::AppListItemType item_type =
755 iter->second->item_type; 774 iter->second->item_type;
756 DVLOG(2) << this << " <- SYNC DELETE: " << iter->second->ToString(); 775 VLOG(2) << this << " <- SYNC DELETE: " << iter->second->ToString();
757 delete iter->second; 776 delete iter->second;
758 sync_items_.erase(iter); 777 sync_items_.erase(iter);
759 // Only delete apps from the model. Folders will be deleted when all 778 // Only delete apps from the model. Folders will be deleted when all
760 // children have been deleted. 779 // children have been deleted.
761 if (item_type == sync_pb::AppListSpecifics::TYPE_APP) 780 if (item_type == sync_pb::AppListSpecifics::TYPE_APP)
762 model_->DeleteItem(item_id); 781 model_->DeleteItem(item_id);
763 } 782 }
764 783
765 std::string AppListSyncableService::FindOrCreateOemFolder() { 784 std::string AppListSyncableService::FindOrCreateOemFolder() {
766 AppListFolderItem* oem_folder = model_->FindFolderItem(kOemFolderId); 785 AppListFolderItem* oem_folder = model_->FindFolderItem(kOemFolderId);
(...skipping 22 matching lines...) Expand all
789 } else { 808 } else {
790 res += " { " + item_name + " }"; 809 res += " { " + item_name + " }";
791 res += " [" + item_ordinal.ToDebugString() + "]"; 810 res += " [" + item_ordinal.ToDebugString() + "]";
792 if (!parent_id.empty()) 811 if (!parent_id.empty())
793 res += " <" + parent_id.substr(0, 8) + ">"; 812 res += " <" + parent_id.substr(0, 8) + ">";
794 } 813 }
795 return res; 814 return res;
796 } 815 }
797 816
798 } // namespace app_list 817 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698