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

Side by Side Diff: chrome/browser/extensions/app_sync_bundle.cc

Issue 217063005: Separate SyncData methods into three groups, local, remote, and common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@syncapi
Patch Set: Rebase. 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
OLDNEW
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/app_sync_bundle.h" 5 #include "chrome/browser/extensions/app_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/common/extensions/sync_helper.h" 9 #include "chrome/common/extensions/sync_helper.h"
10 #include "extensions/browser/app_sorting.h" 10 #include "extensions/browser/app_sorting.h"
11 #include "extensions/common/extension.h" 11 #include "extensions/common/extension.h"
12 #include "extensions/common/extension_set.h" 12 #include "extensions/common/extension_set.h"
13 #include "sync/api/sync_change_processor.h" 13 #include "sync/api/sync_change_processor.h"
14 #include "sync/api/sync_data.h"
14 #include "sync/api/sync_error_factory.h" 15 #include "sync/api/sync_error_factory.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 AppSyncBundle::AppSyncBundle(ExtensionSyncService* extension_sync_service) 19 AppSyncBundle::AppSyncBundle(ExtensionSyncService* extension_sync_service)
19 : extension_sync_service_(extension_sync_service) {} 20 : extension_sync_service_(extension_sync_service) {}
20 21
21 AppSyncBundle::~AppSyncBundle() {} 22 AppSyncBundle::~AppSyncBundle() {}
22 23
23 void AppSyncBundle::SetupSync( 24 void AppSyncBundle::SetupSync(
(...skipping 28 matching lines...) Expand all
52 53
53 void AppSyncBundle::ProcessDeletion(std::string extension_id, 54 void AppSyncBundle::ProcessDeletion(std::string extension_id,
54 const syncer::SyncChange& sync_change) { 55 const syncer::SyncChange& sync_change) {
55 RemoveApp(extension_id); 56 RemoveApp(extension_id);
56 sync_processor_->ProcessSyncChanges(FROM_HERE, 57 sync_processor_->ProcessSyncChanges(FROM_HERE,
57 syncer::SyncChangeList(1, sync_change)); 58 syncer::SyncChangeList(1, sync_change));
58 } 59 }
59 60
60 syncer::SyncChange AppSyncBundle::CreateSyncChange( 61 syncer::SyncChange AppSyncBundle::CreateSyncChange(
61 const syncer::SyncData& sync_data) { 62 const syncer::SyncData& sync_data) {
62 if (HasExtensionId(sync_data.GetTag())) { 63 const syncer::SyncDataLocal sync_data_local(sync_data);
64 if (HasExtensionId(sync_data_local.GetTag())) {
63 return syncer::SyncChange(FROM_HERE, 65 return syncer::SyncChange(FROM_HERE,
64 syncer::SyncChange::ACTION_UPDATE, 66 syncer::SyncChange::ACTION_UPDATE,
65 sync_data); 67 sync_data);
66 } else { 68 } else {
67 AddApp(sync_data.GetTag()); 69 AddApp(sync_data_local.GetTag());
68 return syncer::SyncChange(FROM_HERE, 70 return syncer::SyncChange(FROM_HERE,
69 syncer::SyncChange::ACTION_ADD, 71 syncer::SyncChange::ACTION_ADD,
70 sync_data); 72 sync_data);
71 } 73 }
72 } 74 }
73 75
74 syncer::SyncDataList AppSyncBundle::GetAllSyncData() const { 76 syncer::SyncDataList AppSyncBundle::GetAllSyncData() const {
75 std::vector<AppSyncData> app_sync_data = 77 std::vector<AppSyncData> app_sync_data =
76 extension_sync_service_->GetAppSyncDataList(); 78 extension_sync_service_->GetAppSyncDataList();
77 syncer::SyncDataList result(app_sync_data.size()); 79 syncer::SyncDataList result(app_sync_data.size());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 164 }
163 165
164 166
165 void AppSyncBundle::MarkPendingAppSynced(const std::string& id) { 167 void AppSyncBundle::MarkPendingAppSynced(const std::string& id) {
166 pending_sync_data_.erase(id); 168 pending_sync_data_.erase(id);
167 synced_apps_.insert(id); 169 synced_apps_.insert(id);
168 } 170 }
169 171
170 172
171 } // namespace extensions 173 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/storage/settings_sync_unittest.cc ('k') | chrome/browser/extensions/extension_sync_bundle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698