Commit 0ec64532 authored by Michael Hansen's avatar Michael Hansen Committed by Commit Bot

[Nearby] Add location hint for WebRTC.

Because WebRTC is geo-sharded, both peer devices must specify the same
locale / "location hint" in order to signal each other via Tachyon.

The location hint is in ISO 3166-1 alpha-2 format:
  https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

Bug: 1134210
Change-Id: Ic42c7139bd2ac96de8d6ffebe5c15bb70be0c9aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2447096Reviewed-by: default avatarJames Vecore <vecore@google.com>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Commit-Queue: Michael Hansen <hansenmichael@google.com>
Cr-Commit-Position: refs/heads/master@{#814880}
parent 3521665c
......@@ -36,10 +36,35 @@ message IdType {
}
}
message LocationStandard {
enum Format {
UNKNOWN = 0;
// E164 country codes:
// https://en.wikipedia.org/wiki/List_of_country_calling_codes
// e.g. +1 for USA
E164_CALLING = 1;
// ISO 3166-1 alpha-2 country codes:
// https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
ISO_3166_1_ALPHA_2 = 2;
}
}
// LocationHint is used to specify a location as well as format.
message LocationHint {
// Location is the location, provided in the format specified by format.
string location = 1;
// the format of location.
LocationStandard.Format format = 2;
}
message Id {
IdType.Type type = 1;
string id = 2;
string app = 3;
string country_code = 4 [deprecated = true];
LocationHint location_hint = 5;
}
message ApiVersion {
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/nearby_sharing/webrtc_signaling_messenger.h"
#include "base/bind_helpers.h"
#include "base/i18n/timezone.h"
#include "base/token.h"
#include "chrome/browser/nearby_sharing/instantmessaging/proto/instantmessaging.pb.h"
......@@ -16,6 +17,13 @@ constexpr int kMajorVersion = 1;
constexpr int kMinorVersion = 24;
constexpr int kPointVersion = 0;
void BuildLocationHint(
chrome_browser_nearby_sharing_instantmessaging::LocationHint* hint) {
hint->set_location(base::CountryCodeForCurrentTimezone());
hint->set_format(chrome_browser_nearby_sharing_instantmessaging::
LocationStandard_Format_ISO_3166_1_ALPHA_2);
}
void BuildId(chrome_browser_nearby_sharing_instantmessaging::Id* req_id,
const std::string& id) {
DCHECK(req_id);
......@@ -23,6 +31,7 @@ void BuildId(chrome_browser_nearby_sharing_instantmessaging::Id* req_id,
req_id->set_app(kAppName);
req_id->set_type(
chrome_browser_nearby_sharing_instantmessaging::IdType::NEARBY_ID);
BuildLocationHint(req_id->mutable_location_hint());
}
void BuildHeader(
......
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