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 "chrome/browser/extensions/extension_sync_bundle.h" | 5 #include "chrome/browser/extensions/extension_sync_bundle.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "chrome/browser/extensions/extension_sync_service.h" | 8 #include "chrome/browser/extensions/extension_sync_service.h" |
| 9 #include "chrome/browser/extensions/extension_util.h" | 9 #include "chrome/browser/extensions/extension_util.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 const std::string& id, | 115 const std::string& id, |
| 116 const ExtensionSyncData& extension_sync_data) { | 116 const ExtensionSyncData& extension_sync_data) { |
| 117 pending_sync_data_[id] = extension_sync_data; | 117 pending_sync_data_[id] = extension_sync_data; |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool ExtensionSyncBundle::IsSyncing() const { | 120 bool ExtensionSyncBundle::IsSyncing() const { |
| 121 return sync_processor_ != NULL; | 121 return sync_processor_ != NULL; |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ExtensionSyncBundle::SyncChangeIfNeeded(const Extension& extension) { | 124 void ExtensionSyncBundle::SyncChangeIfNeeded(const Extension& extension) { |
| 125 // If there is a pending update for this extension, apply it first. | |
| 126 auto it = pending_sync_data_.find(extension.id()); | |
| 127 if (it != pending_sync_data_.end()) | |
| 128 ProcessSyncChange(it->second); | |
|
Marc Treib
2015/06/22 15:35:18
It sucks that this code is duplicated in app_sync_
| |
| 129 | |
| 125 ExtensionSyncData extension_sync_data = | 130 ExtensionSyncData extension_sync_data = |
| 126 extension_sync_service_->GetExtensionSyncData(extension); | 131 extension_sync_service_->GetExtensionSyncData(extension); |
| 127 | 132 |
| 128 syncer::SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange( | 133 syncer::SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange( |
| 129 HasExtensionId(extension.id()) ? | 134 HasExtensionId(extension.id()) ? |
| 130 syncer::SyncChange::ACTION_UPDATE : syncer::SyncChange::ACTION_ADD)); | 135 syncer::SyncChange::ACTION_UPDATE : syncer::SyncChange::ACTION_ADD)); |
| 131 sync_processor_->ProcessSyncChanges(FROM_HERE, sync_change_list); | 136 sync_processor_->ProcessSyncChanges(FROM_HERE, sync_change_list); |
| 132 MarkPendingExtensionSynced(extension.id()); | 137 MarkPendingExtensionSynced(extension.id()); |
| 133 } | 138 } |
| 134 | 139 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 void ExtensionSyncBundle::RemoveExtension(const std::string& id) { | 175 void ExtensionSyncBundle::RemoveExtension(const std::string& id) { |
| 171 synced_extensions_.erase(id); | 176 synced_extensions_.erase(id); |
| 172 } | 177 } |
| 173 | 178 |
| 174 void ExtensionSyncBundle::MarkPendingExtensionSynced(const std::string& id) { | 179 void ExtensionSyncBundle::MarkPendingExtensionSynced(const std::string& id) { |
| 175 pending_sync_data_.erase(id); | 180 pending_sync_data_.erase(id); |
| 176 synced_extensions_.insert(id); | 181 synced_extensions_.insert(id); |
| 177 } | 182 } |
| 178 | 183 |
| 179 } // namespace extensions | 184 } // namespace extensions |
| OLD | NEW |