Commit 99f944fa authored by Himanshu Jaju's avatar Himanshu Jaju Committed by Commit Bot

Update wire_format.proto

Updates wire_format to latest internal version, will be used by upcoming
changes for nearby share.

Bug: 1085068
Change-Id: I7ac7796e9fb89f5efda5c950a3662ab6d8ab21a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2306046Reviewed-by: default avatarAlex Chau <alexchau@chromium.org>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Commit-Queue: Himanshu Jaju <himanshujaju@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789989}
parent a12697ca
...@@ -44,7 +44,8 @@ std::vector<mojom::FileMetadataPtr> GetFileMetadata( ...@@ -44,7 +44,8 @@ std::vector<mojom::FileMetadataPtr> GetFileMetadata(
proto_frame.file_metadata()) { proto_frame.file_metadata()) {
mojo_file_metadatas.push_back(mojom::FileMetadata::New( mojo_file_metadatas.push_back(mojom::FileMetadata::New(
metadata.name(), ConvertFileMetadataType(metadata.type()), metadata.name(), ConvertFileMetadataType(metadata.type()),
metadata.payload_id(), metadata.size(), metadata.mime_type())); metadata.payload_id(), metadata.size(), metadata.mime_type(),
metadata.id()));
} }
return mojo_file_metadatas; return mojo_file_metadatas;
...@@ -75,7 +76,7 @@ std::vector<mojom::TextMetadataPtr> GetTextMetadata( ...@@ -75,7 +76,7 @@ std::vector<mojom::TextMetadataPtr> GetTextMetadata(
proto_frame.text_metadata()) { proto_frame.text_metadata()) {
mojo_text_metadatas.push_back(mojom::TextMetadata::New( mojo_text_metadatas.push_back(mojom::TextMetadata::New(
metadata.text_title(), ConvertTextMetadataType(metadata.type()), metadata.text_title(), ConvertTextMetadataType(metadata.type()),
metadata.payload_id(), metadata.size())); metadata.payload_id(), metadata.size(), metadata.id()));
} }
return mojo_text_metadatas; return mojo_text_metadatas;
...@@ -104,7 +105,7 @@ std::vector<mojom::WifiCredentialsMetadataPtr> GetWifiMetadata( ...@@ -104,7 +105,7 @@ std::vector<mojom::WifiCredentialsMetadataPtr> GetWifiMetadata(
proto_frame.wifi_credentials_metadata()) { proto_frame.wifi_credentials_metadata()) {
mojo_wifi_metadatas.push_back(mojom::WifiCredentialsMetadata::New( mojo_wifi_metadatas.push_back(mojom::WifiCredentialsMetadata::New(
metadata.ssid(), ConvertSecurityType(metadata.security_type()), metadata.ssid(), ConvertSecurityType(metadata.security_type()),
metadata.payload_id())); metadata.payload_id(), metadata.id()));
} }
return mojo_wifi_metadatas; return mojo_wifi_metadatas;
...@@ -304,6 +305,9 @@ void NearbySharingDecoder::DecodeFrame(const std::vector<uint8_t>& data, ...@@ -304,6 +305,9 @@ void NearbySharingDecoder::DecodeFrame(const std::vector<uint8_t>& data,
mojo_v1frame->set_certificate_info( mojo_v1frame->set_certificate_info(
GetCertificateInfoFrame(proto_frame.v1().certificate_info())); GetCertificateInfoFrame(proto_frame.v1().certificate_info()));
break; break;
case sharing::nearby::V1Frame_FrameType_CANCEL:
mojo_v1frame->set_cancel_frame(mojom::CancelFrame::New());
break;
default: default:
LOG(ERROR) << "Unknown type of v1frame, unable to process."; LOG(ERROR) << "Unknown type of v1frame, unable to process.";
std::move(callback).Run(nullptr); std::move(callback).Run(nullptr);
......
...@@ -109,6 +109,7 @@ void ExpectFrameContainsIntroduction( ...@@ -109,6 +109,7 @@ void ExpectFrameContainsIntroduction(
EXPECT_EQ(base::checked_cast<uint64_t>(file_metadata[i].size()), EXPECT_EQ(base::checked_cast<uint64_t>(file_metadata[i].size()),
file->size); file->size);
EXPECT_EQ(file_metadata[i].mime_type(), file->mime_type); EXPECT_EQ(file_metadata[i].mime_type(), file->mime_type);
EXPECT_EQ(file_metadata[i].id(), file->id);
} }
// Verify contents of TextMetadata vector. // Verify contents of TextMetadata vector.
...@@ -121,6 +122,7 @@ void ExpectFrameContainsIntroduction( ...@@ -121,6 +122,7 @@ void ExpectFrameContainsIntroduction(
EXPECT_EQ(text_metadata[i].payload_id(), text->payload_id); EXPECT_EQ(text_metadata[i].payload_id(), text->payload_id);
EXPECT_EQ(base::checked_cast<uint64_t>(text_metadata[i].size()), EXPECT_EQ(base::checked_cast<uint64_t>(text_metadata[i].size()),
text->size); text->size);
EXPECT_EQ(text_metadata[i].id(), text->id);
} }
EXPECT_EQ(required_package, intro->required_package); EXPECT_EQ(required_package, intro->required_package);
...@@ -135,6 +137,7 @@ void ExpectFrameContainsIntroduction( ...@@ -135,6 +137,7 @@ void ExpectFrameContainsIntroduction(
EXPECT_EQ(wifi_credentials_metadata[i].security_type(), EXPECT_EQ(wifi_credentials_metadata[i].security_type(),
ConvertWifiCredentialsMetadataType(wifi->security_type)); ConvertWifiCredentialsMetadataType(wifi->security_type));
EXPECT_EQ(wifi_credentials_metadata[i].payload_id(), wifi->payload_id); EXPECT_EQ(wifi_credentials_metadata[i].payload_id(), wifi->payload_id);
EXPECT_EQ(wifi_credentials_metadata[i].id(), wifi->id);
} }
} }
...@@ -171,6 +174,12 @@ void ExpectFrameContainsPairedKeyEncryption(const mojom::FramePtr& frame, ...@@ -171,6 +174,12 @@ void ExpectFrameContainsPairedKeyEncryption(const mojom::FramePtr& frame,
frame->get_v1()->get_paired_key_encryption()->secret_id_hash); frame->get_v1()->get_paired_key_encryption()->secret_id_hash);
} }
void ExpectFrameContainsCancelFrame(const mojom::FramePtr& frame) {
ASSERT_TRUE(frame);
ASSERT_TRUE(frame->is_v1());
EXPECT_TRUE(frame->get_v1()->is_cancel_frame());
}
std::unique_ptr<sharing::nearby::Frame> BuildPairedKeyResultFrame( std::unique_ptr<sharing::nearby::Frame> BuildPairedKeyResultFrame(
sharing::nearby::PairedKeyResultFrame_Status status) { sharing::nearby::PairedKeyResultFrame_Status status) {
std::unique_ptr<sharing::nearby::Frame> frame = std::unique_ptr<sharing::nearby::Frame> frame =
...@@ -328,6 +337,7 @@ TEST_F(NearbySharingDecoderTest, IntroductionFrameDecoding) { ...@@ -328,6 +337,7 @@ TEST_F(NearbySharingDecoderTest, IntroductionFrameDecoding) {
file->set_payload_id(i); file->set_payload_id(i);
file->set_size(i); file->set_size(i);
file->set_mime_type("mime " + base::NumberToString(i)); file->set_mime_type("mime " + base::NumberToString(i));
file->set_id(i);
files.push_back(*file); files.push_back(*file);
} }
...@@ -342,6 +352,7 @@ TEST_F(NearbySharingDecoderTest, IntroductionFrameDecoding) { ...@@ -342,6 +352,7 @@ TEST_F(NearbySharingDecoderTest, IntroductionFrameDecoding) {
text->set_type(static_cast<sharing::nearby::TextMetadata_Type>(i)); text->set_type(static_cast<sharing::nearby::TextMetadata_Type>(i));
text->set_payload_id(i); text->set_payload_id(i);
text->set_size(i); text->set_size(i);
text->set_id(i);
texts.push_back(*text); texts.push_back(*text);
} }
...@@ -362,6 +373,7 @@ TEST_F(NearbySharingDecoderTest, IntroductionFrameDecoding) { ...@@ -362,6 +373,7 @@ TEST_F(NearbySharingDecoderTest, IntroductionFrameDecoding) {
wifi->set_security_type( wifi->set_security_type(
static_cast<sharing::nearby::WifiCredentialsMetadata_SecurityType>(i)); static_cast<sharing::nearby::WifiCredentialsMetadata_SecurityType>(i));
wifi->set_payload_id(i); wifi->set_payload_id(i);
wifi->set_id(i);
wifis.push_back(*wifi); wifis.push_back(*wifi);
} }
...@@ -524,6 +536,24 @@ TEST_F(NearbySharingDecoderTest, V1FrameMissingPairedKeyResultFrameDecoding) { ...@@ -524,6 +536,24 @@ TEST_F(NearbySharingDecoderTest, V1FrameMissingPairedKeyResultFrameDecoding) {
ExpectNullFrame(frame); ExpectNullFrame(frame);
} }
TEST_F(NearbySharingDecoderTest, CancelFrameSuccessDecoding) {
sharing::nearby::Frame frame = sharing::nearby::Frame();
sharing::nearby::V1Frame* v1frame = frame.mutable_v1();
v1frame->set_type(sharing::nearby::V1Frame_FrameType_CANCEL);
std::vector<uint8_t> data;
data.resize(frame.ByteSize());
ASSERT_TRUE(frame.SerializeToArray(&data[0], frame.ByteSize()));
base::RunLoop run_loop;
auto callback = base::BindLambdaForTesting([&](const mojom::FramePtr answer) {
ExpectFrameContainsCancelFrame(answer);
run_loop.Quit();
});
decoder()->DecodeFrame(std::move(data), std::move(callback));
run_loop.Run();
}
TEST_F(NearbySharingDecoderTest, PairedKeyResultFrameSuccessDecoding) { TEST_F(NearbySharingDecoderTest, PairedKeyResultFrameSuccessDecoding) {
std::unique_ptr<sharing::nearby::Frame> frame = BuildPairedKeyResultFrame( std::unique_ptr<sharing::nearby::Frame> frame = BuildPairedKeyResultFrame(
sharing::nearby::PairedKeyResultFrame_Status_SUCCESS); sharing::nearby::PairedKeyResultFrame_Status_SUCCESS);
......
...@@ -35,6 +35,8 @@ union V1Frame { ...@@ -35,6 +35,8 @@ union V1Frame {
PairedKeyResultFrame paired_key_result; PairedKeyResultFrame paired_key_result;
CertificateInfoFrame certificate_info; CertificateInfoFrame certificate_info;
CancelFrame cancel_frame;
}; };
// An introduction packet sent by the sending side. Contains a list of files // An introduction packet sent by the sending side. Contains a list of files
...@@ -81,6 +83,9 @@ struct FileMetadata { ...@@ -81,6 +83,9 @@ struct FileMetadata {
// The mimeType of file (eg. 'image/jpeg' from 'dog.jpg'). Specifying a // The mimeType of file (eg. 'image/jpeg' from 'dog.jpg'). Specifying a
// mimeType helps provide a richer experience on receiving side. // mimeType helps provide a richer experience on receiving side.
string mime_type = "application/octet-stream"; string mime_type = "application/octet-stream";
// A uuid for the attachment. Should be unique across all attachments.
int64 id;
}; };
// Text metadata. Does not include the actual bytes of the text in transit. // Text metadata. Does not include the actual bytes of the text in transit.
...@@ -108,6 +113,9 @@ struct TextMetadata { ...@@ -108,6 +113,9 @@ struct TextMetadata {
// The size of the text content. // The size of the text content.
uint64 size; uint64 size;
// A uuid for the attachment. Should be unique across all attachments.
int64 id;
}; };
// Wifi credentails metadata. Describes the wifi network to be used by the // Wifi credentails metadata. Describes the wifi network to be used by the
...@@ -129,6 +137,9 @@ struct WifiCredentialsMetadata { ...@@ -129,6 +137,9 @@ struct WifiCredentialsMetadata {
// The BYTE payload id that will be sent as a follow up containing the // The BYTE payload id that will be sent as a follow up containing the
// password. // password.
int64 payload_id; int64 payload_id;
// A uuid for the attachment. Should be unique across all attachments.
int64 id;
}; };
// A response packet sent by the receiving side. Accepts or rejects the list of // A response packet sent by the receiving side. Accepts or rejects the list of
...@@ -208,3 +219,7 @@ struct PublicCertificate { ...@@ -208,3 +219,7 @@ struct PublicCertificate {
// The size should be 32. // The size should be 32.
array<uint8> metadata_encryption_key_tag; array<uint8> metadata_encryption_key_tag;
}; };
// Frame sent by remote device to cancel the share action.
struct CancelFrame {
};
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// Brought from: //depot/google3/location/nearby/sharing/proto/wire_format.proto // Brought from: //depot/google3/location/nearby/sharing/proto/wire_format.proto
// At CL 311037085 // At CL 317565061
syntax = "proto2"; syntax = "proto2";
...@@ -40,6 +40,9 @@ message FileMetadata { ...@@ -40,6 +40,9 @@ message FileMetadata {
// The mimeType of file (eg. 'image/jpeg' from 'dog.jpg'). Specifying a // The mimeType of file (eg. 'image/jpeg' from 'dog.jpg'). Specifying a
// mimeType helps provide a richer experience on receiving side. // mimeType helps provide a richer experience on receiving side.
optional string mime_type = 5 [default = "application/octet-stream"]; optional string mime_type = 5 [default = "application/octet-stream"];
// A uuid for the attachment. Should be unique across all attachments.
optional int64 id = 6;
} }
// NEXT_ID=5 // NEXT_ID=5
...@@ -67,6 +70,9 @@ message TextMetadata { ...@@ -67,6 +70,9 @@ message TextMetadata {
// The size of the text content. // The size of the text content.
optional int64 size = 5; optional int64 size = 5;
// A uuid for the attachment. Should be unique across all attachments.
optional int64 id = 6;
} }
// NEXT_ID=5 // NEXT_ID=5
...@@ -87,6 +93,9 @@ message WifiCredentialsMetadata { ...@@ -87,6 +93,9 @@ message WifiCredentialsMetadata {
// The BYTE payload id that will be sent as a follow up containing the // The BYTE payload id that will be sent as a follow up containing the
// password. // password.
optional int64 payload_id = 4; optional int64 payload_id = 4;
// A uuid for the attachment. Should be unique across all attachments.
optional int64 id = 5;
} }
// A frame used when sending messages over the wire. // A frame used when sending messages over the wire.
...@@ -112,6 +121,7 @@ message V1Frame { ...@@ -112,6 +121,7 @@ message V1Frame {
PAIRED_KEY_ENCRYPTION = 3; PAIRED_KEY_ENCRYPTION = 3;
PAIRED_KEY_RESULT = 4; PAIRED_KEY_RESULT = 4;
CERTIFICATE_INFO = 5; CERTIFICATE_INFO = 5;
CANCEL = 6;
} }
optional FrameType type = 1; optional FrameType type = 1;
......
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