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

Side by Side Diff: chrome/browser/sync/engine/syncapi.cc

Issue 3072022: Added constants, strings, protos for app sync. (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/protocol/app_specifics.proto » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/sync/engine/syncapi.h" 5 #include "chrome/browser/sync/engine/syncapi.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <iomanip> 9 #include <iomanip>
10 #include <list> 10 #include <list>
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/sync/sync_constants.h" 27 #include "chrome/browser/sync/sync_constants.h"
28 #include "chrome/browser/sync/engine/all_status.h" 28 #include "chrome/browser/sync/engine/all_status.h"
29 #include "chrome/browser/sync/engine/auth_watcher.h" 29 #include "chrome/browser/sync/engine/auth_watcher.h"
30 #include "chrome/browser/sync/engine/change_reorder_buffer.h" 30 #include "chrome/browser/sync/engine/change_reorder_buffer.h"
31 #include "chrome/browser/sync/engine/model_safe_worker.h" 31 #include "chrome/browser/sync/engine/model_safe_worker.h"
32 #include "chrome/browser/sync/engine/net/server_connection_manager.h" 32 #include "chrome/browser/sync/engine/net/server_connection_manager.h"
33 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h" 33 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h"
34 #include "chrome/browser/sync/engine/syncer.h" 34 #include "chrome/browser/sync/engine/syncer.h"
35 #include "chrome/browser/sync/engine/syncer_thread.h" 35 #include "chrome/browser/sync/engine/syncer_thread.h"
36 #include "chrome/browser/sync/notifier/server_notifier_thread.h" 36 #include "chrome/browser/sync/notifier/server_notifier_thread.h"
37 #include "chrome/browser/sync/protocol/app_specifics.pb.h"
37 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" 38 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h"
38 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 39 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
39 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 40 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
40 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 41 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
41 #include "chrome/browser/sync/protocol/password_specifics.pb.h" 42 #include "chrome/browser/sync/protocol/password_specifics.pb.h"
42 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" 43 #include "chrome/browser/sync/protocol/preference_specifics.pb.h"
43 #include "chrome/browser/sync/protocol/service_constants.h" 44 #include "chrome/browser/sync/protocol/service_constants.h"
44 #include "chrome/browser/sync/protocol/sync.pb.h" 45 #include "chrome/browser/sync/protocol/sync.pb.h"
45 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" 46 #include "chrome/browser/sync/protocol/theme_specifics.pb.h"
46 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" 47 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 const std::string& favicon = GetBookmarkSpecifics().favicon(); 247 const std::string& favicon = GetBookmarkSpecifics().favicon();
247 output->assign(reinterpret_cast<const unsigned char*>(favicon.data()), 248 output->assign(reinterpret_cast<const unsigned char*>(favicon.data()),
248 reinterpret_cast<const unsigned char*>(favicon.data() + 249 reinterpret_cast<const unsigned char*>(favicon.data() +
249 favicon.length())); 250 favicon.length()));
250 } 251 }
251 252
252 int64 BaseNode::GetExternalId() const { 253 int64 BaseNode::GetExternalId() const {
253 return GetEntry()->Get(syncable::LOCAL_EXTERNAL_ID); 254 return GetEntry()->Get(syncable::LOCAL_EXTERNAL_ID);
254 } 255 }
255 256
257 const sync_pb::AppSpecifics& BaseNode::GetAppSpecifics() const {
258 DCHECK(GetModelType() == syncable::APPS);
259 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::app);
260 }
261
256 const sync_pb::AutofillSpecifics& BaseNode::GetAutofillSpecifics() const { 262 const sync_pb::AutofillSpecifics& BaseNode::GetAutofillSpecifics() const {
257 DCHECK(GetModelType() == syncable::AUTOFILL); 263 DCHECK(GetModelType() == syncable::AUTOFILL);
258 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::autofill); 264 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::autofill);
259 } 265 }
260 266
261 const sync_pb::BookmarkSpecifics& BaseNode::GetBookmarkSpecifics() const { 267 const sync_pb::BookmarkSpecifics& BaseNode::GetBookmarkSpecifics() const {
262 DCHECK(GetModelType() == syncable::BOOKMARKS); 268 DCHECK(GetModelType() == syncable::BOOKMARKS);
263 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::bookmark); 269 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::bookmark);
264 } 270 }
265 271
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 entry_->Put(syncable::NON_UNIQUE_NAME, server_legal_name); 326 entry_->Put(syncable::NON_UNIQUE_NAME, server_legal_name);
321 MarkForSyncing(); 327 MarkForSyncing();
322 } 328 }
323 329
324 void WriteNode::SetURL(const GURL& url) { 330 void WriteNode::SetURL(const GURL& url) {
325 sync_pb::BookmarkSpecifics new_value = GetBookmarkSpecifics(); 331 sync_pb::BookmarkSpecifics new_value = GetBookmarkSpecifics();
326 new_value.set_url(url.spec()); 332 new_value.set_url(url.spec());
327 SetBookmarkSpecifics(new_value); 333 SetBookmarkSpecifics(new_value);
328 } 334 }
329 335
336 void WriteNode::SetAppSpecifics(
337 const sync_pb::AppSpecifics& new_value) {
338 DCHECK(GetModelType() == syncable::APPS);
339 PutAppSpecificsAndMarkForSyncing(new_value);
340 }
341
330 void WriteNode::SetAutofillSpecifics( 342 void WriteNode::SetAutofillSpecifics(
331 const sync_pb::AutofillSpecifics& new_value) { 343 const sync_pb::AutofillSpecifics& new_value) {
332 DCHECK(GetModelType() == syncable::AUTOFILL); 344 DCHECK(GetModelType() == syncable::AUTOFILL);
333 PutAutofillSpecificsAndMarkForSyncing(new_value); 345 PutAutofillSpecificsAndMarkForSyncing(new_value);
334 } 346 }
335 347
336 void WriteNode::PutAutofillSpecificsAndMarkForSyncing( 348 void WriteNode::PutAutofillSpecificsAndMarkForSyncing(
337 const sync_pb::AutofillSpecifics& new_value) { 349 const sync_pb::AutofillSpecifics& new_value) {
338 sync_pb::EntitySpecifics entity_specifics; 350 sync_pb::EntitySpecifics entity_specifics;
339 entity_specifics.MutableExtension(sync_pb::autofill)->CopyFrom(new_value); 351 entity_specifics.MutableExtension(sync_pb::autofill)->CopyFrom(new_value);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 DCHECK(GetModelType() == syncable::TYPED_URLS); 423 DCHECK(GetModelType() == syncable::TYPED_URLS);
412 PutTypedUrlSpecificsAndMarkForSyncing(new_value); 424 PutTypedUrlSpecificsAndMarkForSyncing(new_value);
413 } 425 }
414 426
415 void WriteNode::SetExtensionSpecifics( 427 void WriteNode::SetExtensionSpecifics(
416 const sync_pb::ExtensionSpecifics& new_value) { 428 const sync_pb::ExtensionSpecifics& new_value) {
417 DCHECK(GetModelType() == syncable::EXTENSIONS); 429 DCHECK(GetModelType() == syncable::EXTENSIONS);
418 PutExtensionSpecificsAndMarkForSyncing(new_value); 430 PutExtensionSpecificsAndMarkForSyncing(new_value);
419 } 431 }
420 432
433 void WriteNode::PutAppSpecificsAndMarkForSyncing(
434 const sync_pb::AppSpecifics& new_value) {
435 sync_pb::EntitySpecifics entity_specifics;
436 entity_specifics.MutableExtension(sync_pb::app)->CopyFrom(new_value);
437 PutSpecificsAndMarkForSyncing(entity_specifics);
438 }
439
421 void WriteNode::PutThemeSpecificsAndMarkForSyncing( 440 void WriteNode::PutThemeSpecificsAndMarkForSyncing(
422 const sync_pb::ThemeSpecifics& new_value) { 441 const sync_pb::ThemeSpecifics& new_value) {
423 sync_pb::EntitySpecifics entity_specifics; 442 sync_pb::EntitySpecifics entity_specifics;
424 entity_specifics.MutableExtension(sync_pb::theme)->CopyFrom(new_value); 443 entity_specifics.MutableExtension(sync_pb::theme)->CopyFrom(new_value);
425 PutSpecificsAndMarkForSyncing(entity_specifics); 444 PutSpecificsAndMarkForSyncing(entity_specifics);
426 } 445 }
427 446
428 void WriteNode::PutTypedUrlSpecificsAndMarkForSyncing( 447 void WriteNode::PutTypedUrlSpecificsAndMarkForSyncing(
429 const sync_pb::TypedUrlSpecifics& new_value) { 448 const sync_pb::TypedUrlSpecifics& new_value) {
430 sync_pb::EntitySpecifics entity_specifics; 449 sync_pb::EntitySpecifics entity_specifics;
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; 2176 DCHECK(data_->initialized()) << "GetUserShare requires initialization!";
2158 return data_->GetUserShare(); 2177 return data_->GetUserShare();
2159 } 2178 }
2160 2179
2161 bool SyncManager::HasUnsyncedItems() const { 2180 bool SyncManager::HasUnsyncedItems() const {
2162 sync_api::ReadTransaction trans(GetUserShare()); 2181 sync_api::ReadTransaction trans(GetUserShare());
2163 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); 2182 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0);
2164 } 2183 }
2165 2184
2166 } // namespace sync_api 2185 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi.h ('k') | chrome/browser/sync/protocol/app_specifics.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698