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

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

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 5 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 | « chrome/browser/extensions/app_sync_bundle.h ('k') | chrome/browser/extensions/app_sync_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_sorting.h" 9 #include "chrome/browser/extensions/extension_sorting.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_set.h" 11 #include "chrome/common/extensions/extension_set.h"
12 #include "sync/api/sync_change_processor.h" 12 #include "sync/api/sync_change_processor.h"
13 #include "sync/api/sync_error_factory.h" 13 #include "sync/api/sync_error_factory.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 AppSyncBundle::AppSyncBundle(ExtensionService* extension_service) 17 AppSyncBundle::AppSyncBundle(ExtensionService* extension_service)
18 : extension_service_(extension_service), 18 : extension_service_(extension_service),
19 sync_processor_(NULL) {} 19 sync_processor_(NULL) {}
20 20
21 AppSyncBundle::~AppSyncBundle() {} 21 AppSyncBundle::~AppSyncBundle() {}
22 22
23 void AppSyncBundle::SetupSync(csync::SyncChangeProcessor* sync_change_processor, 23 void AppSyncBundle::SetupSync(
24 csync::SyncErrorFactory* sync_error_factory, 24 syncer::SyncChangeProcessor* sync_change_processor,
25 const csync::SyncDataList& initial_sync_data) { 25 syncer::SyncErrorFactory* sync_error_factory,
26 const syncer::SyncDataList& initial_sync_data) {
26 sync_processor_.reset(sync_change_processor); 27 sync_processor_.reset(sync_change_processor);
27 sync_error_factory_.reset(sync_error_factory); 28 sync_error_factory_.reset(sync_error_factory);
28 29
29 for (csync::SyncDataList::const_iterator i = initial_sync_data.begin(); 30 for (syncer::SyncDataList::const_iterator i = initial_sync_data.begin();
30 i != initial_sync_data.end(); 31 i != initial_sync_data.end();
31 ++i) { 32 ++i) {
32 AppSyncData app_sync_data(*i); 33 AppSyncData app_sync_data(*i);
33 AddApp(app_sync_data.id()); 34 AddApp(app_sync_data.id());
34 extension_service_->ProcessAppSyncData(app_sync_data); 35 extension_service_->ProcessAppSyncData(app_sync_data);
35 } 36 }
36 } 37 }
37 38
38 void AppSyncBundle::Reset() { 39 void AppSyncBundle::Reset() {
39 sync_processor_.reset(); 40 sync_processor_.reset();
40 sync_error_factory_.reset(); 41 sync_error_factory_.reset();
41 synced_apps_.clear(); 42 synced_apps_.clear();
42 pending_sync_data_.clear(); 43 pending_sync_data_.clear();
43 } 44 }
44 45
45 csync::SyncChange AppSyncBundle::CreateSyncChangeToDelete( 46 syncer::SyncChange AppSyncBundle::CreateSyncChangeToDelete(
46 const Extension* extension) 47 const Extension* extension)
47 const { 48 const {
48 AppSyncData sync_data = extension_service_->GetAppSyncData(*extension); 49 AppSyncData sync_data = extension_service_->GetAppSyncData(*extension);
49 return sync_data.GetSyncChange(csync::SyncChange::ACTION_DELETE); 50 return sync_data.GetSyncChange(syncer::SyncChange::ACTION_DELETE);
50 } 51 }
51 52
52 void AppSyncBundle::ProcessDeletion(std::string extension_id, 53 void AppSyncBundle::ProcessDeletion(std::string extension_id,
53 const csync::SyncChange& sync_change) { 54 const syncer::SyncChange& sync_change) {
54 RemoveApp(extension_id); 55 RemoveApp(extension_id);
55 sync_processor_->ProcessSyncChanges(FROM_HERE, 56 sync_processor_->ProcessSyncChanges(FROM_HERE,
56 csync::SyncChangeList(1, sync_change)); 57 syncer::SyncChangeList(1, sync_change));
57 } 58 }
58 59
59 csync::SyncChange AppSyncBundle::CreateSyncChange( 60 syncer::SyncChange AppSyncBundle::CreateSyncChange(
60 const csync::SyncData& sync_data) { 61 const syncer::SyncData& sync_data) {
61 if (HasExtensionId(sync_data.GetTag())) { 62 if (HasExtensionId(sync_data.GetTag())) {
62 return csync::SyncChange(csync::SyncChange::ACTION_UPDATE, sync_data); 63 return syncer::SyncChange(syncer::SyncChange::ACTION_UPDATE, sync_data);
63 } else { 64 } else {
64 AddApp(sync_data.GetTag()); 65 AddApp(sync_data.GetTag());
65 return csync::SyncChange(csync::SyncChange::ACTION_ADD, sync_data); 66 return syncer::SyncChange(syncer::SyncChange::ACTION_ADD, sync_data);
66 } 67 }
67 } 68 }
68 69
69 csync::SyncDataList AppSyncBundle::GetAllSyncData() const { 70 syncer::SyncDataList AppSyncBundle::GetAllSyncData() const {
70 std::vector<AppSyncData> app_sync_data = 71 std::vector<AppSyncData> app_sync_data =
71 extension_service_->GetAppSyncDataList(); 72 extension_service_->GetAppSyncDataList();
72 csync::SyncDataList result(app_sync_data.size()); 73 syncer::SyncDataList result(app_sync_data.size());
73 for (int i = 0; i < static_cast<int>(app_sync_data.size()); ++i) { 74 for (int i = 0; i < static_cast<int>(app_sync_data.size()); ++i) {
74 result[i] = app_sync_data[i].GetSyncData(); 75 result[i] = app_sync_data[i].GetSyncData();
75 } 76 }
76 return result; 77 return result;
77 } 78 }
78 79
79 void AppSyncBundle::SyncChangeIfNeeded(const Extension& extension) { 80 void AppSyncBundle::SyncChangeIfNeeded(const Extension& extension) {
80 AppSyncData app_sync_data = extension_service_->GetAppSyncData(extension); 81 AppSyncData app_sync_data = extension_service_->GetAppSyncData(extension);
81 82
82 csync::SyncChangeList sync_change_list(1, app_sync_data.GetSyncChange( 83 syncer::SyncChangeList sync_change_list(1, app_sync_data.GetSyncChange(
83 HasExtensionId(extension.id()) ? 84 HasExtensionId(extension.id()) ?
84 csync::SyncChange::ACTION_UPDATE : csync::SyncChange::ACTION_ADD)); 85 syncer::SyncChange::ACTION_UPDATE : syncer::SyncChange::ACTION_ADD));
85 sync_processor_->ProcessSyncChanges(FROM_HERE, sync_change_list); 86 sync_processor_->ProcessSyncChanges(FROM_HERE, sync_change_list);
86 MarkPendingAppSynced(extension.id()); 87 MarkPendingAppSynced(extension.id());
87 } 88 }
88 89
89 void AppSyncBundle::ProcessSyncChange(AppSyncData app_sync_data) { 90 void AppSyncBundle::ProcessSyncChange(AppSyncData app_sync_data) {
90 if (app_sync_data.uninstalled()) 91 if (app_sync_data.uninstalled())
91 RemoveApp(app_sync_data.id()); 92 RemoveApp(app_sync_data.id());
92 else 93 else
93 AddApp(app_sync_data.id()); 94 AddApp(app_sync_data.id());
94 extension_service_->ProcessAppSyncData(app_sync_data); 95 extension_service_->ProcessAppSyncData(app_sync_data);
95 } 96 }
96 97
97 void AppSyncBundle::ProcessSyncChangeList( 98 void AppSyncBundle::ProcessSyncChangeList(
98 csync::SyncChangeList sync_change_list) { 99 syncer::SyncChangeList sync_change_list) {
99 sync_processor_->ProcessSyncChanges(FROM_HERE, sync_change_list); 100 sync_processor_->ProcessSyncChanges(FROM_HERE, sync_change_list);
100 extension_service_->extension_prefs()->extension_sorting()-> 101 extension_service_->extension_prefs()->extension_sorting()->
101 FixNTPOrdinalCollisions(); 102 FixNTPOrdinalCollisions();
102 } 103 }
103 104
104 bool AppSyncBundle::HasExtensionId(const std::string& id) const { 105 bool AppSyncBundle::HasExtensionId(const std::string& id) const {
105 return synced_apps_.find(id) != synced_apps_.end(); 106 return synced_apps_.find(id) != synced_apps_.end();
106 } 107 }
107 108
108 bool AppSyncBundle::HasPendingExtensionId(const std::string& id) const { 109 bool AppSyncBundle::HasPendingExtensionId(const std::string& id) const {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } 157 }
157 158
158 159
159 void AppSyncBundle::MarkPendingAppSynced(const std::string& id) { 160 void AppSyncBundle::MarkPendingAppSynced(const std::string& id) {
160 pending_sync_data_.erase(id); 161 pending_sync_data_.erase(id);
161 synced_apps_.insert(id); 162 synced_apps_.insert(id);
162 } 163 }
163 164
164 165
165 } // namespace extensions 166 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_sync_bundle.h ('k') | chrome/browser/extensions/app_sync_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698