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

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

Issue 9460047: sync: remove use of protobuf extensions in protocol to reduce static init overhead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fred's review Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_data.h" 5 #include "chrome/browser/extensions/extension_sync_data.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/sync/protocol/app_specifics.pb.h" 9 #include "chrome/browser/sync/protocol/app_specifics.pb.h"
10 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 10 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
11 #include "chrome/browser/sync/protocol/sync.pb.h"
11 12
12 ExtensionSyncData::ExtensionSyncData() 13 ExtensionSyncData::ExtensionSyncData()
13 : uninstalled_(false), 14 : uninstalled_(false),
14 enabled_(false), 15 enabled_(false),
15 incognito_enabled_(false), 16 incognito_enabled_(false),
16 type_(Extension::SYNC_TYPE_NONE), 17 type_(Extension::SYNC_TYPE_NONE),
17 notifications_disabled_(false) { 18 notifications_disabled_(false) {
18 } 19 }
19 20
20 ExtensionSyncData::ExtensionSyncData(const SyncData& sync_data) 21 ExtensionSyncData::ExtensionSyncData(const SyncData& sync_data)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 specifics->set_enabled(enabled_); 86 specifics->set_enabled(enabled_);
86 specifics->set_incognito_enabled(incognito_enabled_); 87 specifics->set_incognito_enabled(incognito_enabled_);
87 specifics->set_name(name_); 88 specifics->set_name(name_);
88 } 89 }
89 90
90 SyncData ExtensionSyncData::GetSyncData() const { 91 SyncData ExtensionSyncData::GetSyncData() const {
91 sync_pb::EntitySpecifics specifics; 92 sync_pb::EntitySpecifics specifics;
92 93
93 switch (type_) { 94 switch (type_) {
94 case Extension::SYNC_TYPE_EXTENSION: 95 case Extension::SYNC_TYPE_EXTENSION:
95 PopulateExtensionSpecifics(specifics.MutableExtension( 96 PopulateExtensionSpecifics(specifics.mutable_extension());
96 sync_pb::extension));
97 break; 97 break;
98 case Extension::SYNC_TYPE_APP: 98 case Extension::SYNC_TYPE_APP:
99 PopulateAppSpecifics(specifics.MutableExtension(sync_pb::app)); 99 PopulateAppSpecifics(specifics.mutable_app());
100 break; 100 break;
101 default: 101 default:
102 LOG(FATAL) << "Attempt to get non-syncable data."; 102 LOG(FATAL) << "Attempt to get non-syncable data.";
103 } 103 }
104 104
105 return SyncData::CreateLocalData(id_, name_, specifics); 105 return SyncData::CreateLocalData(id_, name_, specifics);
106 } 106 }
107 107
108 SyncChange ExtensionSyncData::GetSyncChange( 108 SyncChange ExtensionSyncData::GetSyncChange(
109 SyncChange::SyncChangeType change_type) const { 109 SyncChange::SyncChangeType change_type) const {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 update_url_ = specifics_update_url; 149 update_url_ = specifics_update_url;
150 version_ = specifics_version; 150 version_ = specifics_version;
151 enabled_ = specifics.enabled(); 151 enabled_ = specifics.enabled();
152 incognito_enabled_ = specifics.incognito_enabled(); 152 incognito_enabled_ = specifics.incognito_enabled();
153 name_ = specifics.name(); 153 name_ = specifics.name();
154 } 154 }
155 155
156 void ExtensionSyncData::PopulateFromSyncData(const SyncData& sync_data) { 156 void ExtensionSyncData::PopulateFromSyncData(const SyncData& sync_data) {
157 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics(); 157 const sync_pb::EntitySpecifics& entity_specifics = sync_data.GetSpecifics();
158 158
159 if (entity_specifics.HasExtension(sync_pb::extension)) { 159 if (entity_specifics.has_extension()) {
160 PopulateFromExtensionSpecifics( 160 PopulateFromExtensionSpecifics(entity_specifics.extension());
161 entity_specifics.GetExtension(sync_pb::extension));
162 type_ = Extension::SYNC_TYPE_EXTENSION; 161 type_ = Extension::SYNC_TYPE_EXTENSION;
163 } else if (entity_specifics.HasExtension(sync_pb::app)) { 162 } else if (entity_specifics.has_app()) {
164 PopulateFromAppSpecifics( 163 PopulateFromAppSpecifics(entity_specifics.app());
165 entity_specifics.GetExtension(sync_pb::app));
166 type_ = Extension::SYNC_TYPE_APP; 164 type_ = Extension::SYNC_TYPE_APP;
167 } else { 165 } else {
168 LOG(FATAL) << "Attempt to sync bad EntitySpecifics."; 166 LOG(FATAL) << "Attempt to sync bad EntitySpecifics.";
169 } 167 }
170 } 168 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.cc ('k') | chrome/browser/extensions/extension_sync_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698