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

Side by Side Diff: sync/protocol/proto_value_conversions.cc

Issue 9663023: Log the sync communication that happens between client and server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For 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) 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 // Keep this file in sync with the .proto files in this directory. 5 // Keep this file in sync with the .proto files in this directory.
6 6
7 #include "sync/protocol/proto_value_conversions.h" 7 #include "sync/protocol/proto_value_conversions.h"
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/bind.h"
12 #include "base/callback.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
13 #include "base/values.h" 15 #include "base/values.h"
14 #include "sync/protocol/app_notification_specifics.pb.h" 16 #include "sync/protocol/app_notification_specifics.pb.h"
15 #include "sync/protocol/app_setting_specifics.pb.h" 17 #include "sync/protocol/app_setting_specifics.pb.h"
16 #include "sync/protocol/app_specifics.pb.h" 18 #include "sync/protocol/app_specifics.pb.h"
17 #include "sync/protocol/autofill_specifics.pb.h" 19 #include "sync/protocol/autofill_specifics.pb.h"
18 #include "sync/protocol/bookmark_specifics.pb.h" 20 #include "sync/protocol/bookmark_specifics.pb.h"
19 #include "sync/protocol/encryption.pb.h" 21 #include "sync/protocol/encryption.pb.h"
20 #include "sync/protocol/extension_setting_specifics.pb.h" 22 #include "sync/protocol/extension_setting_specifics.pb.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 SET_FIELD(nigori, NigoriSpecificsToValue); 392 SET_FIELD(nigori, NigoriSpecificsToValue);
391 SET_FIELD(password, PasswordSpecificsToValue); 393 SET_FIELD(password, PasswordSpecificsToValue);
392 SET_FIELD(preference, PreferenceSpecificsToValue); 394 SET_FIELD(preference, PreferenceSpecificsToValue);
393 SET_FIELD(search_engine, SearchEngineSpecificsToValue); 395 SET_FIELD(search_engine, SearchEngineSpecificsToValue);
394 SET_FIELD(session, SessionSpecificsToValue); 396 SET_FIELD(session, SessionSpecificsToValue);
395 SET_FIELD(theme, ThemeSpecificsToValue); 397 SET_FIELD(theme, ThemeSpecificsToValue);
396 SET_FIELD(typed_url, TypedUrlSpecificsToValue); 398 SET_FIELD(typed_url, TypedUrlSpecificsToValue);
397 return value; 399 return value;
398 } 400 }
399 401
402 namespace {
403
404 DictionaryValue* SyncEntityToValue(const sync_pb::SyncEntity& proto,
405 bool include_specifics) {
406 DictionaryValue* value = new DictionaryValue();
407 SET_STR(id_string);
408 SET_STR(parent_id_string);
409 SET_STR(old_parent_id);
410 SET_INT64(version);
411 SET_INT64(mtime);
412 SET_INT64(ctime);
413 SET_STR(name);
414 SET_STR(non_unique_name);
415 SET_INT64(sync_timestamp);
416 SET_STR(server_defined_unique_tag);
417 SET_INT64(position_in_parent);
418 SET_STR(insert_after_item_id);
419 SET_BOOL(deleted);
420 SET_STR(originator_cache_guid);
421 SET_STR(originator_client_item_id);
422 if (include_specifics)
423 SET(specifics, EntitySpecificsToValue);
424 SET_BOOL(folder);
425 SET_STR(client_defined_unique_tag);
426 return value;
427 }
428
429 ListValue* SyncEntitiesToValue(
430 const ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities,
431 bool include_specifics) {
432 ListValue* list = new ListValue();
433 ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it;
434 for (it = entities.begin(); it != entities.end(); ++it) {
435 list->Append(SyncEntityToValue(*it, include_specifics));
436 }
437
438 return list;
439 }
440
441 DictionaryValue* ChromiumExtensionActivityToValue(
442 const sync_pb::ChromiumExtensionsActivity& proto) {
443 DictionaryValue* value = new DictionaryValue();
444 SET_STR(extension_id);
445 SET_INT32(bookmark_writes_since_last_commit);
446 return value;
447 }
448
449 DictionaryValue* CommitMessageToValue(
450 const sync_pb::CommitMessage& proto,
451 bool include_specifics) {
452 DictionaryValue* value = new DictionaryValue();
453 value->Set("entries",
454 SyncEntitiesToValue(proto.entries(), include_specifics));
455 SET_STR(cache_guid);
456 SET_REP(extensions_activity, ChromiumExtensionActivityToValue);
457 return value;
458 }
459
460 DictionaryValue* DataTypeProgressMarkerToValue(
461 const sync_pb::DataTypeProgressMarker& proto) {
462 DictionaryValue* value = new DictionaryValue();
463 SET_INT32(data_type_id);
464 SET_BYTES(token);
465 SET_INT64(timestamp_token_for_migration);
466 SET_STR(notification_hint);
467 return value;
468 }
469
470 DictionaryValue* GetUpdatesCallerInfoToValue(
471 const sync_pb::GetUpdatesCallerInfo& proto) {
472 DictionaryValue* value = new DictionaryValue();
473 SET_ENUM(source, GetUpdatesSourceString);
474 SET_BOOL(notifications_enabled);
475 return value;
476 }
477
478 DictionaryValue* GetUpdatesMessageToValue(
479 const sync_pb::GetUpdatesMessage& proto) {
480 DictionaryValue* value = new DictionaryValue();
481 SET(caller_info, GetUpdatesCallerInfoToValue);
482 SET_BOOL(fetch_folders);
483 SET_INT32(batch_size);
484 SET_REP(from_progress_marker, DataTypeProgressMarkerToValue);
485 SET_BOOL(streaming);
486 SET_BOOL(create_mobile_bookmarks_folder);
487 return value;
488 }
489
490 DictionaryValue* EntryResponseToValue(
491 const sync_pb::CommitResponse::EntryResponse& proto) {
492 DictionaryValue* value = new DictionaryValue();
493 SET_ENUM(response_type, GetResponseTypeString);
494 SET_STR(id_string);
495 SET_STR(parent_id_string);
496 SET_INT64(position_in_parent);
497 SET_INT64(version);
498 SET_STR(name);
499 SET_STR(error_message);
500 SET_INT64(mtime);
501 return value;
502 }
503
504 DictionaryValue* CommitResponseToValue(const sync_pb::CommitResponse& proto) {
505 DictionaryValue* value = new DictionaryValue();
506 SET_REP(entryresponse, EntryResponseToValue);
507 return value;
508 }
509
510 DictionaryValue* GetUpdatesResponseToValue(
511 const sync_pb::GetUpdatesResponse& proto,
512 bool include_specifics) {
513 DictionaryValue* value = new DictionaryValue();
514 value->Set("entries",
515 SyncEntitiesToValue(proto.entries(), include_specifics));
516 SET_INT64(changes_remaining);
517 SET_REP(new_progress_marker, DataTypeProgressMarkerToValue);
518 return value;
519 }
520
521 DictionaryValue* ClientCommandToValue(const sync_pb::ClientCommand& proto) {
522 DictionaryValue* value = new DictionaryValue();
523 SET_INT32(set_sync_poll_interval);
524 SET_INT32(set_sync_long_poll_interval);
525 SET_INT32(max_commit_batch_size);
526 SET_INT32(sessions_commit_delay_seconds);
527 SET_INT32(throttle_delay_seconds);
528 return value;
529 }
530
531 DictionaryValue* ErrorToValue(
532 const sync_pb::ClientToServerResponse::Error& proto) {
533 DictionaryValue* value = new DictionaryValue();
534 SET_ENUM(error_type, GetErrorTypeString);
535 SET_STR(error_description);
536 SET_STR(url);
537 SET_ENUM(action, GetActionString);
538 return value;
539 }
540
541 } // namespace
542
543 DictionaryValue* ClientToServerResponseToValue(
544 const sync_pb::ClientToServerResponse& proto,
545 bool include_specifics) {
546 DictionaryValue* value = new DictionaryValue();
547 SET(commit, CommitResponseToValue);
548 if (proto.has_get_updates()) {
549 value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(),
550 include_specifics));
551 }
552
553 SET(error, ErrorToValue);
554 SET_ENUM(error_code, GetErrorTypeString);
555 SET_STR(error_message);
556 SET_STR(store_birthday);
557 SET(client_command, ClientCommandToValue);
558 SET_INT32_REP(migrated_data_type_id);
559 return value;
560 }
561
562 DictionaryValue* ClientToServerMessageToValue(
563 const sync_pb::ClientToServerMessage& proto,
564 bool include_specifics) {
565 DictionaryValue* value = new DictionaryValue();
566 SET_STR(share);
567 SET_INT32(protocol_version);
568 if (proto.has_commit()) {
569 value->Set("commit",
570 CommitMessageToValue(proto.commit(), include_specifics));
571 }
572
573 SET(get_updates, GetUpdatesMessageToValue);
574 SET_STR(store_birthday);
575 SET_BOOL(sync_problem_detected);
576 return value;
577 }
578
579
400 #undef SET 580 #undef SET
401 #undef SET_REP 581 #undef SET_REP
402 582
403 #undef SET_BOOL 583 #undef SET_BOOL
404 #undef SET_BYTES 584 #undef SET_BYTES
405 #undef SET_INT32 585 #undef SET_INT32
406 #undef SET_INT64 586 #undef SET_INT64
407 #undef SET_INT64_REP 587 #undef SET_INT64_REP
408 #undef SET_STR 588 #undef SET_STR
409 #undef SET_STR_REP 589 #undef SET_STR_REP
410 590
411 #undef SET_FIELD 591 #undef SET_FIELD
412 592
413 } // namespace browser_sync 593 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698