Bug 1826076 - Make toolkit/components/telemetry/pingsender buildable outside of a unified build environment r=andi

Differential Revision: https://phabricator.services.mozilla.com/D174462
This commit is contained in:
serge-sans-paille 2023-04-03 20:39:16 +00:00
Родитель 28f6f63857
Коммит 381e5faa2b
5 изменённых файлов: 19 добавлений и 11 удалений

Просмотреть файл

@ -36,5 +36,3 @@ else:
# Don't use the STL wrappers; we don't link with -lmozalloc, and it really
# doesn't matter here anyway.
DisableStlWrapping()
REQUIRES_UNIFIED_BUILD = True

Просмотреть файл

@ -23,13 +23,6 @@ using std::vector;
namespace PingSender {
const char* kUserAgent = "pingsender/1.0";
const char* kCustomVersionHeader = "X-PingSender-Version: 1.0";
const char* kContentEncodingHeader = "Content-Encoding: gzip";
// The maximum time, in milliseconds, we allow for the connection phase
// to the server.
const uint32_t kConnectionTimeoutMs = 30 * 1000;
// Operate in std::string because nul bytes will be preserved
bool IsValidDestination(std::string aHost) {
static const std::string kValidDestinations[] = {

Просмотреть файл

@ -3,6 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_telemetry_pingsender_h
#define mozilla_telemetry_pingsender_h
#include <string>
#ifdef DEBUG
@ -13,6 +16,13 @@
namespace PingSender {
// The maximum time, in milliseconds, we allow for the connection phase
// to the server.
constexpr uint32_t kConnectionTimeoutMs = 30 * 1000;
constexpr char kUserAgent[] = "pingsender/1.0";
constexpr char kCustomVersionHeader[] = "X-PingSender-Version: 1.0";
constexpr char kContentEncodingHeader[] = "Content-Encoding: gzip";
// System-specific function that changes the current working directory to be
// the same as the one containing the ping file. This is currently required on
// Windows to release the Firefox installation folder (see bug 1597803 for more
@ -24,5 +34,8 @@ bool Post(const std::string& url, const std::string& payload);
bool IsValidDestination(char* aUriEndingInHost);
bool IsValidDestination(std::string aUriEndingInHost);
std::string GenerateDateHeader();
} // namespace PingSender
#endif

Просмотреть файл

@ -12,6 +12,8 @@
#include "mozilla/Unused.h"
#include "third_party/curl/curl.h"
#include "pingsender.h"
namespace PingSender {
using std::string;
@ -199,7 +201,7 @@ bool FallbackIsValidDestination(const string& aUrl) {
unsigned long portStart = url.find_last_of(":");
url = (portStart == std::string::npos) ? url : url.substr(0, portStart);
return ::IsValidDestination(url);
return PingSender::IsValidDestination(url);
}
bool CurlWrapper::IsValidDestination(const string& aUrl) {
@ -222,7 +224,7 @@ bool CurlWrapper::IsValidDestination(const string& aUrl) {
goto cleanup;
}
ret = ::IsValidDestination(host);
ret = PingSender::IsValidDestination(host);
curl_free(host);
cleanup:

Просмотреть файл

@ -9,6 +9,8 @@
#include <windows.h>
#include <wininet.h>
#include "pingsender.h"
namespace PingSender {
using std::string;