OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 Loading... |
27 #include "chrome/browser/sync/engine/all_status.h" | 27 #include "chrome/browser/sync/engine/all_status.h" |
28 #include "chrome/browser/sync/engine/auth_watcher.h" | 28 #include "chrome/browser/sync/engine/auth_watcher.h" |
29 #include "chrome/browser/sync/engine/change_reorder_buffer.h" | 29 #include "chrome/browser/sync/engine/change_reorder_buffer.h" |
30 #include "chrome/browser/sync/engine/model_safe_worker.h" | 30 #include "chrome/browser/sync/engine/model_safe_worker.h" |
31 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 31 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
32 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h" | 32 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h" |
33 #include "chrome/browser/sync/engine/syncer.h" | 33 #include "chrome/browser/sync/engine/syncer.h" |
34 #include "chrome/browser/sync/engine/syncer_thread.h" | 34 #include "chrome/browser/sync/engine/syncer_thread.h" |
35 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" | 35 #include "chrome/browser/sync/protocol/autofill_specifics.pb.h" |
36 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" | 36 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" |
| 37 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" |
37 #include "chrome/browser/sync/protocol/password_specifics.pb.h" | 38 #include "chrome/browser/sync/protocol/password_specifics.pb.h" |
38 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" | 39 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" |
39 #include "chrome/browser/sync/protocol/service_constants.h" | 40 #include "chrome/browser/sync/protocol/service_constants.h" |
40 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" | 41 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" |
41 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" | 42 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" |
42 #include "chrome/browser/sync/sessions/sync_session_context.h" | 43 #include "chrome/browser/sync/sessions/sync_session_context.h" |
43 #include "chrome/browser/sync/syncable/directory_manager.h" | 44 #include "chrome/browser/sync/syncable/directory_manager.h" |
44 #include "chrome/browser/sync/syncable/syncable.h" | 45 #include "chrome/browser/sync/syncable/syncable.h" |
45 #include "chrome/browser/sync/util/character_set_converters.h" | 46 #include "chrome/browser/sync/util/character_set_converters.h" |
46 #include "chrome/browser/sync/util/closure.h" | 47 #include "chrome/browser/sync/util/closure.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 const sync_pb::ThemeSpecifics& BaseNode::GetThemeSpecifics() const { | 262 const sync_pb::ThemeSpecifics& BaseNode::GetThemeSpecifics() const { |
262 DCHECK(GetModelType() == syncable::THEMES); | 263 DCHECK(GetModelType() == syncable::THEMES); |
263 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::theme); | 264 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::theme); |
264 } | 265 } |
265 | 266 |
266 const sync_pb::TypedUrlSpecifics& BaseNode::GetTypedUrlSpecifics() const { | 267 const sync_pb::TypedUrlSpecifics& BaseNode::GetTypedUrlSpecifics() const { |
267 DCHECK(GetModelType() == syncable::TYPED_URLS); | 268 DCHECK(GetModelType() == syncable::TYPED_URLS); |
268 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::typed_url); | 269 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::typed_url); |
269 } | 270 } |
270 | 271 |
| 272 const sync_pb::ExtensionSpecifics& BaseNode::GetExtensionSpecifics() const { |
| 273 DCHECK(GetModelType() == syncable::EXTENSIONS); |
| 274 return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::extension); |
| 275 } |
| 276 |
271 syncable::ModelType BaseNode::GetModelType() const { | 277 syncable::ModelType BaseNode::GetModelType() const { |
272 return GetEntry()->GetModelType(); | 278 return GetEntry()->GetModelType(); |
273 } | 279 } |
274 | 280 |
275 //////////////////////////////////// | 281 //////////////////////////////////// |
276 // WriteNode member definitions | 282 // WriteNode member definitions |
277 void WriteNode::SetIsFolder(bool folder) { | 283 void WriteNode::SetIsFolder(bool folder) { |
278 if (entry_->Get(syncable::IS_DIR) == folder) | 284 if (entry_->Get(syncable::IS_DIR) == folder) |
279 return; // Skip redundant changes. | 285 return; // Skip redundant changes. |
280 | 286 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 entity_specifics.MutableExtension(sync_pb::preference)->CopyFrom(new_value); | 368 entity_specifics.MutableExtension(sync_pb::preference)->CopyFrom(new_value); |
363 PutSpecificsAndMarkForSyncing(entity_specifics); | 369 PutSpecificsAndMarkForSyncing(entity_specifics); |
364 } | 370 } |
365 | 371 |
366 void WriteNode::SetTypedUrlSpecifics( | 372 void WriteNode::SetTypedUrlSpecifics( |
367 const sync_pb::TypedUrlSpecifics& new_value) { | 373 const sync_pb::TypedUrlSpecifics& new_value) { |
368 DCHECK(GetModelType() == syncable::TYPED_URLS); | 374 DCHECK(GetModelType() == syncable::TYPED_URLS); |
369 PutTypedUrlSpecificsAndMarkForSyncing(new_value); | 375 PutTypedUrlSpecificsAndMarkForSyncing(new_value); |
370 } | 376 } |
371 | 377 |
| 378 void WriteNode::SetExtensionSpecifics( |
| 379 const sync_pb::ExtensionSpecifics& new_value) { |
| 380 DCHECK(GetModelType() == syncable::EXTENSIONS); |
| 381 PutExtensionSpecificsAndMarkForSyncing(new_value); |
| 382 } |
| 383 |
372 void WriteNode::PutThemeSpecificsAndMarkForSyncing( | 384 void WriteNode::PutThemeSpecificsAndMarkForSyncing( |
373 const sync_pb::ThemeSpecifics& new_value) { | 385 const sync_pb::ThemeSpecifics& new_value) { |
374 sync_pb::EntitySpecifics entity_specifics; | 386 sync_pb::EntitySpecifics entity_specifics; |
375 entity_specifics.MutableExtension(sync_pb::theme)->CopyFrom(new_value); | 387 entity_specifics.MutableExtension(sync_pb::theme)->CopyFrom(new_value); |
376 PutSpecificsAndMarkForSyncing(entity_specifics); | 388 PutSpecificsAndMarkForSyncing(entity_specifics); |
377 } | 389 } |
378 | 390 |
379 void WriteNode::PutTypedUrlSpecificsAndMarkForSyncing( | 391 void WriteNode::PutTypedUrlSpecificsAndMarkForSyncing( |
380 const sync_pb::TypedUrlSpecifics& new_value) { | 392 const sync_pb::TypedUrlSpecifics& new_value) { |
381 sync_pb::EntitySpecifics entity_specifics; | 393 sync_pb::EntitySpecifics entity_specifics; |
382 entity_specifics.MutableExtension(sync_pb::typed_url)->CopyFrom(new_value); | 394 entity_specifics.MutableExtension(sync_pb::typed_url)->CopyFrom(new_value); |
383 PutSpecificsAndMarkForSyncing(entity_specifics); | 395 PutSpecificsAndMarkForSyncing(entity_specifics); |
384 } | 396 } |
385 | 397 |
| 398 void WriteNode::PutExtensionSpecificsAndMarkForSyncing( |
| 399 const sync_pb::ExtensionSpecifics& new_value) { |
| 400 sync_pb::EntitySpecifics entity_specifics; |
| 401 entity_specifics.MutableExtension(sync_pb::extension)->CopyFrom(new_value); |
| 402 PutSpecificsAndMarkForSyncing(entity_specifics); |
| 403 } |
| 404 |
386 void WriteNode::PutSpecificsAndMarkForSyncing( | 405 void WriteNode::PutSpecificsAndMarkForSyncing( |
387 const sync_pb::EntitySpecifics& specifics) { | 406 const sync_pb::EntitySpecifics& specifics) { |
388 // Skip redundant changes. | 407 // Skip redundant changes. |
389 if (specifics.SerializeAsString() == | 408 if (specifics.SerializeAsString() == |
390 entry_->Get(SPECIFICS).SerializeAsString()) { | 409 entry_->Get(SPECIFICS).SerializeAsString()) { |
391 return; | 410 return; |
392 } | 411 } |
393 entry_->Put(SPECIFICS, specifics); | 412 entry_->Put(SPECIFICS, specifics); |
394 MarkForSyncing(); | 413 MarkForSyncing(); |
395 } | 414 } |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 UserShare* SyncManager::GetUserShare() const { | 1966 UserShare* SyncManager::GetUserShare() const { |
1948 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; | 1967 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; |
1949 return data_->GetUserShare(); | 1968 return data_->GetUserShare(); |
1950 } | 1969 } |
1951 | 1970 |
1952 SyncManager::ExtraAutofillChangeRecordData::~ExtraAutofillChangeRecordData() { | 1971 SyncManager::ExtraAutofillChangeRecordData::~ExtraAutofillChangeRecordData() { |
1953 delete pre_deletion_data; | 1972 delete pre_deletion_data; |
1954 } | 1973 } |
1955 | 1974 |
1956 } // namespace sync_api | 1975 } // namespace sync_api |
OLD | NEW |