Commit 182ca718 authored by Leonid Baraz's avatar Leonid Baraz Committed by Commit Bot

Add Client timestamp to the Record to be enqueue.

The server is free to process Records in arbitrary order,
and timestamp will allow to rearrange them according to the order
they were enqueued by the Client device.

Change-Id: I3df98f61b4dfa67933eef322dc2959dd28c3d17b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422721
Commit-Queue: Leonid Baraz <lbaraz@chromium.org>
Reviewed-by: default avatarZach Trudo <zatrudo@google.com>
Cr-Commit-Position: refs/heads/master@{#809399}
parent 8cf29d47
......@@ -18,6 +18,7 @@
#include "base/strings/strcat.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/policy/messaging_layer/encryption/encryption_module.h"
#include "chrome/browser/policy/messaging_layer/public/report_queue_configuration.h"
......@@ -98,6 +99,10 @@ Record ReportQueue::AugmentRecord(base::StringPiece record_data) {
record.set_data(std::string(record_data));
record.set_destination(config_->destination());
record.set_dm_token(config_->dm_token().value());
// Calculate timestamp in microseconds - to match Spanner expectations.
const int64_t time_since_epoch_us =
base::Time::Now().ToDeltaSinceWindowsEpoch().InMicroseconds();
record.set_timestamp_us(time_since_epoch_us);
return record;
}
......
......@@ -20,7 +20,7 @@ message Record {
//
// Current expected formats (destination : type):
// Destination::UPLOAD_EVENTS : UploadEventsRequest
optional string data = 1;
optional bytes data = 1;
// The destination associated with this request as set with the
// ReportingQueueConfiguration (required).
......@@ -29,6 +29,11 @@ message Record {
// The DMToken associated with this request as set with the
// ReportingQueueConfiuguration (required).
optional string dm_token = 3;
// When the record was submitted to ReportingQueue::Enqueue.
// Represents UTC time since Unix epoch 1970-01-01T00:00:00Z in microseconds,
// to match Spanner timestamp format.
optional int64 timestamp_us = 4;
}
// A Record with it's digest and the digest of the previous record.
......@@ -87,7 +92,7 @@ message SequencingInformation {
message EncryptedRecord {
// Encrypted Wrapped Record (required)
// |WrappedRecord| encrypted with the |encryption_key| in |encryption_info|.
optional string encrypted_wrapped_record = 1;
optional bytes encrypted_wrapped_record = 1;
optional EncryptionInfo encryption_info = 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment