Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Data Formats

Marshall T. Rose edited this page Sep 26, 2019 · 8 revisions

NB: Always verify that the information recorded below reflects the latest commit to the relevant file!

Platform-independent Information

Latest version of api.proto SyncRecord, as of 2019-05-14.

At present, only Bookmark and Device are synchronized.

Note that there are platform-specific limitations:

  • Android: Bookmark.hideInToolbar and Bookmark.metaInfo are ignored
  • iOS: none known
  • Laptop: none known
message MetaInfo {
  optional string key = 1;
  optional string value = 2;
}

message SyncRecord {
  enum Action {
    CREATE = 0;
    UPDATE = 1;
    DELETE = 2;
  }
  message Site {
    string location = 1;
    string title = 2;
    string customTitle = 3;
    uint64 lastAccessedTime = 4;
    uint64 creationTime = 5;
    string favicon = 6;
  }
  message Bookmark {
    Site site = 1;
    bool isFolder = 2;
    bytes parentFolderObjectId = 3;
    bytes previousObjectId = 4; // unused
    bytes nextObjectId = 5; // unused
    repeated string fields = 6;
    bool hideInToolbar = 7;
    string order = 8;
    repeated MetaInfo metaInfo= 9;
  }
  message SiteSetting {
    string hostPattern = 1;
    float zoomLevel = 2;
    bool shieldsUp = 3;
    enum AdControl {
      SHOW_BRAVE_ADS = 0;
      BLOCK_ADS = 1;
      ALLOW_ADS_AND_TRACKING = 2;
    }
    enum CookieControl {
      BLOCK_THIRD_PARTY_COOKIE = 0;
      ALLOW_ALL_COOKIES = 1;
      BLOCK_ALL_COOKIES = 2;
    }
    AdControl adControl = 4;
    CookieControl cookieControl = 5;
    bool safeBrowsing = 6;
    bool noScript = 7;
    bool httpsEverywhere = 8;
    bool fingerprintingProtection = 9;
    bool ledgerPayments = 10;
    bool ledgerPaymentsShown = 11;
    repeated string fields = 12;
  }
  message Device {
    string name = 1;
  }
  Action action = 1;
  bytes deviceId = 2;
  bytes objectId = 3;
  oneof objectData {
    Bookmark bookmark = 4;
    Site historySite = 5;
    SiteSetting siteSetting = 6;
    Device device = 7;
  }
}
  // The unique identifier for this node.
  int64_t id_;

  // The URL of this node. BookmarkModel maintains maps off this URL, so changes
  // to the URL must be done through the BookmarkModel.
  GURL url_;

  // The type of this node. See enum above.
  Type type_;

  // Date of when this node was created.
  base::Time date_added_;

  // Date of the last modification. Only used for folders.
  base::Time date_folder_modified_;

  // The favicon of this node.
  gfx::Image favicon_;

  // The type of favicon currently loaded.
  favicon_base::IconType favicon_type_;

  // The URL of the node's favicon.
  GURL icon_url_;

  // The loading state of the favicon.
  FaviconState favicon_state_;

  // If not base::CancelableTaskTracker::kBadTaskId, it indicates
  // we're loading the
  // favicon and the task is tracked by CancelabelTaskTracker.
  base::CancelableTaskTracker::TaskId favicon_load_task_id_;

  // A map that stores arbitrary meta information about the node.
  std::unique_ptr<MetaInfoMap> meta_info_map_;

  // The sync transaction version. Defaults to kInvalidSyncTransactionVersion.
  int64_t sync_transaction_version_;

Latest version of SyncRecord.swift as of 2019-03-05:

/* Bookmark */
var objectId: [Int]?
var deviceId: [Int]?
var action: Int?
var objectData: SyncObjectDataType?
var isFavorite: Bool = false
var isFolder: Bool? = false
var parentFolderObjectId: [Int]?
var syncOrder: String?
var customTitle: String?
var title: String?
var favicon: String?
var location: String?
var creationTime: Int?
var lastAccessedTime: Int?

/* Device */
var objectId: [Int]?
var deviceId: [Int]?
var action: Int?
var objectData: SyncObjectDataType?
var name: String?

Latest version of state.md, as of 2017-01-03.

  bookmarks: {
    [bookmarkKey]: {
      favicon: string, // URL of the favicon
      key: string, // key is duplication of bookmarkKey
      location: string,
      objectId: Array.<number>,
      originalSeed: Array.<number>, // bookmarks that have been synced before a sync profile reset
      parentFolderId: number,
      partitionNumber: number, // optionally specifies a specific session
      skipSync: boolean,
      title: string
    }
  },
  bookmarkFolders: {
    [folderKey]: {
      folderId: number,
      key: string, // key is duplication of folderKey
      objectId: Array.<number>,
      originalSeed: Array.<number>, // only set for bookmarks that have been synced before a sync profile reset
      parentFolderId: number, // set for bookmarks and bookmark folders only
      skipSync: boolean, // Set for objects FETCHed by sync
      title: string
    }
  },
  sync: {
    lastFetchTimestamp: integer // the last time new sync records were fetched in seconds
    deviceId: Array.<number>,
    devices: {
      [deviceId]: {
        name: string,
        lastRecordTimestamp: number // last seen Sync record from this device
      }
    },
    objectId: Array.<number>, // objectId for this sync device
    objectsById: {
      [string of objectId joined by pipes |]: Array.<string> // array key path within appState, so we can do appState.getIn({key path})
    },
    pendingRecords: { // OrderedMap of unconfirmed (not yet downloaded) sync records.
      [objectId]: {
        enqueueTimestamp: number // new Date().getTime() when record was submitted
        record: object, // Sync record sent with SEND_SYNC_RECORDS
      }
    },
    seed: Array.<number>,
    seedQr: string, // data URL of QR code representing the seed
    setupError: string? // indicates that an error occurred during sync setup
  }
Clone this wiki locally