Skip to content

Commit

Permalink
Send P2A json messages to the P3A endpoint.
Browse files Browse the repository at this point in the history
These are handled with the same reporting software and privacy
protections on the server-side, so there's no value to maintaining
a separate endpoint for the P2A message type. Instead, send them
all to p3a-json.brave.com and sort into the approprate queue
on the back end.

Resolves brave/brave-browser#20478
  • Loading branch information
rillian committed Mar 30, 2022
1 parent 005d188 commit 0c1206d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
18 changes: 6 additions & 12 deletions components/p3a/brave_p3a_new_uploader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,19 @@ net::NetworkTrafficAnnotationTag GetNetworkTrafficAnnotation(

BraveP3ANewUploader::BraveP3ANewUploader(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const GURL& p3a_endpoint,
const GURL& p2a_endpoint)
: url_loader_factory_(url_loader_factory),
p3a_endpoint_(p3a_endpoint),
p2a_endpoint_(p2a_endpoint) {}
const GURL& p3a_endpoint)
: url_loader_factory_(url_loader_factory), p3a_endpoint_(p3a_endpoint) {}

BraveP3ANewUploader::~BraveP3ANewUploader() = default;

void BraveP3ANewUploader::UploadLog(const std::string& compressed_log_data,
const std::string& upload_type) {
auto resource_request = std::make_unique<network::ResourceRequest>();
if (upload_type == "p2a") {
resource_request->url = p2a_endpoint_;
resource_request->headers.SetHeader("X-Brave-P2A", "?1");
// TODO(issues/20478): Re-enable once backend is ready.
return;
} else if (upload_type == "p3a") {
resource_request->url = p3a_endpoint_;
resource_request->url = p3a_endpoint_;
if (upload_type == "p3a") {
resource_request->headers.SetHeader("X-Brave-P3A", "?1");
} else if (upload_type == "p2a") {
resource_request->headers.SetHeader("X-Brave-P2A", "?1");
} else {
NOTREACHED();
}
Expand Down
4 changes: 1 addition & 3 deletions components/p3a/brave_p3a_new_uploader.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class BraveP3ANewUploader {
public:
BraveP3ANewUploader(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const GURL& p3a_endpoint,
const GURL& p2a_endpoint);
const GURL& p3a_endpoint);

BraveP3ANewUploader(const BraveP3ANewUploader&) = delete;
BraveP3ANewUploader& operator=(const BraveP3ANewUploader&) = delete;
Expand All @@ -44,7 +43,6 @@ class BraveP3ANewUploader {
private:
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
const GURL p3a_endpoint_;
const GURL p2a_endpoint_;
std::unique_ptr<network::SimpleURLLoader> url_loader_;
};

Expand Down
5 changes: 2 additions & 3 deletions components/p3a/brave_p3a_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ constexpr char kP3AServerUrl[] = "https://p3a.brave.com/";
constexpr char kP2AServerUrl[] = "https://p2a.brave.com/";

constexpr char kP3AJsonServerUrl[] = "https://p3a-json.brave.com/";
constexpr char kP2AJsonServerUrl[] = "https://p2a-json.brave.com/";

constexpr uint64_t kDefaultUploadIntervalSeconds = 60; // 1 minute.

Expand Down Expand Up @@ -292,8 +291,8 @@ void BraveP3AService::Init(
url_loader_factory, upload_server_url_, GURL(kP2AServerUrl),
base::BindRepeating(&BraveP3AService::OnLogUploadComplete, this)));

new_uploader_.reset(new BraveP3ANewUploader(
url_loader_factory, GURL(kP3AJsonServerUrl), GURL(kP2AJsonServerUrl)));
new_uploader_.reset(
new BraveP3ANewUploader(url_loader_factory, GURL(kP3AJsonServerUrl)));

upload_scheduler_.reset(new BraveP3AScheduler(
base::BindRepeating(&BraveP3AService::StartScheduledUpload, this),
Expand Down

0 comments on commit 0c1206d

Please sign in to comment.